Skip to content

Add DecomposeChannelsLastPass for the channels_last CPU fallback#20615

Merged
rascani merged 1 commit into
pytorch:mainfrom
rascani:channels-last-decompose
Jun 30, 2026
Merged

Add DecomposeChannelsLastPass for the channels_last CPU fallback#20615
rascani merged 1 commit into
pytorch:mainfrom
rascani:channels-last-decompose

Conversation

@rascani

@rascani rascani commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Provides the channels-first CPU fallback for the dialect: an ExportPass that rewrites channels_last.{convolution,avg_pool2d,permute_copy} into permute_copy + edge.aten op + permute_copy, running on the existing portable kernels with memory-planned intermediates. Intended for the graph portion that no backend claimed; backends instead replace the channels_last ops with their own channels-last kernels.

Part of #20093.

Test plan

pytest backends/transforms/test/test_decompose_channels_last_pass.py

Stacked on the channels_last dialect (pytorch#20093). Provides the channels-first CPU
fallback for the dialect: an ExportPass that rewrites
channels_last.{convolution,avg_pool2d,permute_copy} into permute_copy +
edge.aten op + permute_copy, running on the existing portable kernels with
memory-planned intermediates. Intended for the graph portion that no backend
claimed; backends instead replace the channels_last ops with their own
channels-last kernels.

This is the decomposition alternative to a C++ reference kernel: per ExecuTorch
precedent, decomposing the un-delegated remainder via a post-partition pass is
idiomatic, whereas a kernel dispatching to the portable ops (registry or
forward-declared symbols) has no in-tree precedent and needs unplanned scratch.

Part of pytorch#20093.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rascani rascani requested a review from AdrianLundell June 30, 2026 01:45
@rascani rascani requested a review from kimishpatel as a code owner June 30, 2026 01:45
@pytorch-bot

pytorch-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit a3bb536 with merge base f4a6aac (image):
💚 Looks good so far! There are no failures yet. 💚

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 30, 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.

@rascani rascani merged commit 80902f9 into pytorch:main Jun 30, 2026
185 of 187 checks passed
@rascani rascani deleted the channels-last-decompose branch June 30, 2026 15:19
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants