Skip to content

Commit 57a7903

Browse files
Cortex-M backend: Add CortexMPassManager (#14986)
Signed-off-by: Adrian Lundell <[email protected]>
1 parent 4c064e3 commit 57a7903

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
from .quantized_linear_fusion_pass import QuantizedLinearFusionPass # noqa
7+
from .quantized_op_fusion_pass import QuantizedOpFusionPass # noqa
8+
from .replace_quant_nodes_pass import ReplaceQuantNodesPass # noqa
9+
from .cortex_m_pass_manager import CortexMPassManager # noqa # usort: skip
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates.
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
7+
from executorch.backends.cortex_m.passes import (
8+
QuantizedLinearFusionPass,
9+
QuantizedOpFusionPass,
10+
ReplaceQuantNodesPass,
11+
)
12+
from executorch.backends.xnnpack._passes import XNNPACKPassManager
13+
from executorch.exir.pass_base import ExportPass
14+
15+
16+
class CortexMPassManager(XNNPACKPassManager):
17+
18+
pass_list: list[ExportPass] = [
19+
ReplaceQuantNodesPass,
20+
QuantizedOpFusionPass,
21+
QuantizedLinearFusionPass,
22+
]
23+
24+
def __init__(self, exported_program, passes=None):
25+
super().__init__(exported_program, passes or self.pass_list)

backends/cortex_m/test/tester.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@
1010
import torch
1111
from executorch.backends.arm.test.common import get_u55_compile_spec
1212
from executorch.backends.arm.test.tester.arm_tester import Serialize
13-
from executorch.backends.cortex_m.passes.quantized_linear_fusion_pass import (
14-
QuantizedLinearFusionPass,
15-
)
16-
from executorch.backends.cortex_m.passes.quantized_op_fusion_pass import (
17-
QuantizedOpFusionPass,
18-
)
19-
20-
from executorch.backends.cortex_m.passes.replace_quant_nodes_pass import (
21-
ReplaceQuantNodesPass,
22-
)
13+
from executorch.backends.cortex_m.passes.cortex_m_pass_manager import CortexMPassManager
2314
from executorch.backends.test.harness import Tester as TesterBase
2415
from executorch.backends.test.harness.stages import (
2516
Export,
@@ -29,7 +20,6 @@
2920
ToEdgeTransformAndLower,
3021
ToExecutorch,
3122
)
32-
from executorch.backends.xnnpack._passes import XNNPACKPassManager
3323

3424
from executorch.backends.xnnpack.quantizer.xnnpack_quantizer import (
3525
get_symmetric_quantization_config,
@@ -47,12 +37,8 @@ def __init__(self):
4737
class CortexMRunPasses(RunPasses):
4838
def __init__(self):
4939
super().__init__(
50-
XNNPACKPassManager,
51-
pass_list=[
52-
ReplaceQuantNodesPass,
53-
QuantizedLinearFusionPass,
54-
QuantizedOpFusionPass,
55-
],
40+
CortexMPassManager,
41+
CortexMPassManager.pass_list,
5642
)
5743

5844

0 commit comments

Comments
 (0)