-
Notifications
You must be signed in to change notification settings - Fork 7k
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
allow len 1 sequences for fill with PIL #7928
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if green, thanks. Let's just make sure we don't need to update any docstring before merging
Docstrings for v1 look this: vision/torchvision/transforms/transforms.py Lines 771 to 772 in a3ba01a
vision/torchvision/transforms/functional.py Lines 736 to 741 in a3ba01a
IMO, we don't need to update the docs here. The fact that PIL also supports length 1 sequences is more a QoL thing. I don't expect users to actively use it. But if they do, it is nice that the PIL and Tensor backend have the same behavior. |
Reviewed By: matteobettini Differential Revision: D49600777 fbshipit-source-id: 1b8731b6ef2e42feba0bde4dc7ee23bec6bfbe46
The length 1 sequences for
fill
were just a workaround back when JIT didn't supportUnion
. Since PIL is not restricted by JIT, we never added support for it.This means however, that for example
F.rotate(img_tensor, fill=[127])
works, whileF.rotate(img_pil, fill=[127])
doesn't.That makes parametrized tests harder, e.g.
vision/test/transforms_v2_dispatcher_infos.py
Lines 135 to 138 in a3ba01a
vision/test/test_transforms_v2_refactored.py
Lines 2584 to 2585 in a3ba01a
This PR adds support for length 1 sequences of
fill
for the PIL backend. Note, that I've implemented the fix in v1, since all our v2 PIL ops with afill
parameter are thin wrappers around the v1 kernel. LMK if that is ok. Otherwise we can also do it in a more verbose way in v2.cc @vfdev-5