Repository: pytorch
Issue: Suboptimal error message - nn.Linear with double argument
Labels: module: error checking,triaged

### 🐛 Describe the bug

Following code fails with error message below:
```python
from torch import nn


net = nn.Linear(10, 10)

t = torch.tensor([1.]*10, dtype=torch.double)
net(t)
```

Error:
```
Traceback (most recent call last):
  File "~/Library/Application Support/JetBrains/PyCharm2022.1/scratches/ntuple.py", line 15, in <module>
    net(t)
  File "~/venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "~/venv/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 103, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: expected scalar type Double but found Float
```

There are two things I don't get with this message:
1. I'm passing in a dtype=torch.double, but the message complains inversely that it *expects* Double and found Float. This must be due to order of operations inside nn.Linear, but as a user I am responsible in the first line for type of my inputs, so saying "expects Float, found Double" would make me discover my bugs faster.
2. Why does it say `scalar type`? weight, bias and input are all non-scalars.

In my opinion it would make sense to say explicitly what had what time in this mismatch. Something along lines: "nn.Linear of type `torch.float` expects input of type `torch.float`, but input of type `torch.double` was given."

### Versions

PyTorch version: 1.11.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 11.6.5 (x86_64)
GCC version: Could not collect
Clang version: 12.0.5 (clang-1205.0.22.9)
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.12 (main, Mar 26 2022, 15:52:10)  [Clang 13.0.0 (clang-1300.0.29.30)] (64-bit runtime)
Python platform: macOS-11.6.5-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.6
[pip3] torch==1.11.0
[conda] blas                      1.0                         mkl    https://repo.anaconda.com/pkgs/main
[conda] mkl                       2021.2.0           hecd8cb5_269    https://repo.anaconda.com/pkgs/main
[conda] mkl-service               2.3.0            py38h9ed2024_1    https://repo.anaconda.com/pkgs/main
[conda] mkl_fft                   1.3.0            py38h4a7008c_2    https://repo.anaconda.com/pkgs/main
[conda] mkl_random                1.2.1            py38hb2f4e1b_2    https://repo.anaconda.com/pkgs/main
[conda] numpy                     1.22.2                   pypi_0    pypi
[conda] numpydoc                  1.1.0              pyhd3eb1b0_1    https://repo.anaconda.com/pkgs/main
[conda] torch                     1.11.0                   pypi_0    pypi
[conda] torchvision               0.10.0                   pypi_0    pypi