diff --git a/backends/cadence/aot/replace_ops.py b/backends/cadence/aot/replace_ops.py index 34a1abdf0b1..358ec1d6a4b 100644 --- a/backends/cadence/aot/replace_ops.py +++ b/backends/cadence/aot/replace_ops.py @@ -283,31 +283,6 @@ def call_operator(self, op, args, kwargs, meta): return super().call_operator(op, args, kwargs, meta) -@register_cadence_pass(CadencePassAttribute(opt_level=0)) -class ReplaceTCopyWithTransposePass(ExportPass): - """ - Replace t_copy with transpose_copy.int. If the input is 1D, the t_copy is - a nop. t_copy is not supported, so this is an opt_level=0 pass. - """ - - def call_operator(self, op, args, kwargs, meta): - if get_edge_overload_packet(op) != exir_ops.edge.aten.t_copy: - return super().call_operator(op, args, kwargs, meta) - - # Get the input tensor shape - in_tensor = args[0].to_tensor() if isinstance(args[0], ProxyValue) else args[0] - - # If the input is a 1D tensor, this t_copy is a nop, so return the input - if in_tensor.dim() <= 1: - return args[0] - - assert in_tensor.dim() == 2, "t_copy expects a tensor with <= 2 dimensions" - transpose_args = (args[0], 0, 1) - return super().call_operator( - exir_ops.edge.aten.transpose_copy.int, transpose_args, kwargs, meta - ) - - @register_cadence_pass(CadencePassAttribute(opt_level=0)) class ReplaceMMWithAddMMPass(ExportPass): """ @@ -2407,7 +2382,6 @@ class CadenceReplaceOpsInGraph: passes = [ ReplaceEmptyTensorsWithFullPass, ReplaceFunctionallyEquivalentOpTargets, - ReplaceTCopyWithTransposePass, ReplacePermuteWithTransposePass, ReplaceScalarWithTensorArgPass, ReplaceConvolutionOptionalArgsWithConcreteArgsPass, diff --git a/backends/cadence/aot/tests/test_replace_ops_passes.py b/backends/cadence/aot/tests/test_replace_ops_passes.py index 85077db93ca..e7bf8e9cefa 100644 --- a/backends/cadence/aot/tests/test_replace_ops_passes.py +++ b/backends/cadence/aot/tests/test_replace_ops_passes.py @@ -48,7 +48,6 @@ ReplaceSingleElementTensorArgumentsFromFullOpWithScalarPass, ReplaceSplitWithSlicePass, ReplaceSqueezeAndUnsqueezeWithViewPass, - ReplaceTCopyWithTransposePass, ReplaceTransposedConvWithLinearPass, ReplaceTrivialConvWithLinear, ReplaceWhereWithFullArgsWithWhereScalar, @@ -368,37 +367,6 @@ def forward(self, x: torch.Tensor): 0, ) - @parameterized.expand( - [ - [(16, 32)], - [(1, 240)], - [(4, 16)], - ] - ) - @torch.no_grad() - def test_replace_t_copy_with_transpose(self, shape: Tuple[int]): - class TCopy(torch.nn.Module): - def forward(self, x: torch.Tensor): - return exir_ops.edge.aten.t_copy(x) - - w = torch.randn(shape) - inputs = (w,) - p1 = ReplaceTCopyWithTransposePass() - p2 = ReplacePermuteWithTransposePass() - model = TCopy() - graph_module = export_to_edge(model, inputs).exported_program().graph_module - graph_after_passes = cast( - PassResult, p2(cast(PassResult, p1(graph_module)).graph_module) - ).graph_module - self.assertEqual( - count_node(graph_after_passes, exir_ops.edge.aten.transpose_copy.int), - 1, - ) - self.assertEqual( - count_node(graph_after_passes, exir_ops.edge.aten.t_copy), - 0, - ) - @parameterized.expand( [ [(1, 8, 33), 8, 16, 3],