Skip to content

Use torch.Tag.pointwise to auto-discover permutable elementwise ops (#19457)#19457

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
export-D104612850
May 13, 2026
Merged

Use torch.Tag.pointwise to auto-discover permutable elementwise ops (#19457)#19457
meta-codesync[bot] merged 1 commit into
mainfrom
export-D104612850

Conversation

@mcremon-meta
Copy link
Copy Markdown
Contributor

@mcremon-meta mcremon-meta commented May 11, 2026

Summary:

Instead of manually listing each elementwise op in RemovePermutesAroundElementwiseOps.permutable_ops, use the torch.Tag.pointwise tag to automatically accept any ATen op tagged as pointwise. This makes the pass forward-compatible with new elementwise ops added to PyTorch without requiring manual updates.

A new static method _is_pointwise(target) inspects the op's tags at runtime and is used as a fallback in both is_node_permutable and the main subgraph-discovery loop.

The explicit permutable_ops set is retained for:

  • Non-pointwise ops that need special dimension-argument handling (cat, mean, sum, slice_copy)
  • quantize_per_tensor/dequantize_per_tensor ops (not part of ATen)

Differential Revision: D104612850

@mcremon-meta mcremon-meta requested a review from kimishpatel as a code owner May 11, 2026 16:49
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 11, 2026

🔗 Helpful Links

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

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:

❌ 3 New Failures, 1 Pending, 4 Unrelated Failures

As of commit 24dc09f with merge base f1062a7 (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 May 11, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 11, 2026

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

@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.

…19457)

Summary:

Instead of manually listing each elementwise op in `RemovePermutesAroundElementwiseOps.permutable_ops`, use the `torch.Tag.pointwise` tag to automatically accept any ATen op tagged as pointwise. This makes the pass forward-compatible with new elementwise ops added to PyTorch without requiring manual updates.

A new static method `_is_pointwise(target)` inspects the op's tags at runtime and is used as a fallback in both `is_node_permutable` and the main subgraph-discovery loop.

The explicit `permutable_ops` set is retained for:
- Non-pointwise ops that need special dimension-argument handling (`cat`, `mean`, `sum`, `slice_copy`)
- `quantize_per_tensor`/`dequantize_per_tensor` ops (not part of ATen)

Differential Revision: D104612850
@meta-codesync meta-codesync Bot changed the title Use torch.Tag.pointwise to auto-discover permutable elementwise ops Use torch.Tag.pointwise to auto-discover permutable elementwise ops (#19457) May 12, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D104612850 branch from 7401610 to 24dc09f Compare May 12, 2026 15:23
@mcremon-meta
Copy link
Copy Markdown
Contributor Author

cc @AdrianLundell, I don't anticipate any required changes for Arm's flow, the pass should just be able to catch more cases!

Copy link
Copy Markdown
Collaborator

@AdrianLundell AdrianLundell left a comment

Choose a reason for hiding this comment

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

Great work! This could probably be used in the view-fusing pass as well if you feel like adding that at the same time.

@meta-codesync meta-codesync Bot merged commit a279b72 into main May 13, 2026
175 of 182 checks passed
@meta-codesync meta-codesync Bot deleted the export-D104612850 branch May 13, 2026 08:32
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants