Cortex-M: Support avg_pool2d ceil_mode lowering#21039
Open
bdemirb wants to merge 3 commits into
Open
Conversation
Cortex-M avg_pool2d quantized lowering rejected ceil_mode=True and left the graph on the fallback aten.avg_pool2d path. That preserved correctness but prevented optimized Cortex-M lowering for cases that CMSIS-NN can execute from statically known output shapes. This patch threads ceil_mode through the cortex_m::quantized_avg_pool2d schema, fake implementation, lowering, and C++ kernel wrapper. The wrapper validates the static output shape against ceil-mode pooling semantics before dispatching to CMSIS-NN. The avg_pool2d tests now cover optimized ceil_mode lowering, padded ceil_mode, count_include_pad with ceil_mode, non-square multi-channel ceil_mode, and divisor_override fallback behavior. Signed-off-by: Baris Demir <baris.demir@arm.com> Change-Id: Ib856e7cc0cc4a29ec6ede7d379b03ef7a98cb12f
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21039
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 4f88706 with merge base e8c47d7 ( BROKEN TRUNK - The following job 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
Author
|
@pytorchbot label "partner: arm" |
Collaborator
Author
|
@pytorchbot label "release notes: arm" |
rascani
reviewed
Jul 20, 2026
| count_include_pad=True, | ||
| ), | ||
| (ramp_tensor(0, 15, (1, 1, 4, 4)),), | ||
| ), |
Contributor
There was a problem hiding this comment.
Can we add a test case with kernel_size =< stride with count_include_pad & ceil_mode? I think we might wind up with the wrong output size in that case: H=5, kernel=3, stride=3, pad=1, ceil_mode=True, count_include_pad=True
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.
Cortex-M avg_pool2d quantized lowering rejected ceil_mode=True and left the graph on the fallback aten.avg_pool2d path. That preserved correctness but prevented optimized Cortex-M lowering for cases that CMSIS-NN can execute from statically known output shapes.
This patch threads ceil_mode through the cortex_m::quantized_avg_pool2d schema, fake implementation, lowering, and C++ kernel wrapper. The wrapper validates the static output shape against ceil-mode pooling semantics before dispatching to CMSIS-NN.
The avg_pool2d tests now cover optimized ceil_mode lowering, padded ceil_mode, count_include_pad with ceil_mode, non-square multi-channel ceil_mode, and divisor_override fallback behavior.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani