Skip to content

Commit e193470

Browse files
committed
Remove dependency checks from __init__ files
Backends are not separated well enough for this to work. Signed-off-by: Erik Lundell <erik.lundell@arm.com> Change-Id: Iccd75cac6e28cad20d858443908a1d39dd58527c
1 parent 32d7d51 commit e193470

2 files changed

Lines changed: 2 additions & 76 deletions

File tree

backends/arm/ethosu/__init__.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,9 @@
1-
# Copyright 2025-2026 Arm Limited and/or its affiliates.
1+
# Copyright 2025 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.
55
#
66

7-
from importlib.util import find_spec
8-
9-
10-
def _missing_dependencies_error(missing: str) -> ModuleNotFoundError:
11-
return ModuleNotFoundError(
12-
"Ethos-U backend dependencies are not installed "
13-
f"(missing: {missing}). Install ExecuTorch with "
14-
"`pip install executorch[ethos_u]`, or if building from source run "
15-
"`examples/arm/setup.sh --i-agree-to-the-contained-eula`."
16-
)
17-
18-
19-
def _ensure_ethos_u_dependencies() -> None:
20-
required_modules = {
21-
"ethosu.vela": "ethos-u-vela",
22-
"tosa_serializer": "tosa-tools",
23-
}
24-
missing_packages = []
25-
for module_name, package_name in required_modules.items():
26-
try:
27-
if find_spec(module_name) is None:
28-
missing_packages.append(package_name)
29-
except (ImportError, ValueError):
30-
missing_packages.append(package_name)
31-
32-
if missing_packages:
33-
raise _missing_dependencies_error(", ".join(missing_packages))
34-
35-
36-
_ensure_ethos_u_dependencies()
37-
387
from .backend import EthosUBackend # noqa: F401
398
from .compile_spec import EthosUCompileSpec # noqa: F401
409
from .partitioner import EthosUPartitioner # noqa: F401

backends/arm/vgf/__init__.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,9 @@
1-
# Copyright 2025-2026 Arm Limited and/or its affiliates.
1+
# Copyright 2025 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.
55
#
66

7-
from importlib.metadata import PackageNotFoundError, version
8-
from importlib.util import find_spec
9-
10-
11-
def _missing_dependencies_error(missing: str) -> ModuleNotFoundError:
12-
return ModuleNotFoundError(
13-
"VGF backend dependencies are not installed "
14-
f"(missing: {missing}). Install ExecuTorch with "
15-
"`pip install executorch[vgf]`, or if building from source run "
16-
"`examples/arm/setup.sh --i-agree-to-the-contained-eula "
17-
"--disable-ethos-u-deps --enable-mlsdk-deps`."
18-
)
19-
20-
21-
def _ensure_vgf_dependencies() -> None:
22-
required_distributions = (
23-
"ai_ml_emulation_layer_for_vulkan",
24-
"ai_ml_sdk_model_converter",
25-
"ai_ml_sdk_vgf_library",
26-
)
27-
required_modules = {
28-
"tosa_serializer": "tosa-tools",
29-
}
30-
missing_packages = []
31-
for package_name in required_distributions:
32-
try:
33-
version(package_name)
34-
except PackageNotFoundError:
35-
missing_packages.append(package_name)
36-
37-
for module_name, package_name in required_modules.items():
38-
try:
39-
if find_spec(module_name) is None:
40-
missing_packages.append(package_name)
41-
except (ImportError, ValueError):
42-
missing_packages.append(package_name)
43-
44-
if missing_packages:
45-
raise _missing_dependencies_error(", ".join(missing_packages))
46-
47-
48-
_ensure_vgf_dependencies()
49-
507
from .backend import VgfBackend # noqa: F401
518
from .compile_spec import VgfCompileSpec # noqa: F401
529
from .partitioner import VgfPartitioner # noqa: F401

0 commit comments

Comments
 (0)