-
Notifications
You must be signed in to change notification settings - Fork 531
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
Converts all Adaptive Pooling Ops to Linalg #2808
Conversation
Also adds support for: - aten.adaptive_max_pool1d - aten.adaptive_max_pool3d - using inputs of rank n+1 instead of n+2 (i.e., no batches)
All adaptive pooling ops will now use the same templated conversion pattern.
The AdaptiveAvgPool2d tests are failing on dynamo with the expected error message:
So I know to add those to the appropriate place in the xfail sets. However, the dynamo failures for AdaptiveAvgPool3d are more cryptic and say:
I'll do some digging to figure out what is going on there. I would like to assume it is secretly encountering the same issue as the other tests, but I'd like to figure out why it isn't giving the same error message. |
74cf105
to
68d404d
Compare
8a4afeb
to
60e9346
Compare
amended for a typo
1762cba
to
2d6784c
Compare
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.
Looks like a nice improvement! Just a few minor suggestions.
also stores isMaxPool as part of the same struct as Dim
Seeing if it's possible to use polymorphism to clean up conversion
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.
This looks good to me. Thanks for making the suggested changes (the template to determine dim and isMax is very nice). @zjgarvey feel free to get the opinion of a more experienced torch-mlir-er if you like.
This one off-loads compile-time cf to polymorphic helper functions
The helper functions require quite a few arguments, but overall I think this polymorphism approach is probably better. Let me know what you think, @newling. |
Nice! I think it makes the main function easier to follow. I have made a PR zjgarvey#1 against this which may/mayn't be a better design. |
Yeah, I can see the advantage there especially if I can move all of the helper functions to the external structure and not need to define derived classes for the conversion. I'll check this out, thanks for the prototyping @newling . |
77e6a84
to
9d45ed1
Compare
I'm going to make a few more changes right now to move the rest of the methods to the external helper. |
9d45ed1
to
9e26534
Compare
4e5753f
to
8660363
Compare
@rsuderman I just updated this PR so that it should be fine to merge without problems. Would you mind taking a look? |
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'm by no means familiar with this codebase and most of my comments are "i wonder" type comments. I would so love it if @zjgarvey could explain the thought processes behind some of the decisions. Maybe we should @ somebody more experienced to comment on it afterwards.
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.
Apologies for the delay in reviewing. This looks good to me!
@renxida do you think the comments I added in the last commit are sufficient to clear up the readability concerns you had earlier? |
The previous conversions for AtenAdaptiveAvgPool1dOp and AtenAdaptiveMaxPool2dOp are refactored into a general templated conversion that works for all of the AtenAdaptive...PoolNdOp's. New support is added for the following ops: 1. AtenAdaptiveMaxPool1d 2. AtenAdaptiveMaxPool3d 3. AtenAdaptiveAvgPool3d Support is also provided for passing inputs without batch dimensions. For example, applying adaptive_avg_pool2d to an input tensor of rank 3. After [pytorch #118162](pytorch/pytorch#118162) gets down to torch-mlir, I'll add a test for AdaptiveMaxPool1d with return_indices (which will pass with that upstream fix). --------- Co-authored-by: James Newling <[email protected]>
The previous conversions for AtenAdaptiveAvgPool1dOp and AtenAdaptiveMaxPool2dOp are refactored into a general templated conversion that works for all of the AtenAdaptive...PoolNdOp's. New support is added for the following ops: 1. AtenAdaptiveMaxPool1d 2. AtenAdaptiveMaxPool3d 3. AtenAdaptiveAvgPool3d Support is also provided for passing inputs without batch dimensions. For example, applying adaptive_avg_pool2d to an input tensor of rank 3. After [pytorch #118162](pytorch/pytorch#118162) gets down to torch-mlir, I'll add a test for AdaptiveMaxPool1d with return_indices (which will pass with that upstream fix). --------- Co-authored-by: James Newling <[email protected]>
The previous conversions for AtenAdaptiveAvgPool1dOp and AtenAdaptiveMaxPool2dOp are refactored into a general templated conversion that works for all of the AtenAdaptive...PoolNdOp's.
New support is added for the following ops:
Support is also provided for passing inputs without batch dimensions. For example, applying adaptive_avg_pool2d to an input tensor of rank 3.
After pytorch #118162 gets down to torch-mlir, I'll add a test for AdaptiveMaxPool1d with return_indices (which will pass with that upstream fix).