Skip to content

Cortex-M backend: Refactor quantized_op_fusion_pass#20179

Open
AdrianLundell wants to merge 4 commits into
pytorch:mainfrom
AdrianLundell:change-1257545
Open

Cortex-M backend: Refactor quantized_op_fusion_pass#20179
AdrianLundell wants to merge 4 commits into
pytorch:mainfrom
AdrianLundell:change-1257545

Conversation

@AdrianLundell

@AdrianLundell AdrianLundell commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Move to use the AtenToCortexMPass instead.

Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Change-Id: I00020beb4248b24f344c47a1728c06925f1b7c7a
Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Change-Id: I9f94f018d95ec58a4a12022679ddd66340344fa0
Copilot AI review requested due to automatic review settings June 10, 2026 09:42
@AdrianLundell AdrianLundell requested a review from rascani as a code owner June 10, 2026 09:42
@AdrianLundell AdrianLundell added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: none Do not include this in the release notes labels Jun 10, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 78 Pending, 4 Unrelated Failures

As of commit d107ddb with merge base 2b9e9bf (image):

NEW FAILURE - The following job has failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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 Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Cortex-M backend pass pipeline by removing the standalone QuantizedOpFusionPass and moving its operator replacement/fusion responsibilities into AtenToCortexMPass, simplifying pass management and consolidation of Cortex-M dialect substitutions.

Changes:

  • Deleted quantized_op_fusion_pass.py and removed it from imports/build rules and the Cortex-M pass list.
  • Extended AtenToCortexMPass with additional dialect substitutions for quantized add/mul/softmax/maxpool/min/max/permute/pad (and quantize/dequantize per-tensor).
  • Updated BUCK targets and __init__.py exports to reflect the refactor.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backends/cortex_m/passes/quantized_op_fusion_pass.py Removed the old ExportPass-based fusion/replacement implementation.
backends/cortex_m/passes/cortex_m_pass_manager.py Dropped QuantizedOpFusionPass from the pass list and imports.
backends/cortex_m/passes/BUCK Removed the deleted file from build sources.
backends/cortex_m/passes/aten_to_cortex_m_pass.py Added/ported substitution logic that previously lived in QuantizedOpFusionPass.
backends/cortex_m/passes/__init__.py Removed export/import of QuantizedOpFusionPass.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py
Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py
Comment on lines +1015 to +1018
del dialect_pass
input_tensor = _get_input_tensor_data(node)
if input_tensor.dtype != torch.int8:
return None
Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py
Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py

@rascani rascani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple minor nits.

Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py


@AtenToCortexMPass.register_dialect_substitution(
exir_ops.edge.quantized_decomposed.quantize_per_tensor.default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also remove the ReplaceQuantNodePass?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in aot_arm_compiler so it would be a slightly larger fix and should perhaps be treated as an API which should be deprecated properly, so maybe in another PR?

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread backends/cortex_m/passes/aten_to_cortex_m_pass.py
Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Change-Id: Ibf36386cff49fe0fc16f60b8f582d0d49e061095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants