Skip to content

Fix various numerical issues in average pooling divisor calculation in torch to linalg lowering #4169

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

Closed

Conversation

ivangarcia44
Copy link
Contributor

@ivangarcia44 ivangarcia44 commented Apr 28, 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:

  1. Fix the condition that determines if the divisor is just the product of kernel dimensions or the clamped divisor comptutation.
  2. 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.

This PR is an improvement and replacement of this PR: #4144.

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

@ivangarcia44
Copy link
Contributor Author

Will address the merge issue in the original PR.

#4144

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.

1 participant