Skip to content

Average pooling clamped divisor should be done on all conditions where the kernel can go out of bounds #4144

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ivangarcia44
Copy link
Contributor

@ivangarcia44 ivangarcia44 commented Apr 17, 2025

In this pull request I added various E2E tests to cover edge cases on the average pooling torch to linalg lowering algorithm. These new tests uncovered various numerical issues that were addressed in this same PR.

One of the issues is the IREE test failure found in #4079 which triggered this work.

Background:

In the most common case, the divisor for the average pooling is just the product of kernel dimensions. But with padding, and ceil mode options, some elements need to be discounted from the divisor computation. This change fixes two components of this:

Fix the condition that determines if the divisor is just the product of kernel dimensions or the clamped divisor comptutation.
Reimplement the clamped divisor computation algorithm.
The clamped divisor algorithm had various numerical issues uncovered by the new E2E tests added here. In this new version all E2E pass, the variables have more specific names, and there are comments explaining the formula.

@vivekkhandelwal1
@JianzheXiao
@AmosLewis
@rsuderman
@nirvedhmeshram)
@sahas3
@Hanumanth04
@dixinzhou
@rafaelubalmw

@ivangarcia44 ivangarcia44 marked this pull request as draft April 24, 2025 15:26
…rnel/stride/padding elements have to be processed in reversed order relative to the spatial dimensions.
@ivangarcia44 ivangarcia44 marked this pull request as ready for review April 24, 2025 17:11
@vivekkhandelwal1
Copy link
Collaborator

@ivangarcia44 This is not a good practice to close and open a new PR just because conflicts have arisen in the branch. Ideally, you should have addressed the conflicts and updated this PR just like other contributors do. At the very least, it creates confusion and makes it hard to follow the discussion on 2 different PR for the same changes.

Also, I would expect that this PR (or the new replacement of this) is not merged until a thorough review of the patch is done. The last PR had already made some changes which should not have been done, so I expect all to be more careful this time.

@ivangarcia44 ivangarcia44 reopened this Apr 29, 2025
@ivangarcia44
Copy link
Contributor Author

I will do the merge in this PR and close the new one.

@ivangarcia44 ivangarcia44 marked this pull request as ready for review April 29, 2025 21:59
@ivangarcia44
Copy link
Contributor Author

Hi all, updated the changes after merging the conflict with @vivekkhandelwal1 's changes. Please review when you get a chance. Thank you

@vivekkhandelwal1
@JianzheXiao
@AmosLewis
@rsuderman
@nirvedhmeshram)
@sahas3
@Hanumanth04
@dixinzhou
@rafaelubalmw

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.

3 participants