Skip to content

Xnnpack: Support clone.default with skip_dim_order=True#19797

Merged
mansnils merged 1 commit into
pytorch:mainfrom
mansnils:xnnpack
May 28, 2026
Merged

Xnnpack: Support clone.default with skip_dim_order=True#19797
mansnils merged 1 commit into
pytorch:mainfrom
mansnils:xnnpack

Conversation

@mansnils

@mansnils mansnils commented May 27, 2026

Copy link
Copy Markdown
Collaborator

With the default XNNPACK test config, skip_dim_order=False rewrites aten.clone.default to dim_order_ops._clone_dim_order.default. That path is already supported through CloneDimOrderConfig.

Some XNNPACK export flows use skip_dim_order=True, where aten.clone.default stays as aten.clone.default and is not selected by the partitioner.

Adds CloneConfig for dim-order-preserving aten.clone.default nodes so this path is partitioned directly.

This reduces delegate splits in the EdgeTAM mask decoder, where profiling exports use skip_dim_order=True.

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

With the default XNNPACK test config, skip_dim_order=False rewrites
aten.clone.default to dim_order_ops._clone_dim_order.default. That
path is already supported through CloneDimOrderConfig.

Some XNNPACK export flows use skip_dim_order=True, where
aten.clone.default stays as aten.clone.default and is not selected
by the partitioner.

Adds CloneConfig for dim-order-preserving aten.clone.default nodes
so this path is partitioned directly.

This reduces delegate splits in the EdgeTAM mask decoder, where
profiling exports use skip_dim_order=True.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: Ic48ec187f26048b68a805c6edd6dad41b3dab481
@mansnils mansnils requested review from GregoryComer and Copilot May 27, 2026 09:54
@mansnils mansnils added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label May 27, 2026
@mansnils mansnils requested a review from digantdesai as a code owner May 27, 2026 09:54
@pytorch-bot

pytorch-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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, 2 Cancelled Jobs, 1 Unrelated Failure

As of commit 63fb2ae with merge base ee4c90a (image):

NEW FAILURE - The following job has failed:

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

BROKEN TRUNK - The following job 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 27, 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.

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

Adds direct XNNPACK partitioning support for dim-order-preserving aten.clone.default when Edge export is run with skip_dim_order=True, reducing delegate segmentation in flows that bypass the dim-order rewrite.

Changes:

  • Add CloneConfig to partition plain clone.default nodes when input/output dim_order matches.
  • Register CloneConfig in the XNNPACK partitioner config set.
  • Extend XNNPACK clone op serialization to explicitly define input/output tensors with quant params, and add a new test covering the skip_dim_order=True partitioning path.

Reviewed changes

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

File Description
backends/xnnpack/test/ops/test_clone.py Adds a test for skip_dim_order=True to ensure aten.clone.default is delegated (and proposes adding a negative/regression case).
backends/xnnpack/partition/config/generic_node_configs.py Introduces CloneConfig to partition dim-order-preserving clone.default.
backends/xnnpack/partition/config/init.py Exposes/registers CloneConfig in ALL_PARTITIONER_CONFIGS.
backends/xnnpack/operators/op_clone.py Updates CloneVisitor tensor definition to use QuantParams for input/output tensors.

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

Comment on lines +67 to +91
def test_fp32_clone_default_partitions_with_skip_dim_order(self):
"""Test plain aten.clone.default partitioning without dim-order rewrite."""
inputs = (torch.randn(2, 3, 4, 5),)
(
Tester(self.Clone(), inputs)
.export()
.check_count({"torch.ops.aten.clone.default": 1})
.to_edge_transform_and_lower(
ToEdgeTransformAndLower(
edge_compile_config=get_xnnpack_edge_compile_config(
skip_dim_order=True
)
)
)
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.check_not(
[
"executorch_exir_dialects_edge__ops_aten_clone_default",
"executorch_exir_dialects_edge__ops_dim_order_ops__clone_dim_order_default",
]
)
.to_executorch()
.serialize()
.run_method_and_compare_outputs()
)
@zingo zingo added the help wanted Extra attention is needed label May 27, 2026
@zingo zingo removed the help wanted Extra attention is needed label May 27, 2026
@mansnils mansnils merged commit c505aa5 into pytorch:main May 28, 2026
476 of 486 checks passed
@mansnils mansnils added the module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ 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: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants