-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
🚀 Feature
The functional_tensor.py file makes use of the private method _is_tensor_a_torch_image in every public operator to check its dimensions:
vision/torchvision/transforms/functional_tensor.py
Lines 10 to 11 in dab4757
| def _is_tensor_a_torch_image(x: Tensor) -> bool: | |
| return x.ndim >= 2 |
Examples:
vision/torchvision/transforms/functional_tensor.py
Lines 146 to 147 in dab4757
| if not _is_tensor_a_torch_image(img): | |
| raise TypeError('tensor is not a torch image.') |
vision/torchvision/transforms/functional_tensor.py
Lines 166 to 167 in dab4757
| if not _is_tensor_a_torch_image(img): | |
| raise TypeError('tensor is not a torch image.') |
This check is repetitive and reduces the code readability. We should fix this by using decorators. See #3123 (comment) for details. assertions.
cc @vfdev-5
vfdev-5