Skip to content

Allow for arbitrary sequences in torchvision/transforms/functional #5398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Parskatt opened this issue Feb 9, 2022 · 2 comments
Open

Allow for arbitrary sequences in torchvision/transforms/functional #5398

Parskatt opened this issue Feb 9, 2022 · 2 comments

Comments

@Parskatt
Copy link
Contributor

Parskatt commented Feb 9, 2022

🚀 The feature

Replace all checks for (list,tuple) in functional with Iterable.

Motivation, pitch

There are about 8 checks in functional right now which requires the argument to be either list or tuple, e.g.
https://github.com/pytorch/vision/blob/main/torchvision/transforms/functional.py#L1059
Instead of performing these checks, simply checking for Iterable allows to use e.g. numpy arrays.

In my usecase i generate parameters using numpy, and I don't want to convert them.

The documentation indicates that general sequences should work, so the current checks are counter-intuitive.

Alternatives

No response

Additional context

No response

cc @vfdev-5 @datumbox

@datumbox
Copy link
Contributor

datumbox commented Feb 9, 2022

Sounds reasonable but note we are limited due to JIT compatibility. We wound't be able to add for example numpy arrays in the check because that won't be JIT-scritable. We need to review what exactly is supported by JIT and what's the common denominator/type for iterable objects.

@pmeier @vfdev-5 Good feedback for the new API. Perhaps we could push all these checks on the non-JIT-scriptable high-level kernels and allow the low-level ones just work on input with minimal validation. Thoughts?

@pmeier
Copy link
Collaborator

pmeier commented Feb 15, 2022

Given that we do not plan to make the transforms (objects not kernels) JIT scriptable, I think we should be able to fix the annotations on the transforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants