From 44da050a1455a928e35d74986e27096b8ca5d9d6 Mon Sep 17 00:00:00 2001 From: lucylq Date: Mon, 14 Jul 2025 17:35:37 -0700 Subject: [PATCH] Remove usages of 'to_edge_with_preserve_ops' Replace with to_edge. Differential Revision: [D78311705](https://our.internmc.facebook.com/intern/diff/D78311705/) [ghstack-poisoned] --- backends/cadence/aot/compiler.py | 10 +++++----- examples/apple/coreml/llama/export.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backends/cadence/aot/compiler.py b/backends/cadence/aot/compiler.py index bfa07fc03cf..dba8ed57006 100644 --- a/backends/cadence/aot/compiler.py +++ b/backends/cadence/aot/compiler.py @@ -34,7 +34,7 @@ ) from executorch.exir.passes import ToOutVarPass from executorch.exir.passes.sym_shape_eval_pass import HintBasedSymShapeEvalPass -from executorch.exir.program._program import to_edge_with_preserved_ops +from executorch.exir.program._program import to_edge from torch._inductor.decomposition import remove_decompositions from torch.export.exported_program import ExportedProgram @@ -219,7 +219,7 @@ def quantize_pt2( torch.ops.aten.angle.default, torch.ops.aten.rms_norm.default, ] -TO_EDGE_PRESERVE_OPS: tuple[torch._ops.OpOverload, ...] = ( +TO_EDGE_PRESERVE_OPS: list[torch._ops.OpOverload, ...] = ( torch.ops.aten.rms_norm.default, ) @@ -233,18 +233,18 @@ def _lower_ep_to_edge( """ Lower an ExportedProgram to an EdgeProgramManager (in edge IR). """ - # Call to_edge_with_preserved_ops to convert the graph to edge IR. + # Call to_edge to convert the graph to edge IR. # Note: dim_order is skipped (https://github.com/pytorch/executorch/issues/3704) - edge_prog_manager = to_edge_with_preserved_ops( + edge_prog_manager = to_edge( expo_program, compile_config=EdgeCompileConfig( _skip_dim_order=True, # Allow specific non-core aten ops in the IR. _core_aten_ops_exception_list=TO_EDGE_OP_EXCEPTION_LIST + (core_aten_exceptions or []), + _preserve_ops=TO_EDGE_PRESERVE_OPS, ), constant_methods=constant_methods, - preserve_ops=TO_EDGE_PRESERVE_OPS, ) if dump_graphs: diff --git a/examples/apple/coreml/llama/export.py b/examples/apple/coreml/llama/export.py index a367a14c595..0eed4d2a97e 100644 --- a/examples/apple/coreml/llama/export.py +++ b/examples/apple/coreml/llama/export.py @@ -27,7 +27,7 @@ from executorch.exir.passes import MemoryPlanningPass from executorch.exir.passes.quant_fusion_pass import QuantFusionPass from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass -from executorch.exir.program._program import to_edge_with_preserved_ops +from executorch.exir.program._program import to_edge from executorch.extension.export_util.utils import save_pte_program @@ -196,17 +196,17 @@ def main() -> None: print("Exported program") print(ep) - edge_manager = to_edge_with_preserved_ops( + edge_manager = to_edge( ep, - preserve_ops=[ - torch.ops.aten.scaled_dot_product_attention.default, - # preserve norm op for numerical stability - torch.ops.aten.linalg_vector_norm.default, - torch.ops.aten.reciprocal.default, - ], compile_config=EdgeCompileConfig( _check_ir_validity=False, _skip_dim_order=True, + _preserve_ops=[ + torch.ops.aten.scaled_dot_product_attention.default, + # preserve norm op for numerical stability + torch.ops.aten.linalg_vector_norm.default, + torch.ops.aten.reciprocal.default, + ], ), ) print("Edge program")