Skip to content

Commit d3299a7

Browse files
authored
Fuse permutes separated by views with CanonicalizeViewCopyPermutePass (#24863)
Summary: `FuseCascadedTransposeOrPermuteOps` only fuses permutes that are adjacent, so a permute, a view and a second permute move the tensor twice. XLSR's tail is such a chain: the channels-last conv output is permuted back to NCHW, then the decomposed pixel shuffle views and permutes it again, copying the 3x1080x1920 output twice. The shared `CanonicalizeViewCopyPermutePass` (used by Arm and Cortex-M) swaps a permute with an adjacent view when the view's dimension mapping allows it, and fuses the permutes and views that become adjacent. Add it at the end of the `FusedQuantPassManager` group, and make it visible to ExecuTorch clients like its neighbors. The pass also turns a permute that only moves size-1 dims into a view. Earlier in the group, that ran before `MovePermuteAfterConcat` and `RemovePermuteBeforeMeanPass`, which only handle permutes, and left extra size-1 views in the eye tracking and DPE models. At the end of the group those passes see the permutes first, and the group's iterations still let the canonicalizer fuse what it was added for. The `iobt_v2` and `metanet_clip_small` partitioned graphs shrink: a channels-last permute, a flattening view and a transpose to tokens become one view, and the attention head reshapes need fewer permutes. Their expected graph stats are updated. Reviewed By: ethansfng Differential Revision: D131015488 Pull Request resolved: #24863
1 parent 73a1406 commit d3299a7

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎backends/transforms/targets.bzl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def define_common_targets():
418418
],
419419
visibility = [
420420
"//executorch/backends/...",
421+
"@EXECUTORCH_CLIENTS",
421422
],
422423
deps = [
423424
"//caffe2:torch",

0 commit comments

Comments
 (0)