Skip to content

Commit 80fc3fc

Browse files
authored
Revert "Arm backend: Populate __init__.py for quantizer and Arm root" (#10395)
Reverts #10351
1 parent 0480fc0 commit 80fc3fc

22 files changed

+47
-57
lines changed

backends/arm/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

backends/arm/ethosu_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import logging
1515
from typing import final, List
1616

17-
from executorch.backends.arm import TOSABackend
18-
1917
from executorch.backends.arm.arm_vela import vela_compile
18+
19+
from executorch.backends.arm.tosa_backend import TOSABackend
2020
from executorch.exir.backend.backend_details import BackendDetails, PreprocessResult
2121
from executorch.exir.backend.compile_spec_schema import CompileSpec
2222
from torch.export.exported_program import ExportedProgram

backends/arm/ethosu_partitioner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from executorch.backends.arm.arm_backend import (
1111
is_ethosu,
1212
) # usort: skip
13-
from executorch.backends.arm import EthosUBackend, TOSAPartitioner
13+
from executorch.backends.arm.ethosu_backend import EthosUBackend
14+
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
1415
from executorch.exir.backend.compile_spec_schema import CompileSpec
1516
from executorch.exir.backend.partitioner import DelegationSpec
1617
from torch.fx.passes.operator_support import OperatorSupportBase

backends/arm/quantizer/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# Copyright 2024-2025 Arm Limited and/or its affiliates.
1+
# Copyright 2024 Arm Limited and/or its affiliates.
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
5-
6-
7-
from .quantization_config import QuantizationConfig # noqa # usort: skip
8-
from .arm_quantizer import ( # noqa
9-
EthosUQuantizer,
10-
get_symmetric_quantization_config,
11-
TOSAQuantizer,
12-
)

backends/arm/quantizer/arm_quantizer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import torch
2020
from executorch.backends.arm._passes import ArmPassManager
2121

22-
from executorch.backends.arm.quantizer import arm_quantizer_utils, QuantizationConfig
22+
from executorch.backends.arm.quantizer import arm_quantizer_utils
2323
from executorch.backends.arm.quantizer.arm_quantizer_utils import ( # type: ignore[attr-defined]
2424
mark_node_as_annotated,
2525
)
2626
from executorch.backends.arm.quantizer.quantization_annotator import ( # type: ignore[import-not-found]
2727
annotate_graph,
2828
)
2929

30+
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
3031
from executorch.backends.arm.tosa_specification import TosaSpecification
3132
from executorch.backends.arm.arm_backend import (
3233
get_tosa_spec,

backends/arm/quantizer/quantization_annotator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
import torch
1212
import torch.fx
13-
from executorch.backends.arm.quantizer import arm_quantizer_utils, QuantizationConfig
13+
from executorch.backends.arm.quantizer import arm_quantizer_utils
14+
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
1415
from executorch.backends.arm.tosa_utils import get_node_debug_info
1516
from torch.ao.quantization.quantizer import QuantizationSpecBase, SharedQuantizationSpec
1617
from torch.ao.quantization.quantizer.utils import (

backends/arm/test/ops/test_expand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import torch
1717

18-
from executorch.backends.arm.quantizer import (
18+
from executorch.backends.arm.quantizer.arm_quantizer import (
1919
EthosUQuantizer,
2020
get_symmetric_quantization_config,
2121
TOSAQuantizer,

backends/arm/test/ops/test_hardtanh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import torch
1515

16-
from executorch.backends.arm.quantizer import (
16+
from executorch.backends.arm.quantizer.arm_quantizer import (
1717
EthosUQuantizer,
1818
get_symmetric_quantization_config,
1919
TOSAQuantizer,

backends/arm/test/ops/test_max_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313

1414
import torch
15-
from executorch.backends.arm.quantizer import (
15+
from executorch.backends.arm.quantizer.arm_quantizer import (
1616
EthosUQuantizer,
1717
get_symmetric_quantization_config,
1818
TOSAQuantizer,

backends/arm/test/ops/test_permute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import torch
1515

16-
from executorch.backends.arm.quantizer import (
16+
from executorch.backends.arm.quantizer.arm_quantizer import (
1717
EthosUQuantizer,
1818
get_symmetric_quantization_config,
1919
TOSAQuantizer,

backends/arm/test/ops/test_relu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import Tuple
1111

1212
import torch
13-
from executorch.backends.arm.quantizer import (
13+
from executorch.backends.arm.quantizer.arm_quantizer import (
1414
EthosUQuantizer,
1515
get_symmetric_quantization_config,
1616
TOSAQuantizer,

backends/arm/test/ops/test_repeat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import torch
1515

16-
from executorch.backends.arm.quantizer import (
16+
from executorch.backends.arm.quantizer.arm_quantizer import (
1717
EthosUQuantizer,
1818
get_symmetric_quantization_config,
1919
TOSAQuantizer,

backends/arm/test/ops/test_sigmoid_16bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88
import torch
9-
from executorch.backends.arm.quantizer import (
9+
from executorch.backends.arm.quantizer.arm_quantizer import (
1010
get_symmetric_quantization_config,
1111
TOSAQuantizer,
1212
)

backends/arm/test/ops/test_sigmoid_32bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77
import torch
8-
from executorch.backends.arm.quantizer import TOSAQuantizer
8+
from executorch.backends.arm.quantizer.arm_quantizer import TOSAQuantizer
99
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
1010
from executorch.backends.arm.test import common
1111
from executorch.backends.arm.test.tester.test_pipeline import (

backends/arm/test/ops/test_var.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest
1212

1313
import torch
14-
from executorch.backends.arm.quantizer import (
14+
from executorch.backends.arm.quantizer.arm_quantizer import (
1515
EthosUQuantizer,
1616
get_symmetric_quantization_config,
1717
TOSAQuantizer,

backends/arm/test/ops/test_where.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import torch
1111

12-
from executorch.backends.arm.quantizer import (
12+
from executorch.backends.arm.quantizer.arm_quantizer import (
1313
EthosUQuantizer,
1414
get_symmetric_quantization_config,
1515
TOSAQuantizer,

backends/arm/test/tester/arm_tester.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import torch.utils._pytree as pytree
1919

2020
import tosa_tools.v0_80.serializer.tosa_serializer as ts # type: ignore[import-untyped]
21-
from executorch.backends.arm import EthosUPartitioner, TOSAPartitioner
2221
from executorch.backends.arm._passes.arm_pass_manager import ArmPassManager
2322

2423
from executorch.backends.arm.arm_backend import (
@@ -27,7 +26,8 @@
2726
is_ethosu,
2827
is_tosa,
2928
)
30-
from executorch.backends.arm.quantizer import (
29+
from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner
30+
from executorch.backends.arm.quantizer.arm_quantizer import (
3131
EthosUQuantizer,
3232
get_symmetric_quantization_config,
3333
TOSAQuantizer,
@@ -47,6 +47,7 @@
4747
print_error_diffs,
4848
)
4949
from executorch.backends.arm.tosa_mapping import extract_tensor_meta
50+
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
5051

5152
from executorch.backends.xnnpack.test.tester import Tester
5253
from executorch.devtools.backend_debug import get_delegation_info

backends/arm/test/tester/test_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import torch
1010

11-
from executorch.backends.arm.quantizer import (
11+
from executorch.backends.arm.quantizer.arm_quantizer import (
1212
EthosUQuantizer,
1313
get_symmetric_quantization_config,
1414
TOSAQuantizer,

backends/arm/tosa_partitioner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
get_tosa_spec,
1414
is_tosa,
1515
) # usort: skip
16-
from executorch.backends.arm import TOSABackend
1716
from executorch.backends.arm._passes.arm_pass_utils import get_first_fake_tensor
1817
from executorch.backends.arm.operator_support.tosa_supported_operators import (
1918
tosa_support_factory,
2019
)
20+
from executorch.backends.arm.tosa_backend import TOSABackend
2121
from executorch.exir.backend.compile_spec_schema import CompileSpec
2222
from executorch.exir.backend.partitioner import (
2323
DelegationSpec,

backends/arm/tosa_quant_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import math
1111
from typing import cast, List, NamedTuple, Tuple
1212

13+
import executorch.backends.arm.tosa_mapping
14+
1315
import torch.fx
1416
import torch.fx.node
1517

@@ -232,7 +234,7 @@ def build_rescale(
232234

233235
def build_rescale_to_int32(
234236
tosa_fb: ts.TosaSerializer,
235-
input_arg: TosaArg,
237+
input_arg: executorch.backends.arm.tosa_mapping.TosaArg,
236238
input_zp: int,
237239
rescale_scale: list[float],
238240
is_scale32: bool = True,

examples/arm/aot_arm_compiler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717

1818
import torch
1919
from examples.devtools.scripts.export_bundled_program import save_bundled_program
20-
from executorch.backends.arm import (
20+
from executorch.backends.arm.arm_backend import (
2121
ArmCompileSpecBuilder,
22-
EthosUPartitioner,
23-
TOSAPartitioner,
22+
get_tosa_spec,
23+
is_ethosu,
24+
is_tosa,
2425
)
25-
from executorch.backends.arm.arm_backend import get_tosa_spec, is_ethosu, is_tosa
26-
from executorch.backends.arm.quantizer import (
26+
from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner
27+
from executorch.backends.arm.quantizer.arm_quantizer import (
2728
EthosUQuantizer,
2829
get_symmetric_quantization_config,
2930
TOSAQuantizer,
3031
)
32+
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
3133
from executorch.backends.arm.tosa_specification import TosaSpecification
3234

3335
from executorch.backends.arm.util.arm_model_evaluator import (

examples/arm/ethos_u_minimal_example.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
"metadata": {},
8080
"outputs": [],
8181
"source": [
82-
"from executorch.backends.arm import ArmCompileSpecBuilder\n",
83-
"from executorch.backends.arm.quantizer import (\n",
82+
"from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder\n",
83+
"from executorch.backends.arm.quantizer.arm_quantizer import (\n",
8484
" EthosUQuantizer,\n",
8585
" get_symmetric_quantization_config,\n",
8686
")\n",
@@ -89,7 +89,7 @@
8989
"target = \"ethos-u55-128\"\n",
9090
"\n",
9191
"# Create a compilation spec describing the target for configuring the quantizer\n",
92-
"# Some args are used by the Arm Vela graph compiler later in the example. Refer to Arm Vela documentation for an\n",
92+
"# Some args are used by the Arm Vela graph compiler later in the example. Refer to Arm Vela documentation for an \n",
9393
"# explanation of its flags: https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/blob/main/OPTIONS.md\n",
9494
"spec_builder = ArmCompileSpecBuilder().ethosu_compile_spec(\n",
9595
" target,\n",
@@ -100,12 +100,12 @@
100100
"compile_spec = spec_builder.build()\n",
101101
"\n",
102102
"# Create and configure quantizer to use a symmetric quantization config globally on all nodes\n",
103-
"quantizer = EthosUQuantizer(compile_spec)\n",
103+
"quantizer = EthosUQuantizer(compile_spec) \n",
104104
"operator_config = get_symmetric_quantization_config(is_per_channel=False)\n",
105105
"quantizer.set_global(operator_config)\n",
106106
"\n",
107107
"# Post training quantization\n",
108-
"quantized_graph_module = prepare_pt2e(graph_module, quantizer)\n",
108+
"quantized_graph_module = prepare_pt2e(graph_module, quantizer) \n",
109109
"quantized_graph_module(*example_inputs) # Calibrate the graph module with the example input\n",
110110
"quantized_graph_module = convert_pt2e(quantized_graph_module)\n",
111111
"\n",
@@ -128,8 +128,8 @@
128128
"metadata": {},
129129
"outputs": [],
130130
"source": [
131-
"import subprocess\n",
132-
"import os\n",
131+
"import subprocess \n",
132+
"import os \n",
133133
"\n",
134134
"# Setup paths\n",
135135
"cwd_dir = os.getcwd()\n",
@@ -163,16 +163,16 @@
163163
"metadata": {},
164164
"outputs": [],
165165
"source": [
166-
"from executorch.backends.arm import EthosUPartitioner\n",
166+
"from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n",
167167
"from executorch.exir import (\n",
168168
" EdgeCompileConfig,\n",
169169
" ExecutorchBackendConfig,\n",
170170
" to_edge_transform_and_lower,\n",
171171
")\n",
172172
"from executorch.extension.export_util.utils import save_pte_program\n",
173-
"import platform\n",
173+
"import platform \n",
174174
"\n",
175-
"# Create partitioner from compile spec\n",
175+
"# Create partitioner from compile spec \n",
176176
"partitioner = EthosUPartitioner(compile_spec)\n",
177177
"\n",
178178
"# Lower the exported program to the Ethos-U backend\n",
@@ -185,8 +185,8 @@
185185
" )\n",
186186
"\n",
187187
"# Load quantization ops library\n",
188-
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\",\n",
189-
" \"Linux\" : \"libquantized_ops_aot_lib.so\",\n",
188+
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\", \n",
189+
" \"Linux\" : \"libquantized_ops_aot_lib.so\", \n",
190190
" \"Windows\": \"libquantized_ops_aot_lib.dll\"}\n",
191191
"aot_lib_name = os_aot_lib_names[platform.system()]\n",
192192
"\n",
@@ -226,7 +226,7 @@
226226
"metadata": {},
227227
"outputs": [],
228228
"source": [
229-
"# Build executorch\n",
229+
"# Build executorch \n",
230230
"subprocess.run(os.path.join(script_dir, \"build_executorch.sh\"), shell=True, cwd=et_dir)\n",
231231
"\n",
232232
"# Build portable kernels\n",

0 commit comments

Comments
 (0)