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

Extend to 1D and 3D the torch to linalg lowering of the average pool operator with count_include_pad = false #4035

Merged

Conversation

ivangarcia44
Copy link
Contributor

Currently the avg_pool2d PyTorch operation supports the cases where count_include_pad is true and false, but the avg_pool1d and avg_pool3d only the true case is supported (which is simpler).

The count_include_pad = false support for avg_pool2d was added by @AmosLewis in this change (reviewed by @rsuderman and @nirvedhmeshram) : #3235

In this change I generalized the logic added above. I also did some refactoring to the original code to reduce the size of the functions and to avoid redundancy when possible.

@sahas3 @dixinzhou @rafaelubal

@ivangarcia44
Copy link
Contributor Author

Hi @AmosLewis , @rsuderman ,

Could you please review this change when you get a chance?

The change is just to generalize the average pooling divisor computation when count_include_pad = false. This was implemented for 2 dimensions. This change makes it work for N dimensions, and does some refactoring to make the methods smaller.

Thanks,
Ivan

@ivangarcia44
Copy link
Contributor Author

Link to old PR: #4010

The review of @sahas3 can be found there.

@ivangarcia44
Copy link
Contributor Author

ivangarcia44 commented Feb 22, 2025

Including additional reviewers familiar with the Pooling.cpp file: @vivekkhandelwal1, @lingzhiz1998

In addition to @AmosLewis , @rsuderman, @sahas3, @dixinzhou, @rafaelubal

@ivangarcia44
Copy link
Contributor Author

Including @rafaelubalmw in addition to the other reviewers: @vivekkhandelwal1, @lingzhiz1998, @AmosLewis , @rsuderman, @sahas3, @dixinzhou, @rafaelubal

@ivangarcia44 ivangarcia44 changed the title Extend avg pool count include pad false to1d3d Extend avg pool count include pad false to 1d 3d cases Feb 27, 2025
@ivangarcia44 ivangarcia44 changed the title Extend avg pool count include pad false to 1d 3d cases Extend to 1D and 3D the torch to linalg lowering of the average pool operator with count include pad equal to false case Feb 27, 2025
@ivangarcia44 ivangarcia44 changed the title Extend to 1D and 3D the torch to linalg lowering of the average pool operator with count include pad equal to false case Extend to 1D and 3D the torch to linalg lowering of the average pool operator with count_include_pad = false Feb 27, 2025
@dixinzhou
Copy link
Contributor

Thanks for making the changes @ivangarcia44. The changes look good to me.

Copy link
Member

@sahas3 sahas3 left a comment

Choose a reason for hiding this comment

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

LGTM

@sahas3 sahas3 merged commit 7b23a1f into llvm:main Mar 5, 2025
3 checks passed
@ivangarcia44 ivangarcia44 deleted the extendAvgPoolCountIncludePadFalseTo1d3d branch March 5, 2025 00:22
@amd-vivekag
Copy link

amd-vivekag commented Mar 7, 2025

Hi @ivangarcia44 ,

This change is causing a testcase failure: iree-test-suites/onnx_ops/onnx/node/generated/test_averagepool_2d_ceil/
Can you please fix it?

I've created an issue for this: #4079

Thanks Vivek

@ivangarcia44
Copy link
Contributor Author

Hi @amd-vivekag ,

I will take a look at this.

Thanks,
Ivan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants