Fix error message stack overflow (#25146)
Summary:
When the given input size is larger than expected, `weight_sizes` is `k`-length but only has `weight_dim` numbers. And it causes the confusing error message:
```
RuntimeError: Expected 4-dimensional input for 4-dimensional
weight 256 5 3 3 3987964488216321853 94670871813000,
but got 6-dimensional input of size [1, 61, 1, 5, 64, 64] instead
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25146
Differential Revision: D17233651
Pulled By: soumith
fbshipit-source-id: c6ddfa45e854f9b95ca253052f8bc358e35fd9d4