Skip to content

Commit 65ef645

Browse files
mcremon-metafacebook-github-bot
authored andcommitted
Update permute removal pass to handle binary operations, and cleanup better (#18256)
Summary: As titled. It is currently not cleaning up as much as it should, and the pass is only capable of handling single input cases. Result: from 9 to 1 (minimum by construction) permutes on Wake Gesture. Reviewed By: abeakkas Differential Revision: D96940254
1 parent 32d677d commit 65ef645

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

backends/cadence/aot/passes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from executorch.backends.cadence.aot.remove_ops import (
2626
CadenceRemoveNops,
2727
RemoveNopSliceOrViewOpPass,
28+
RemovePermutesAroundElementwiseOps,
2829
RemoveRedundantOps,
2930
)
3031
from executorch.backends.cadence.aot.reorder_ops import CadenceReorderOpsInGraph
@@ -89,6 +90,7 @@ def get_passes_in_default_order() -> list[Type[ExportPass]]:
8990
CadenceSimplifyOpsInGraph.passes,
9091
FinalizePipeline,
9192
FuseFullThenReshapePass,
93+
RemovePermutesAroundElementwiseOps,
9294
FuseTransposeOrPermuteOpPairsPass,
9395
RemoveNopSliceOrViewOpPass,
9496
CompileTimeTypeDispatchPass,

backends/cadence/aot/remove_ops.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
# Import these for the cadence function signatures.
1313
import executorch.backends.cadence.aot.ops_registrations # noqa: F401
14-
1514
import torch
1615
import torch.fx
16+
from executorch.backends.cadence.aot.fuse_ops import FuseTransposeOrPermuteOpPairsPass
1717
from executorch.backends.cadence.aot.pass_utils import (
1818
CadencePassAttribute,
1919
get_arg,
2020
register_cadence_pass,
2121
RemoveOrReplacePassInterface,
2222
set_arg,
2323
)
24-
2524
from executorch.backends.cadence.aot.simplify_ops import SimplifySliceOpPass
2625
from executorch.backends.cadence.aot.utils import get_edge_overload_packet
2726
from executorch.backends.transforms.remove_clone_ops import RemoveCloneOpsTransform
@@ -412,6 +411,9 @@ class Subgraph:
412411
exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default,
413412
exir_ops.edge.cadence.quantize_per_tensor.default,
414413
exir_ops.edge.cadence.dequantize_per_tensor.default,
414+
exir_ops.edge.cadence.quantized_relu.per_tensor,
415+
exir_ops.edge.cadence.requantize.per_tensor,
416+
exir_ops.edge.cadence.quantized_add.per_tensor,
415417
# Ops that require special handling.
416418
exir_ops.edge.aten.cat.default,
417419
exir_ops.edge.aten.mean.dim,
@@ -804,6 +806,7 @@ class CommonRemovePasses:
804806
RemoveToOpsPass,
805807
RemoveZeroSizedCatArgsPass,
806808
RemovePermutesAroundElementwiseOps,
809+
FuseTransposeOrPermuteOpPairsPass,
807810
RemoveSqueezeViewBeforeElementwiseOps,
808811
RemoveCatFromSliceCopyPass,
809812
RemoveCloneOpsTransformImported,

0 commit comments

Comments
 (0)