Skip to content

Arm backend: Generalize fuse_view_copy_transform_pass#18285

Open
AdrianLundell wants to merge 6 commits intopytorch:mainfrom
AdrianLundell:change-1223321
Open

Arm backend: Generalize fuse_view_copy_transform_pass#18285
AdrianLundell wants to merge 6 commits intopytorch:mainfrom
AdrianLundell:change-1223321

Conversation

@AdrianLundell
Copy link
Copy Markdown
Collaborator

@AdrianLundell AdrianLundell commented Mar 18, 2026

Update the fuse_view_copy_transform_pass to check shapes rather than args to match different ways of expressing the same shape. This change makes some as_strided ops into noops which they were not previously so an additional noops check is added to fix this.

Additionally moves constants in the pass to class level to simplify overriding behavior for inheriting passes.

Note: test names as_strided_copy -> as_strided since the _copy suffix of operator names are removed in name check.

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

Update the fuse_view_copy_transform_pass to check shapes
rather than args to match differet ways of expressing the same shape.
This change makes some as_strided ops into noops which they were
not previosuly, so an addtional noops check is added to fix this.

Additionally moves constants in the pass to class level to simplify
overriding behaviour for inheriting passes.

Note: test names as_strided_copy -> as_strided since the _copy
suffix of operator names are removed in name check.

Signed-off-by: Adrian Lundell <adrian.lundell@arm.com>
Change-Id: Iba8dc3862c3fc4a8a34e036377ec7bcee84988b1
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Mar 18, 2026

🔗 Helpful Links

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

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:

❌ 2 New Failures, 3 Unrelated Failures

As of commit 60c1a8b with merge base 656850a (image):

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.

@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 Mar 18, 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.

@AdrianLundell
Copy link
Copy Markdown
Collaborator Author

@digantdesai Hi, does this look ok to you?

@AdrianLundell
Copy link
Copy Markdown
Collaborator Author

Bumping this @digantdesai @kimishpatel

@AdrianLundell
Copy link
Copy Markdown
Collaborator Author

@digantdesai This patch may also help reducing transposes in some cases since it will remove view ops which are blocking permute fusing sometimes.

Copilot AI review requested due to automatic review settings April 22, 2026 07:57
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates Arm backend view/copy fusion to treat “equivalent” reshape specifications as the same shape by comparing inferred shapes (from meta["val"]) instead of the raw shape arguments. It also tightens TOSA partition rejection logic so partitions that would lower to empty graphs due to newly-detected no-ops are not delegated.

Changes:

  • Refactors FuseViewCopyTransform to use class-level constants and removes no-op view_copy based on computed output shape.
  • Adds a partitioner no-op detector for aten.as_strided_copy (shape/stride/offset identical) to prevent delegating trivial partitions.
  • Updates as_strided-related Arm tests to reflect the new no-op behavior and renamed test functions.

Reviewed changes

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

File Description
backends/transforms/fuse_view_copy.py Makes view-copy fusion/removal compare actual inferred shapes (meta["val"].shape) and moves op lists to class attributes for override-friendly behavior.
backends/arm/tosa/partitioner.py Treats “no-op” as_strided_copy as non-compute to avoid delegating partitions that would be optimized away during lowering.
backends/arm/test/ops/test_as_strided_copy.py Adjusts test cases to avoid delegating a true no-op as_strided_copy and renames test functions accordingly.

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants