import torch
a = torch.randn(1,3)
a.expand([-2, 2, 1, 3])
I got error message as below:
Traceback (most recent call last):
File "", line 1, in
File "/home/pytorch/torch/_tensor.py", line 341, in repr
return torch._tensor_str._str(self)
File "/home/pytorch/torch/_tensor_str.py", line 439, in _str
return _str_intern(self)
File "/home/pytorch/torch/_tensor_str.py", line 414, in _str_intern
tensor_str = _tensor_str(self, indent)
File "/home/pytorch/torch/_tensor_str.py", line 264, in _tensor_str
formatter = _Formatter(get_summarized_data(self) if summarize else self)
File "/home/pytorch/torch/_tensor_str.py", line 92, in init
tensor_view = tensor.reshape(-1)
RuntimeError: Trying to create tensor with negative dimension -2: [-2, 2, 1, 3]
It seems to report 'reshape' has invalid parameter, actually expand op does. It causes confuse sometime. Maybe torch should check 'targerSize' in inferExpandGeometryImpl to make sure it is greater than or equal to 0.
🐛 Describe the bug
when I run below code
I got error message as below:
It seems to report 'reshape' has invalid parameter, actually expand op does. It causes confuse sometime. Maybe torch should check 'targerSize' in inferExpandGeometryImpl to make sure it is greater than or equal to 0.
Versions
'1.12.0a0+git0aa3c39'