Repository navigation
Arm backend: Fix avg_pool2d divisor_override with ceil_mode and no padding - #24894
Open
EylonKrause wants to merge 1 commit into
Open
EylonKrause wants to merge 1 commit into
EylonKrause wants to merge 1 commit into
Conversation
…dding DecomposeAvgPool2dPass lowers avg_pool2d with a divisor_override to avg_pool2d(count_include_pad=False) on a zero padded input, followed by a multiplication by kernel_size / divisor_override. That is only exact when every window is full. _compute_post_pad returned early for padding=0, so with ceil_mode=True the last, partial window was averaged over its valid elements only. For avg_pool2d(kernel=(1, 2), stride=(1, 2), padding=0, ceil_mode=True, divisor_override=2) on [1, 2, 3, 4, 5], PyTorch gives [1.5, 3.5, 2.5] (5 / 2) and the decomposition gave [1.5, 3.5, 5.0]. Compute the post padding for ceil_mode with a divisor_override also when padding=0, and insert the pad whenever any pad value is non-zero rather than only when the symmetric pre-padding is. Test plan: Ran the decomposition on the example above, and lowered avg_pool2d configurations with ceil_mode and divisor_override through TosaPipelineFP. Added test cases to test_avg_pool2d.py. Signed-off-by: Eylon Eliyahu Krause <64223519+EylonKrause@users.noreply.github.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24894
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Awaiting Approval, 2 New Failures, 1 Pending, 4 Unrelated FailuresAs of commit e6c7ba9 with merge base 81acbc1 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
|
Collaborator
|
Thanks a lot for this PRs :) I kicked of some extended testing here also. This job also ask you for EasyCLA but you onl;y need to to it once and I think the CI will pick it up automatically if not a simple rebase will usually help, lets see. |
Author
|
/easycla |
Author
|
@pytorchbot label "release notes: arm" |
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DecomposeAvgPool2dPasslowersavg_pool2dwith adivisor_overridetoavg_pool2d(count_include_pad=False)on a zero padded input, followed by a multiplication bykernel_size / divisor_override. That is only exact when every window is full._compute_post_padreturned early forpadding=0, so withceil_mode=Truethe last, partial window was averaged over its valid elements only.Example:
avg_pool2d(kernel=(1, 2), stride=(1, 2), padding=0, ceil_mode=True, divisor_override=2)on[1, 2, 3, 4, 5]: PyTorch gives[1.5, 3.5, 2.5](5 / 2), the decomposition gave[1.5, 3.5, 5.0]. This is a silent numerical error in the lowered model.This change computes the post padding for
ceil_modewith adivisor_overridealso whenpadding=0, and inserts the pad whenever any pad value is non-zero rather than only when the symmetric pre-padding is. Behaviour only changes whenpadding=0,ceil_mode=Trueanddivisor_overrideare all set.Independent of #24893 (it touches a different function in the same file; the two branches merge cleanly).
Release notes: arm
Test plan
divisor_override_ceil_mode_no_paddinganddivisor_override_ceil_mode_no_padding_count_include_padintest_avg_pool2d.py; they fail on main in the TOSA FP and INT variants and pass with this change.test_avg_pool2d.py,test_decompose_avg_pool2d_pass.py,test_rewrite_avg_pool2d_pass.py,test_adaptive_avg_pool2d.py,test_mean_dim.py(excluding u55/u85/vgf): no new failures.ufmt checkand flake8 clean on the changed files.cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani @nil-is-all