Skip to content

Commit 0868f6a

Browse files
committed
Move quantizer_reporter out from cortex_m.quantizer
When importing backends.cortex_m.quantizer.quantizer_reporter from backends.arm.quantizer.arm_quantizer_utils, a cyclic dependency chain is is formed. The problem is that quantizer_reporter triggers backends/cortex_m/quantizer/__init__.py when imported, which in turn has imports leading back to the Arm backend. To fix this problem, move quantizer_reporter to backends/cortex_m so it can be imported without forming any cycle. Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com> Change-Id: I757aa090d35f47bdce4d523b064217c3069adf41
1 parent e281726 commit 0868f6a

8 files changed

Lines changed: 29 additions & 22 deletions

File tree

backends/arm/quantizer/arm_quantizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from executorch.backends.cortex_m.quantizer.pattern_matcher import PatternMatcher
4141

42-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import (
42+
from executorch.backends.cortex_m.quantizer_reporter import (
4343
QuantizerReporter,
4444
SUPPORTED_QCONFIGS,
4545
SUPPORTED_QSPECS,

backends/arm/quantizer/arm_quantizer_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def __init__(
271271
self.pattern_matcher: "PatternMatcher" = pattern_matcher
272272

273273
def get_quantizer_info(self):
274-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import (
274+
from executorch.backends.cortex_m.quantizer_reporter import (
275275
QuantizerInfo,
276276
SUPPORTED_QCONFIGS,
277277
)
@@ -508,9 +508,7 @@ def __init__(self, targets: Optional[list[Callable[..., object]]] = None) -> Non
508508
)
509509

510510
def get_quantizer_info(self):
511-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import (
512-
QuantizerInfo,
513-
)
511+
from executorch.backends.cortex_m.quantizer_reporter import QuantizerInfo
514512

515513
name = self.__class__.__name__
516514
targeted_nodes_description = ""

backends/cortex_m/TARGETS

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2026 Arm Limited and/or its affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
8+
9+
oncall("executorch")
10+
11+
python_library(
12+
name = "quantizer_reporter",
13+
srcs = [
14+
"quantizer_reporter.py",
15+
],
16+
deps = [
17+
"//caffe2:torch",
18+
"//pytorch/ao:torchao",
19+
"fbsource//third-party/pypi/tabulate:tabulate",
20+
],
21+
)

backends/cortex_m/quantizer/TARGETS

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ python_library(
1717
"pattern_matcher.py",
1818
"quantization_configs.py",
1919
"quantizer.py",
20-
"quantizer_reporter.py",
2120
"quantizer_support.py",
2221
],
2322
deps = [
@@ -27,6 +26,7 @@ python_library(
2726
"//executorch/backends/arm/quantizer:arm_quantizer_utils",
2827
"//executorch/backends/arm/quantizer:quantization_annotator",
2928
"//executorch/backends/arm/quantizer:quantization_config",
29+
"//executorch/backends/cortex_m:quantizer_reporter",
3030
"//pytorch/ao:torchao",
3131
"fbsource//third-party/pypi/tabulate:tabulate",
3232
],
@@ -42,19 +42,7 @@ python_library(
4242
"//caffe2:torch",
4343
"//executorch/backends/arm/quantizer:arm_quantizer_utils",
4444
"//executorch/backends/arm/quantizer:quantization_config",
45+
"//executorch/backends/cortex_m:quantizer_reporter",
4546
"//pytorch/ao:torchao",
46-
":quantizer_reporter",
47-
],
48-
)
49-
50-
python_library(
51-
name = "quantizer_reporter",
52-
srcs = [
53-
"quantizer_reporter.py",
54-
],
55-
deps = [
56-
"//caffe2:torch",
57-
"//pytorch/ao:torchao",
58-
"fbsource//third-party/pypi/tabulate:tabulate",
5947
],
6048
)

backends/cortex_m/quantizer/quantization_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
_get_int32_per_channel_bias_qspec,
1111
)
1212
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
13-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import (
13+
from executorch.backends.cortex_m.quantizer_reporter import (
1414
SUPPORTED_QCONFIGS,
1515
SUPPORTED_QSPECS,
1616
)

backends/cortex_m/quantizer/quantizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
INT8_PER_CHANNEL_CONFIG,
2323
INT8_PER_TENSOR_CONFIG,
2424
)
25-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import QuantizerReporter
2625
from executorch.backends.cortex_m.quantizer.quantizer_support import (
2726
__name__ as cortex_m_quantizer_support_module,
2827
CONV_OP_PATTERNS,
2928
CONV_TRANSPOSE_OP_PATTERNS,
3029
CORTEX_M_QUANTIZER_SUPPORT_DICT,
3130
)
31+
from executorch.backends.cortex_m.quantizer_reporter import QuantizerReporter
3232
from torch._ops import OpOverload
3333
from torch.fx import GraphModule
3434
from torchao.quantization.pt2e.quantizer import ComposableQuantizer, Quantizer
File renamed without changes.

backends/cortex_m/test/misc/test_quantizer_reporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
INT8_WEIGHT_PER_TENSOR_QSPEC,
1212
)
1313
from executorch.backends.cortex_m.quantizer.quantizer import mark_node_as_annotated
14-
from executorch.backends.cortex_m.quantizer.quantizer_reporter import (
14+
from executorch.backends.cortex_m.quantizer_reporter import (
1515
logger as quantizer_logger,
1616
QuantizerInfo,
1717
QuantizerReport,

0 commit comments

Comments
 (0)