diff --git a/backends/cortex_m/passes/__init__.py b/backends/cortex_m/passes/__init__.py new file mode 100644 index 00000000000..26456138cb2 --- /dev/null +++ b/backends/cortex_m/passes/__init__.py @@ -0,0 +1,9 @@ +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +from .quantized_linear_fusion_pass import QuantizedLinearFusionPass # noqa +from .quantized_op_fusion_pass import QuantizedOpFusionPass # noqa +from .replace_quant_nodes_pass import ReplaceQuantNodesPass # noqa +from .cortex_m_pass_manager import CortexMPassManager # noqa # usort: skip diff --git a/backends/cortex_m/passes/cortex_m_pass_manager.py b/backends/cortex_m/passes/cortex_m_pass_manager.py new file mode 100644 index 00000000000..d31a0b894f6 --- /dev/null +++ b/backends/cortex_m/passes/cortex_m_pass_manager.py @@ -0,0 +1,25 @@ +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + + +from executorch.backends.cortex_m.passes import ( + QuantizedLinearFusionPass, + QuantizedOpFusionPass, + ReplaceQuantNodesPass, +) +from executorch.backends.xnnpack._passes import XNNPACKPassManager +from executorch.exir.pass_base import ExportPass + + +class CortexMPassManager(XNNPACKPassManager): + + pass_list: list[ExportPass] = [ + ReplaceQuantNodesPass, + QuantizedOpFusionPass, + QuantizedLinearFusionPass, + ] + + def __init__(self, exported_program, passes=None): + super().__init__(exported_program, passes or self.pass_list) diff --git a/backends/cortex_m/test/tester.py b/backends/cortex_m/test/tester.py index c492d3c8443..57d7a24b46d 100644 --- a/backends/cortex_m/test/tester.py +++ b/backends/cortex_m/test/tester.py @@ -10,16 +10,7 @@ import torch from executorch.backends.arm.test.common import get_u55_compile_spec from executorch.backends.arm.test.tester.arm_tester import Serialize -from executorch.backends.cortex_m.passes.quantized_linear_fusion_pass import ( - QuantizedLinearFusionPass, -) -from executorch.backends.cortex_m.passes.quantized_op_fusion_pass import ( - QuantizedOpFusionPass, -) - -from executorch.backends.cortex_m.passes.replace_quant_nodes_pass import ( - ReplaceQuantNodesPass, -) +from executorch.backends.cortex_m.passes.cortex_m_pass_manager import CortexMPassManager from executorch.backends.test.harness import Tester as TesterBase from executorch.backends.test.harness.stages import ( Export, @@ -29,7 +20,6 @@ ToEdgeTransformAndLower, ToExecutorch, ) -from executorch.backends.xnnpack._passes import XNNPACKPassManager from executorch.backends.xnnpack.quantizer.xnnpack_quantizer import ( get_symmetric_quantization_config, @@ -47,12 +37,8 @@ def __init__(self): class CortexMRunPasses(RunPasses): def __init__(self): super().__init__( - XNNPACKPassManager, - pass_list=[ - ReplaceQuantNodesPass, - QuantizedLinearFusionPass, - QuantizedOpFusionPass, - ], + CortexMPassManager, + CortexMPassManager.pass_list, )