Skip to content

Commit 1805ef0

Browse files
author
Github Executorch
committed
Remove legacy transform_for_cortex_m_backend and --enable_qdq_fusion_pass flag
Summary: Remove the transform_for_cortex_m_backend() function and the --enable_qdq_fusion_pass CLI flag from aot_arm_compiler.py. The function applied Cortex-M passes as a post-hoc step to all non-VGF targets, which made the compilation flow hard to follow and coupled the delegation path to Cortex-M-specific logic. Instead, ReplaceQuantNodesPass is now applied directly inside to_edge_TOSA_delegate() to handle any boundary quantized_decomposed::* nodes that remain outside the delegated subgraph. This makes the delegation path self-contained and explicit about its runtime requirements. This change is in preparation for an upcoming PR (#17075) that introduces Cortex-M as a first-class compilation target with its own dedicated pipeline, including CortexMQuantizer and CortexMPassManager.
1 parent eef30fd commit 1805ef0

1 file changed

Lines changed: 6 additions & 38 deletions

File tree

examples/arm/aot_arm_compiler.py

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838
from executorch.backends.arm.vgf import VgfCompileSpec
3939

4040
# To use Cortex-M backend
41-
from executorch.backends.cortex_m.passes.convert_to_cortex_m_pass import (
42-
ConvertToCortexMPass,
43-
)
44-
45-
from executorch.backends.cortex_m.passes.quantized_op_fusion_pass import (
46-
QuantizedOpFusionPass,
47-
)
48-
4941
from executorch.backends.cortex_m.passes.replace_quant_nodes_pass import (
5042
ReplaceQuantNodesPass,
5143
)
@@ -603,11 +595,6 @@ def get_args():
603595
action="store_false",
604596
help="Disable strict checking while exporting models.",
605597
)
606-
parser.add_argument(
607-
"--enable_qdq_fusion_pass",
608-
action="store_true",
609-
help="Enable the Quantized qdq fusion Op passes",
610-
)
611598
parser.add_argument(
612599
"--enable_debug_mode",
613600
required=False,
@@ -787,6 +774,12 @@ def to_edge_TOSA_delegate(
787774
),
788775
)
789776

777+
# Replace quantized_decomposed::* nodes with cortex_m::* equivalents for
778+
# any QDQ ops that remain outside the delegated subgraph.
779+
# Skip for targets/runtimes that do not ship Cortex-M kernels.
780+
if args.target != "vgf" and not args.direct_drive:
781+
edge = edge.transform([ReplaceQuantNodesPass()])
782+
790783
return model_quant, edge
791784

792785

@@ -825,26 +818,6 @@ def to_edge_no_delegate(
825818
return model_quant, edge
826819

827820

828-
def transform_for_cortex_m_backend(edge_program_manager, args):
829-
# Let's make sure we are using optimized Cortex M backend
830-
# NB: If we can't find and replace ops those are expected to be replaced,
831-
# bad things will happen at runtime, like "missing operator" errors!
832-
833-
# Instantiate the mandatory ReplaceQuantNodesPass
834-
passes = [ReplaceQuantNodesPass]
835-
if args.enable_qdq_fusion_pass:
836-
passes += [ConvertToCortexMPass, QuantizedOpFusionPass]
837-
current_edge = edge_program_manager
838-
for pass_cls in passes:
839-
transform_pass = (
840-
pass_cls(current_edge.exported_program())
841-
if pass_cls.__name__ == "QuantizedLinearFusionPass"
842-
else pass_cls()
843-
)
844-
current_edge = current_edge.transform([transform_pass])
845-
return current_edge
846-
847-
848821
if __name__ == "__main__": # noqa: C901
849822
args = get_args()
850823

@@ -885,11 +858,6 @@ def transform_for_cortex_m_backend(edge_program_manager, args):
885858
exported_program, args, model, example_inputs
886859
)
887860

888-
# Cortex-m ops are never included in vgf or direct-drive
889-
if args.target != "vgf" and not args.direct_drive:
890-
# Transform so we can use ops from the Cortex M backend
891-
edge = transform_for_cortex_m_backend(edge, args)
892-
893861
dump_delegation_info(edge, args.intermediates)
894862

895863
edge_program_manager_copy = copy.deepcopy(edge)

0 commit comments

Comments
 (0)