Repository navigation
Commit d3299a7
authored
Fuse permutes separated by views with
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: #24863CanonicalizeViewCopyPermutePass (#24863)1 parent 73a1406 commit d3299a7
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| 421 | + | |
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| |||
0 commit comments