Skip to content

Simplify dimension checks on functional_tensor.py #3159

Closed
@datumbox

Description

@datumbox

🚀 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:

def _is_tensor_a_torch_image(x: Tensor) -> bool:
return x.ndim >= 2

Examples:

if not _is_tensor_a_torch_image(img):
raise TypeError('tensor is not a torch image.')

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions