-
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
register tensor and PIL kernel the same way as datapoints #7797
Conversation
@@ -449,6 +394,9 @@ def test_datapoint_output_type(self, info, args_kwargs): | |||
|
|||
assert isinstance(output, type(datapoint)) | |||
|
|||
if isinstance(datapoint, datapoints.BoundingBoxes) and info.dispatcher is not F.convert_format_bounding_boxes: |
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.
Since this test is part of the legacy framework, I was to lazy to handle this more elegantly.
def check_dispatcher( | ||
dispatcher, | ||
# TODO: remove this parameter |
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.
We no longer need this parameter. However, we previously parametrized over it together with the function to create the input. Thus, removing it is chore that I'll deal with after release. It doesn't have any effect on the runtime, because the number of tests stays exactly the same after this parameter is removed.
vision/torchvision/transforms/v2/functional/_utils.py Lines 52 to 54 in f3c89cc
as part of The reason why I think this loop is valuable in general rather than just having the exact type match vision/torchvision/transforms/v2/functional/_utils.py Lines 49 to 50 in f3c89cc
is explained in #7747 (comment). |
@_register_kernel_internal(rgb_to_grayscale, datapoints.Image) | ||
def rgb_to_grayscale_image_tensor(image: torch.Tensor, num_output_channels: int = 1) -> torch.Tensor: | ||
if num_output_channels not in (1, 3): |
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.
For some reason, this previously was done on the dispatcher rather than in the kernel. I moved it to the kernel here and the same for the PIL kernel below.
@_register_kernel_internal(resize, PIL.Image.Image) | ||
def _resize_image_pil_dispatch( |
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.
I needed to extract this out due to the warning.
#7797 (comment) is resolved now with the following rules:
|
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.
Took a look at the utils and a few kernels, LGTM.
I'll approve so we don't have to go through another review round. I hope we can make the tests (comments above) a bit more trivial, but this is non-blocking and can be addressed later
Thanks a lot for all this Philip, I'm sure it wasn't fun shuffling so much code, but it's great to see that a lot of the clutter was removed from the dispatchers logic
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
…egister-tensor-pil
…7797) Summary: Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Reviewed By: matteobettini Differential Revision: D48642326 fbshipit-source-id: ee9cd9d5d32b1c4433554763812e44fb6c189fc9
Follow-up to #7747 and prerequisite for 2./3. in #7747 (comment).
cc @vfdev-5