disallow empty named dims list to flatten(names, name) (#61953)
authorMatti Picus <matti.picus@gmail.com>
Wed, 1 Sep 2021 01:54:44 +0000 (18:54 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 1 Sep 2021 02:32:30 +0000 (19:32 -0700)
commit6bb4b5d150ab51ed15d15ed270471848bb84d4e3
tree12851c0a1fdfc528e94d75fe3edffd91f39df5d0
parentc59970db6b7831c34053ecd5f86ce688bf68df7d
disallow empty named dims list to flatten(names, name) (#61953)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/61137 by raising an error if an empty tuple is passed in for the names:
```
>>> torch.empty((2, 3), names=['a', 'b']).flatten((), 'abc')
RuntimeError: flatten(tensor, dims, out_dim): dims cannot be empty
```

or from the original issue:
```
>>> torch.empty((2, 3)).flatten((), 'abc')
RuntimeError: flatten(tensor, dims, out_dim): dims cannot be empty
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/61953

Reviewed By: iramazanli

Differential Revision: D30574571

Pulled By: malfet

fbshipit-source-id: e606e84458a8dd66e5da6d0eb1a260f37b4ce91b
aten/src/ATen/native/TensorShape.cpp
test/test_namedtensor.py