Uploaded image for project: 'AI Platform Core Components'
  1. AI Platform Core Components
  2. AIPCC-6398

`input_size` argument of `nn.RNN()` gets indirect error messages

    • Icon: Story Story
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • None
    • PyTorch
    • None
    • PyTorch Sprint 18, PyTorch Sprint 19, PyTorch Sprint 20, PyTorch Sprint 21, PyTorch Sprint 22

          1. 🐛 Describe the bug

      Setting the float value `3.` to `input_size` of [nn.RNN()](https://pytorch.org/docs/stable/generated/torch.nn.RNN.html) gets the indirect error message as shown below:

      ```python
      import torch
      from torch import nn

      my_tensor = torch.tensor([[8., -3., 5.]])

      torch.manual_seed(42)

      1. ↓↓
        rnn = nn.RNN(input_size=3., hidden_size=2) # Error

      rnn(input=my_tensor)
      ```

      > TypeError: empty(): argument 'size' failed to unpack the object at pos 2 with error "type must be tuple of ints,but got float"

      And, setting the boolean value `True` to `input_size` of `nn.RNN()` gets the indirect error message as shown below:

      ```python
      import torch
      from torch import nn

      my_tensor = torch.tensor([[8., -3., 5.]])

      torch.manual_seed(42)

      1. ↓↓↓↓
        rnn = nn.RNN(input_size=True, hidden_size=2)

      rnn(input=my_tensor) # Error
      ```

      > RuntimeError: input.size(-1) must be equal to input_size. Expected True, got 3

      So, the error messages should be something direct like as shown below:

      > TypeError: `input_size` argument must be `int` but got `float`

      > TypeError: `input_size` argument must be `int` but got `bool`

          1. Versions

      ```python
      import torch

      torch._version_ # '2.3.0'
      ```

      cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki

              rh-ee-visgoyal Vishal Goyal
              rh-ee-visgoyal Vishal Goyal
              PyTorch Core
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: