Skip to content
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

fix elastic error #7838

Merged
merged 2 commits into from
Aug 16, 2023
Merged

fix elastic error #7838

merged 2 commits into from
Aug 16, 2023

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Aug 16, 2023

I accidentally removed an error in #7977 (thanks @vfdev-5 for spotting).

Before:

def elastic(
inpt: datapoints._InputTypeJIT,
displacement: torch.Tensor,
interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR,
fill: datapoints._FillTypeJIT = None,
) -> datapoints._InputTypeJIT:
if not torch.jit.is_scripting():
_log_api_usage_once(elastic)
if not isinstance(displacement, torch.Tensor):
raise TypeError("Argument displacement should be a Tensor")

After:

def elastic(
inpt: torch.Tensor,
displacement: torch.Tensor,
interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR,
fill: _FillTypeJIT = None,
) -> torch.Tensor:
if torch.jit.is_scripting():
return elastic_image_tensor(inpt, displacement=displacement, interpolation=interpolation, fill=fill)
_log_api_usage_once(elastic)
kernel = _get_kernel(elastic, type(inpt))
return kernel(inpt, displacement=displacement, interpolation=interpolation, fill=fill)

We could put the error back into the functional, but I feel we should raise proper error messages on the kernels as well. Although this means a little code duplication for us, as a user I would be surprised of the functional raises a proper error, but the kernel doesn't. In this case, the duplication is minimal, since all kernels beside the bounding boxes one, call the image kernel.

I've also added tests for elastic.

cc @vfdev-5

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 16, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/7838

Note: Links to docs will display an error until the docs builds have been completed.

❌ 32 New Failures

As of commit 4f44831 with merge base e0e6f7e (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Philip, lgtm!

@vfdev-5 vfdev-5 merged commit cdbbd66 into pytorch:main Aug 16, 2023
@pmeier pmeier mentioned this pull request Aug 16, 2023
@pmeier pmeier deleted the elastic-error branch August 16, 2023 14:41
facebook-github-bot pushed a commit that referenced this pull request Aug 25, 2023
Summary: Co-authored-by: vfdev <vfdev.5@gmail.com>

Reviewed By: matteobettini

Differential Revision: D48642275

fbshipit-source-id: 7bc2e758f5efb3631c5460932d1a9e2fde96f36b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants