Skip to content

Arm backend: Generalize RemovePermutesAroundElementwiseTosaOps#20238

Open
AdrianLundell wants to merge 1 commit into
pytorch:mainfrom
AdrianLundell:change-1265674
Open

Arm backend: Generalize RemovePermutesAroundElementwiseTosaOps#20238
AdrianLundell wants to merge 1 commit into
pytorch:mainfrom
AdrianLundell:change-1265674

Conversation

@AdrianLundell

@AdrianLundell AdrianLundell commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator
  • Use is_param_node for finding constant placeholders
  • Ensure ops are not modified by multiple subgraphs

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

- Use is_param_node for finding constant placeholders
- Ensure ops are not modified by multiple subgraphs

Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Change-Id: Ibb972d89c9c4125dc09bc918eae5f3fe81186cc0
Copilot AI review requested due to automatic review settings June 12, 2026 13:57
@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 12, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures, 2 Cancelled Jobs, 3 Unclassified Failures

As of commit aa30fdb with merge base d0a8dd6 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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

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 generalizes the Arm TOSA pass that removes redundant permutes around elementwise ops by improving constant-placeholder detection and preventing invalid rewrites when multiple candidate subgraphs overlap.

Changes:

  • Add a “stale subgraph” guard to skip applying rewrites when a previously-applied rewrite has already changed a candidate’s boundary edges.
  • Update RemovePermutesAroundElementwiseTosaOps to use is_param_node(exported_program, node) for identifying constant placeholders, and thread exported_program through the Arm pass pipeline.
  • Expand and update Arm backend tests to cover folded scalar constants and shared-boundary/stale-subgraph behavior; adjust transpose count expectations accordingly.

Reviewed changes

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

Show a summary per file
File Description
backends/transforms/remove_permutes_around_elementwise_ops.py Adds _subgraph_edges_are_current() and checks it before rewriting a candidate subgraph.
backends/arm/_passes/remove_permutes_around_elementwise_tosa_ops.py Requires ExportedProgram, improves constant detection via is_param_node, and keeps TABLE constant inputs from being permuted.
backends/arm/_passes/arm_pass_manager.py Wires exported_program into the RemovePermutesAroundElementwiseTosaOps pass construction.
backends/arm/test/passes/test_remove_permutes_around_elementwise_tosa_ops.py Adds new unit tests for folded scalar constants and stale shared-boundary subgraphs; updates pass construction to provide an exported program.
backends/arm/test/misc/test_transpose_counts.py Updates expected transpose count for a model affected by improved permute-removal behavior.

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

Comment on lines 22 to +27
PERMUTE_TARGET = exir_ops.edge.aten.permute_copy.default
RESCALE_TARGET = exir_ops.backend.tosa.RESCALE.default
TABLE_TARGET = exir_ops.backend.tosa.TABLE.default
MUL_TARGET = exir_ops.edge.aten.mul.Tensor
ADD_TARGET = exir_ops.edge.aten.add.Tensor
ERF_TARGET = exir_ops.edge.aten.erf.default
@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 12, 2026
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. module: arm Issues related to arm backend 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.

2 participants