Skip to content

enable arbitrary batch size for all prototype kernels #6726

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

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Oct 10, 2022

Fixes #6670. This basically only moves the squashing that we did for the video kernels into the image kernels.

If we start to merge transforms v1 and v2, we should support this better. I haven't checked, but I guesstimate that 90% - 100% of all times we need to squash / unsquash is because we use these three ops internally:

  1. img = interpolate(img, size=size, mode=interpolation, align_corners=align_corners, antialias=antialias)
  2. img = grid_sample(img, grid, mode=mode, padding_mode="zeros", align_corners=False)
  3. img = conv2d(img, kernel, groups=img.shape[-3])

I propose, we implement _nd_{interpolate, grid_sample, conv_2d} as internal utilities, so we don't have to have the arbitrary batch compatibility code everywhere. This is somewhat already implemented for 2. with

def _apply_grid_transform(

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

FYI, you are missing an import. Feel fee to merge on green CI.

@pmeier
Copy link
Collaborator Author

pmeier commented Oct 10, 2022

FYI, you are missing an import.

Well, no. It was somewhat worse than that: I accidentally removed the perspective dispatcher, but I put it back now 😛

@pmeier pmeier merged commit 17969eb into pytorch:main Oct 10, 2022
@pmeier pmeier deleted the fix-image-kernels-batch branch October 10, 2022 09:17
@pmeier pmeier mentioned this pull request Oct 10, 2022
facebook-github-bot pushed a commit that referenced this pull request Oct 17, 2022
Summary:
* enable arbitrary batch size for all prototype kernels

* put back perspective dispatcher

Reviewed By: NicolasHug

Differential Revision: D40427471

fbshipit-source-id: f8cdfdce28462d72bdb2b92a8606b3eb1ff93d15
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.

Not all prototype kernels support arbitrary batch sizes
3 participants