Skip to content

Cortex-M: keep the activation on a max pool that will not lower - #22232

Open
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:cortex-m-pool-activation-fallback
Open

Cortex-M: keep the activation on a max pool that will not lower#22232
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:cortex-m-pool-activation-fallback

Conversation

@rascani

@rascani rascani commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

ActivationFusionPass folds a following relu, hardtanh or clamp into its producer by narrowing that producer's quantized output range and erasing the activation node. CortexMMaxPool2DCheck annotates a pool it cannot lower before tagging it, so such a pool still carries qparams and reads as a fusion target. It then falls back to the portable kernel, which reads no range, and the activation is gone: relu(max_pool2d(dilation=2)) over randn(1, 4, 8, 8) * 20 came out unclamped, 19.8 away from the reference at its worst element.

Nothing caught it because the op counts look right either way -- the activation is supposed to disappear -- and no test paired a pool with one.

Authored with Claude Code.

ActivationFusionPass folds a following relu, hardtanh or clamp into its producer
by narrowing that producer's quantized output range and erasing the activation
node. CortexMMaxPool2DCheck annotates a pool it cannot lower before tagging it,
so such a pool still carries qparams and reads as a fusion target. It then falls
back to the portable kernel, which reads no range, and the activation is gone:
relu(max_pool2d(dilation=2)) over randn(1, 4, 8, 8) * 20 came out unclamped,
19.8 away from the reference at its worst element.

Nothing caught it because the op counts look right either way -- the activation
is supposed to disappear -- and no test paired a pool with one.

Authored with Claude Code.
@pytorch-bot

pytorch-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22232

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 27, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant