Does torch.nn.Linear check the weights shape before assignment? #125116
Labels
module: nn
Related to torch.nn
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃悰 Describe the bug
Recently, l found that when l directly attribute weights to torch.nn.Linear, the shape of weights dismatch the in_features and out_features, but it still works.
However, when l set the output shape to [100, 70] which is the original shape l want. Errors come.
So, l want to know whether the Linear check the weights shape before assignment? Or, there is a more correct way to attribute weights?
Versions
[pip3] numpy==1.24.4
[pip3] torch==2.0.1
[pip3] torchvision==0.15.2
[pip3] triton==2.0.0
[conda] numpy 1.24.4 pypi_0 pypi
[conda] torch 2.0.1 pypi_0 pypi
[conda] torchvision 0.15.2 pypi_0 pypi
[conda] triton 2.0.0 pypi_0 pypi
cc @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki
The text was updated successfully, but these errors were encountered: