Skip to content

Handle squeeze_copy.dims in RemovePermutesAroundElementwiseOps - #21605

Open
mcremon-meta wants to merge 1 commit into
mainfrom
export-D114508253
Open

Handle squeeze_copy.dims in RemovePermutesAroundElementwiseOps#21605
mcremon-meta wants to merge 1 commit into
mainfrom
export-D114508253

Conversation

@mcremon-meta

Copy link
Copy Markdown
Contributor

Summary:
_SQUEEZE_OPS listed only aten.squeeze_copy.dim, the singular overload. The
plural aten.squeeze_copy.dims was therefore not permutable at all, so any
candidate region containing one was rejected outright -- is_node_permutable
returns False and visit bails.

That overload is common in practice: Tensor.squeeze(dim) traces to it, so it
shows up wherever a model drops a channel or batch axis between two permuted
regions.

Adds _SQUEEZE_DIMS_OPS alongside the singular form and threads it through the
three places the singular one is handled: the permutability check, the
permutation adaptation across the rank change, and the arg rewrite in
permute_subgraph (a list remap, like update_mean_dim).

Unlike .dim, this overload can change rank by more than one and silently
keeps
any listed dim that is not size 1, which would make the rank change
data-dependent. _squeezed_dims therefore normalises the list and declines --
leaving the region unoptimised -- unless every listed position is a concrete
size-1 dim. Duplicates and symbolic shapes are also declined.

_concrete_shape is added as a small shared helper for reading a node's shape
when it may be absent (Arm graphs) or symbolic.

This pass is shared, so the Cadence (opt_level=2) and Arm/TOSA subclasses pick
this up too; their suites are covered below.

Reviewed By: aliafzal

Differential Revision: D114508253

Summary:
`_SQUEEZE_OPS` listed only `aten.squeeze_copy.dim`, the singular overload. The
plural `aten.squeeze_copy.dims` was therefore not permutable at all, so any
candidate region containing one was rejected outright -- `is_node_permutable`
returns False and `visit` bails.

That overload is common in practice: `Tensor.squeeze(dim)` traces to it, so it
shows up wherever a model drops a channel or batch axis between two permuted
regions.

Adds `_SQUEEZE_DIMS_OPS` alongside the singular form and threads it through the
three places the singular one is handled: the permutability check, the
permutation adaptation across the rank change, and the arg rewrite in
`permute_subgraph` (a list remap, like `update_mean_dim`).

Unlike `.dim`, this overload can change rank by more than one and *silently
keeps* any listed dim that is not size 1, which would make the rank change
data-dependent. `_squeezed_dims` therefore normalises the list and declines --
leaving the region unoptimised -- unless every listed position is a concrete
size-1 dim. Duplicates and symbolic shapes are also declined.

`_concrete_shape` is added as a small shared helper for reading a node's shape
when it may be absent (Arm graphs) or symbolic.

This pass is shared, so the Cadence (opt_level=2) and Arm/TOSA subclasses pick
this up too; their suites are covered below.

Reviewed By: aliafzal

Differential Revision: D114508253
@pytorch-bot

pytorch-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 1 New Failure

As of commit b48d225 with merge base bb6b99a (image):

NEW FAILURE - The following job has failed:

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 5, 2026
@meta-codesync

meta-codesync Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@mcremon-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114508253.

@github-actions

github-actions Bot commented Aug 5, 2026

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant