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

SymIntify roi_align #7448

Merged
merged 9 commits into from
Mar 24, 2023
Merged

SymIntify roi_align #7448

merged 9 commits into from
Mar 24, 2023

Conversation

ezyang
Copy link
Contributor

@ezyang ezyang commented Mar 22, 2023

This is one step in making it possible to trace through roi_align in PT2 with dynamic=True; the other missing piece is a meta function.

The duplication of the C++ signatures is a bit of a chore. In PyTorch core we have a codegen that can handle it, but we don't have that here unfortunately.

Signed-off-by: Edward Z. Yang ezyang@meta.com

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 22, 2023

🔗 Helpful Links

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

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

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

ezyang and others added 5 commits March 22, 2023 19:02
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @ezyang, I just have questions at this point, nothing substantial. LMK if you need a stamp on the PR, but also feel free to merge without one if this is urgent

} // namespace detail

TORCH_LIBRARY_FRAGMENT(torchvision, m) {
m.def(TORCH_SELECTIVE_SCHEMA(
"torchvision::roi_align(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width, int sampling_ratio, bool aligned) -> Tensor"));
"torchvision::roi_align(Tensor input, Tensor rois, float spatial_scale, SymInt pooled_height, SymInt pooled_width, int sampling_ratio, bool aligned) -> Tensor"));
Copy link
Member

Choose a reason for hiding this comment

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

Since we're now only registering the SymInt signature, do we still need to keep the pre-existing roi_align definitions/declarations that are using int64_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In core, we had to keep the old signatures because the C++ API is public API, and the SymInt signature is not exactly interchangeable with the int signature (as it can affect what implicit conversions are specified). If your old signatures are not public API, we can remove them too, but I'm guessing they are public-ish? In any case, this is the most conservative change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to other strategies, as we will have to do this for every function we SymInt'ify which is going to be a bit of a pain.

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

I'm guessing they are public-ish

Yeah... They're in the "we want them to be private but we don't know who's using them in the wild" category.

Let's keep them in for now and perhaps reconsider if this becomes too much of a mess.

Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why this file is needed, or point me to a place where I can read on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is analogous to torch/_meta_registrations.py. https://docs.google.com/document/d/1GgvOe7C8_NVOMLOCwDaYV1mXXyHMXY7ExoewHqooxrs/edit#heading=h.fh8zzonyw8ng goes into what the Python meta function workflow looks like. But the basic idea is that if we write the meta functions in Python, there needs to be some flow where we can tell the C++ dispatcher about the meta function. That's the registration file here.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
@ezyang ezyang requested a review from NicolasHug March 24, 2023 17:07
ezyang and others added 2 commits March 24, 2023 10:07
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @ezyang , approving now to unblock. Do we want to add some tests before merging, or do that later?

} // namespace detail

TORCH_LIBRARY_FRAGMENT(torchvision, m) {
m.def(TORCH_SELECTIVE_SCHEMA(
"torchvision::roi_align(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width, int sampling_ratio, bool aligned) -> Tensor"));
"torchvision::roi_align(Tensor input, Tensor rois, float spatial_scale, SymInt pooled_height, SymInt pooled_width, int sampling_ratio, bool aligned) -> Tensor"));
Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

I'm guessing they are public-ish

Yeah... They're in the "we want them to be private but we don't know who's using them in the wild" category.

Let's keep them in for now and perhaps reconsider if this becomes too much of a mess.

@ezyang
Copy link
Contributor Author

ezyang commented Mar 24, 2023

@NicolasHug I'm going to try to stand up some sort of shared testing infrastructure across the repos to do it, so yeah, separate PR would be appreciated

@ezyang ezyang merged commit 8f2e5c9 into pytorch:main Mar 24, 2023
@github-actions
Copy link

Hey @ezyang!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Mar 28, 2023
NicolasHug added a commit to NicolasHug/vision that referenced this pull request Mar 31, 2023
@NicolasHug NicolasHug added the revert(ed) For reverted PRs, and PRs that revert other PRs label Mar 31, 2023
@NicolasHug NicolasHug removed the revert(ed) For reverted PRs, and PRs that revert other PRs label Apr 11, 2023
facebook-github-bot pushed a commit that referenced this pull request Apr 21, 2023
Summary:
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Reviewed By: vmoens

Differential Revision: D44552412

fbshipit-source-id: 05ce4c02d0cbb7a02bdbf4ec68f13bf2056b46c3

Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
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.

4 participants