Skip to content

Commit 258ea24

Browse files
eigen-kfacebook-github-bot
authored andcommitted
Replace duplicated RemoveCloneOpPass with RemoveCloneOpsTransformImported (#16048)
Summary: This change eliminates code duplication by replacing the local `RemoveCloneOpPass` implementation with the imported `RemoveCloneOpsTransformImported` from the executorch transforms module. Previously, there were multiple implementations of the clone removal pass scattered across the codebase. This consolidation improves maintainability by ensuring a single source of truth for the clone removal optimization logic. Reviewed By: DrJessop Differential Revision: D88109862
1 parent d39d64b commit 258ea24

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

backends/cadence/aot/remove_ops.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
class RemoveCloneOpsTransformImported(ExportPass):
3939
def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
4040
finalize_passes: List[PassType] = [
41-
RemoveCloneOpsTransform(),
41+
RemoveCloneOpsTransform(eliminate_quant_dequant_pairs=False),
4242
]
4343
result = PassManager(passes=finalize_passes)(graph_module)
4444
dead_code_elimination_pass(result.graph_module)
@@ -356,20 +356,6 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
356356
return result
357357

358358

359-
@register_cadence_pass(CadencePassAttribute(opt_level=1))
360-
class RemoveCloneOpPass(RemoveOrReplacePassInterface):
361-
# If the op is a clone op, return the input and eliminate the op
362-
@property
363-
def targets(self) -> list[EdgeOpOverload]:
364-
return [exir_ops.edge.aten.clone.default]
365-
366-
def maybe_remove_or_replace(self, node: Node) -> bool:
367-
input_node = node.args[0]
368-
assert isinstance(input_node, Node)
369-
node.replace_all_uses_with(input_node)
370-
return True
371-
372-
373359
@register_cadence_pass(CadencePassAttribute(opt_level=1))
374360
class RemoveContiguousOpPass(RemoveOrReplacePassInterface):
375361
"""
@@ -925,7 +911,6 @@ def maybe_remove_or_replace(self, node: Node) -> bool:
925911

926912
class CommonRemovePasses:
927913
passes: List[Type[ExportPass]] = [
928-
RemoveCloneOpPass,
929914
RemoveAliasCopyOpPass,
930915
RemoveNopExpandOpPass,
931916
RemoveNopSliceOrViewOpPass,
@@ -934,13 +919,13 @@ class CommonRemovePasses:
934919
RemovePermutesAroundElementwiseOps,
935920
RemoveSqueezeViewBeforeElementwiseOps,
936921
RemoveCatFromSliceCopyPass,
922+
RemoveCloneOpsTransformImported,
937923
]
938924

939925

940926
class CadenceRemoveNops:
941927
passes: List[Type[ExportPass]] = CommonRemovePasses.passes + [
942928
SimplifySliceOpPass,
943-
RemoveCloneOpsTransformImported,
944929
RemoveNopRequantizeOpPass,
945930
RemoveZeroSizedConstantPadNd,
946931
RemoveContiguousOpPass,

0 commit comments

Comments
 (0)