From 4bc4d517fd0ad82fd04272ea93c84b6c15c7833c Mon Sep 17 00:00:00 2001 From: Digant Desai Date: Tue, 29 Jul 2025 04:33:41 -0700 Subject: [PATCH] Arm backend: Create ethosu directory (#12338) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/12338 Move EthosU related files to its own directory. cc digantdesai freddan80 per zingo oscarandersson8218 Differential Revision: D77349641 --- backends/arm/TARGETS | 14 ++++++++++++-- backends/arm/ethosu/__init__.py | 14 ++++++++++++++ .../arm/{ethosu_backend.py => ethosu/backend.py} | 0 .../partitioner.py} | 2 +- backends/arm/test/TARGETS | 2 +- backends/arm/test/tester/arm_tester.py | 2 +- docs/source/backends-arm-ethos-u.md | 2 +- examples/arm/aot_arm_compiler.py | 2 +- examples/arm/ethos_u_minimal_example.ipynb | 2 +- 9 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 backends/arm/ethosu/__init__.py rename backends/arm/{ethosu_backend.py => ethosu/backend.py} (100%) rename backends/arm/{ethosu_partitioner.py => ethosu/partitioner.py} (94%) diff --git a/backends/arm/TARGETS b/backends/arm/TARGETS index 8e648c56e16..810b5c09136 100644 --- a/backends/arm/TARGETS +++ b/backends/arm/TARGETS @@ -1,10 +1,20 @@ # @noautodeps load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +python_library( + name = "ethosu_partitioner", + srcs = [ + "ethosu/__init__.py", + "ethosu/backend.py", + "ethosu/partitioner.py" + ], + deps = [ + ":arm_partitioner", + ] +) python_library( name = "arm_partitioner", srcs = [ - "ethosu_backend.py", - "ethosu_partitioner.py", "tosa_backend.py", "tosa_partitioner.py", "vgf_backend.py", diff --git a/backends/arm/ethosu/__init__.py b/backends/arm/ethosu/__init__.py new file mode 100644 index 00000000000..f6cc1329dfe --- /dev/null +++ b/backends/arm/ethosu/__init__.py @@ -0,0 +1,14 @@ +# 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. +# +# pyre-unsafe + +from .backend import EthosUBackend # noqa: F401 +from .partitioner import EthosUPartitioner # noqa: F401 + +__all__ = [ + "EthosUBackend", + "EthosUPartitioner", +] diff --git a/backends/arm/ethosu_backend.py b/backends/arm/ethosu/backend.py similarity index 100% rename from backends/arm/ethosu_backend.py rename to backends/arm/ethosu/backend.py diff --git a/backends/arm/ethosu_partitioner.py b/backends/arm/ethosu/partitioner.py similarity index 94% rename from backends/arm/ethosu_partitioner.py rename to backends/arm/ethosu/partitioner.py index 27102592e15..efbd6705615 100644 --- a/backends/arm/ethosu_partitioner.py +++ b/backends/arm/ethosu/partitioner.py @@ -10,7 +10,7 @@ from executorch.backends.arm.arm_backend import ( is_ethosu, ) # usort: skip -from executorch.backends.arm.ethosu_backend import EthosUBackend +from executorch.backends.arm.ethosu 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 diff --git a/backends/arm/test/TARGETS b/backends/arm/test/TARGETS index 3c29719e1cc..9443547879d 100644 --- a/backends/arm/test/TARGETS +++ b/backends/arm/test/TARGETS @@ -41,7 +41,7 @@ python_library( deps = [ ":common", "//executorch/backends/xnnpack/test/tester:tester", - "//executorch/backends/arm:arm_partitioner", + "//executorch/backends/arm:ethosu_partitioner", "//executorch/backends/arm/quantizer:lib", "//executorch/backends/arm:tosa_mapping", "//executorch/devtools/backend_debug:delegation_info", diff --git a/backends/arm/test/tester/arm_tester.py b/backends/arm/test/tester/arm_tester.py index 60081ac8145..6ea34ca31e8 100644 --- a/backends/arm/test/tester/arm_tester.py +++ b/backends/arm/test/tester/arm_tester.py @@ -38,7 +38,7 @@ is_tosa, is_vgf, ) -from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner +from executorch.backends.arm.ethosu import EthosUPartitioner from executorch.backends.arm.quantizer import ( EthosUQuantizer, get_symmetric_quantization_config, diff --git a/docs/source/backends-arm-ethos-u.md b/docs/source/backends-arm-ethos-u.md index 4dc616f3461..71e3be105de 100644 --- a/docs/source/backends-arm-ethos-u.md +++ b/docs/source/backends-arm-ethos-u.md @@ -23,7 +23,7 @@ The example below demonstrates the lowering processs of a MobileNet V2 model fro ```python import torch from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder -from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner +from executorch.backends.arm.ethosu import EthosUPartitioner from executorch.backends.arm.quantizer.arm_quantizer import ( EthosUQuantizer, get_symmetric_quantization_config, diff --git a/examples/arm/aot_arm_compiler.py b/examples/arm/aot_arm_compiler.py index 90f86817bf3..bb329165074 100644 --- a/examples/arm/aot_arm_compiler.py +++ b/examples/arm/aot_arm_compiler.py @@ -24,7 +24,7 @@ is_tosa, is_vgf, ) -from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner +from executorch.backends.arm.ethosu import EthosUPartitioner from executorch.backends.arm.quantizer import ( EthosUQuantizer, get_symmetric_quantization_config, diff --git a/examples/arm/ethos_u_minimal_example.ipynb b/examples/arm/ethos_u_minimal_example.ipynb index 8cd4cd22959..fd9dcfdf338 100644 --- a/examples/arm/ethos_u_minimal_example.ipynb +++ b/examples/arm/ethos_u_minimal_example.ipynb @@ -138,7 +138,7 @@ "outputs": [], "source": [ "import os\n", - "from executorch.backends.arm.ethosu_partitioner import EthosUPartitioner\n", + "from executorch.backends.arm.ethosu import EthosUPartitioner\n", "from executorch.exir import (\n", " EdgeCompileConfig,\n", " ExecutorchBackendConfig,\n",