Skip to content

Revert "Arm backend: Populate __init__.py for quantizer and Arm root" #10395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions backends/arm/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions backends/arm/ethosu_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import logging
from typing import final, List

from executorch.backends.arm import TOSABackend

from executorch.backends.arm.arm_vela import vela_compile

from executorch.backends.arm.tosa_backend import TOSABackend
from executorch.exir.backend.backend_details import BackendDetails, PreprocessResult
from executorch.exir.backend.compile_spec_schema import CompileSpec
from torch.export.exported_program import ExportedProgram
Expand Down
3 changes: 2 additions & 1 deletion backends/arm/ethosu_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from executorch.backends.arm.arm_backend import (
is_ethosu,
) # usort: skip
from executorch.backends.arm import EthosUBackend, TOSAPartitioner
from executorch.backends.arm.ethosu_backend import EthosUBackend
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
from executorch.exir.backend.compile_spec_schema import CompileSpec
from executorch.exir.backend.partitioner import DelegationSpec
from torch.fx.passes.operator_support import OperatorSupportBase
Expand Down
10 changes: 1 addition & 9 deletions backends/arm/quantizer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Copyright 2024-2025 Arm Limited and/or its affiliates.
# Copyright 2024 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 .quantization_config import QuantizationConfig # noqa # usort: skip
from .arm_quantizer import ( # noqa
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
)
3 changes: 2 additions & 1 deletion backends/arm/quantizer/arm_quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import torch
from executorch.backends.arm._passes import ArmPassManager

from executorch.backends.arm.quantizer import arm_quantizer_utils, QuantizationConfig
from executorch.backends.arm.quantizer import arm_quantizer_utils
from executorch.backends.arm.quantizer.arm_quantizer_utils import ( # type: ignore[attr-defined]
mark_node_as_annotated,
)
from executorch.backends.arm.quantizer.quantization_annotator import ( # type: ignore[import-not-found]
annotate_graph,
)

from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
from executorch.backends.arm.tosa_specification import TosaSpecification
from executorch.backends.arm.arm_backend import (
get_tosa_spec,
Expand Down
3 changes: 2 additions & 1 deletion backends/arm/quantizer/quantization_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

import torch
import torch.fx
from executorch.backends.arm.quantizer import arm_quantizer_utils, QuantizationConfig
from executorch.backends.arm.quantizer import arm_quantizer_utils
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
from executorch.backends.arm.tosa_utils import get_node_debug_info
from torch.ao.quantization.quantizer import QuantizationSpecBase, SharedQuantizationSpec
from torch.ao.quantization.quantizer.utils import (
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_hardtanh.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_max_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest

import torch
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_permute.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_relu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Tuple

import torch
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_sigmoid_16bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

import torch
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
get_symmetric_quantization_config,
TOSAQuantizer,
)
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_sigmoid_32bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
import torch
from executorch.backends.arm.quantizer import TOSAQuantizer
from executorch.backends.arm.quantizer.arm_quantizer import TOSAQuantizer
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import unittest

import torch
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/ops/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
5 changes: 3 additions & 2 deletions backends/arm/test/tester/arm_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import torch.utils._pytree as pytree

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

from executorch.backends.arm.arm_backend import (
Expand All @@ -27,7 +26,8 @@
is_ethosu,
is_tosa,
)
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand All @@ -47,6 +47,7 @@
print_error_diffs,
)
from executorch.backends.arm.tosa_mapping import extract_tensor_meta
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner

from executorch.backends.xnnpack.test.tester import Tester
from executorch.devtools.backend_debug import get_delegation_info
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/tester/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import torch

from executorch.backends.arm.quantizer import (
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/tosa_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
get_tosa_spec,
is_tosa,
) # usort: skip
from executorch.backends.arm import TOSABackend
from executorch.backends.arm._passes.arm_pass_utils import get_first_fake_tensor
from executorch.backends.arm.operator_support.tosa_supported_operators import (
tosa_support_factory,
)
from executorch.backends.arm.tosa_backend import TOSABackend
from executorch.exir.backend.compile_spec_schema import CompileSpec
from executorch.exir.backend.partitioner import (
DelegationSpec,
Expand Down
4 changes: 3 additions & 1 deletion backends/arm/tosa_quant_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import math
from typing import cast, List, NamedTuple, Tuple

import executorch.backends.arm.tosa_mapping

import torch.fx
import torch.fx.node

Expand Down Expand Up @@ -232,7 +234,7 @@ def build_rescale(

def build_rescale_to_int32(
tosa_fb: ts.TosaSerializer,
input_arg: TosaArg,
input_arg: executorch.backends.arm.tosa_mapping.TosaArg,
input_zp: int,
rescale_scale: list[float],
is_scale32: bool = True,
Expand Down
12 changes: 7 additions & 5 deletions examples/arm/aot_arm_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@

import torch
from examples.devtools.scripts.export_bundled_program import save_bundled_program
from executorch.backends.arm import (
from executorch.backends.arm.arm_backend import (
ArmCompileSpecBuilder,
EthosUPartitioner,
TOSAPartitioner,
get_tosa_spec,
is_ethosu,
is_tosa,
)
from executorch.backends.arm.arm_backend import get_tosa_spec, is_ethosu, is_tosa
from executorch.backends.arm.quantizer import (
from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner
from executorch.backends.arm.quantizer.arm_quantizer import (
EthosUQuantizer,
get_symmetric_quantization_config,
TOSAQuantizer,
)
from executorch.backends.arm.tosa_partitioner import TOSAPartitioner
from executorch.backends.arm.tosa_specification import TosaSpecification

from executorch.backends.arm.util.arm_model_evaluator import (
Expand Down
26 changes: 13 additions & 13 deletions examples/arm/ethos_u_minimal_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"metadata": {},
"outputs": [],
"source": [
"from executorch.backends.arm import ArmCompileSpecBuilder\n",
"from executorch.backends.arm.quantizer import (\n",
"from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder\n",
"from executorch.backends.arm.quantizer.arm_quantizer import (\n",
" EthosUQuantizer,\n",
" get_symmetric_quantization_config,\n",
")\n",
Expand All @@ -89,7 +89,7 @@
"target = \"ethos-u55-128\"\n",
"\n",
"# Create a compilation spec describing the target for configuring the quantizer\n",
"# Some args are used by the Arm Vela graph compiler later in the example. Refer to Arm Vela documentation for an\n",
"# Some args are used by the Arm Vela graph compiler later in the example. Refer to Arm Vela documentation for an \n",
"# explanation of its flags: https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/blob/main/OPTIONS.md\n",
"spec_builder = ArmCompileSpecBuilder().ethosu_compile_spec(\n",
" target,\n",
Expand All @@ -100,12 +100,12 @@
"compile_spec = spec_builder.build()\n",
"\n",
"# Create and configure quantizer to use a symmetric quantization config globally on all nodes\n",
"quantizer = EthosUQuantizer(compile_spec)\n",
"quantizer = EthosUQuantizer(compile_spec) \n",
"operator_config = get_symmetric_quantization_config(is_per_channel=False)\n",
"quantizer.set_global(operator_config)\n",
"\n",
"# Post training quantization\n",
"quantized_graph_module = prepare_pt2e(graph_module, quantizer)\n",
"quantized_graph_module = prepare_pt2e(graph_module, quantizer) \n",
"quantized_graph_module(*example_inputs) # Calibrate the graph module with the example input\n",
"quantized_graph_module = convert_pt2e(quantized_graph_module)\n",
"\n",
Expand All @@ -128,8 +128,8 @@
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"import os\n",
"import subprocess \n",
"import os \n",
"\n",
"# Setup paths\n",
"cwd_dir = os.getcwd()\n",
Expand Down Expand Up @@ -163,16 +163,16 @@
"metadata": {},
"outputs": [],
"source": [
"from executorch.backends.arm import EthosUPartitioner\n",
"from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n",
"from executorch.exir import (\n",
" EdgeCompileConfig,\n",
" ExecutorchBackendConfig,\n",
" to_edge_transform_and_lower,\n",
")\n",
"from executorch.extension.export_util.utils import save_pte_program\n",
"import platform\n",
"import platform \n",
"\n",
"# Create partitioner from compile spec\n",
"# Create partitioner from compile spec \n",
"partitioner = EthosUPartitioner(compile_spec)\n",
"\n",
"# Lower the exported program to the Ethos-U backend\n",
Expand All @@ -185,8 +185,8 @@
" )\n",
"\n",
"# Load quantization ops library\n",
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\",\n",
" \"Linux\" : \"libquantized_ops_aot_lib.so\",\n",
"os_aot_lib_names = {\"Darwin\" : \"libquantized_ops_aot_lib.dylib\", \n",
" \"Linux\" : \"libquantized_ops_aot_lib.so\", \n",
" \"Windows\": \"libquantized_ops_aot_lib.dll\"}\n",
"aot_lib_name = os_aot_lib_names[platform.system()]\n",
"\n",
Expand Down Expand Up @@ -226,7 +226,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Build executorch\n",
"# Build executorch \n",
"subprocess.run(os.path.join(script_dir, \"build_executorch.sh\"), shell=True, cwd=et_dir)\n",
"\n",
"# Build portable kernels\n",
Expand Down
Loading