diff options
Diffstat (limited to 'src/mlia/cli')
-rw-r--r-- | src/mlia/cli/command_validators.py | 8 | ||||
-rw-r--r-- | src/mlia/cli/config.py | 53 | ||||
-rw-r--r-- | src/mlia/cli/main.py | 2 | ||||
-rw-r--r-- | src/mlia/cli/options.py | 8 |
4 files changed, 18 insertions, 53 deletions
diff --git a/src/mlia/cli/command_validators.py b/src/mlia/cli/command_validators.py index 8eb966b..23101e0 100644 --- a/src/mlia/cli/command_validators.py +++ b/src/mlia/cli/command_validators.py @@ -23,18 +23,12 @@ def validate_backend( compatible with each other. It assumes that prior checks where made on the validity of the target-profile. """ - target_map = { - "ethos-u55": "Ethos-U55", - "ethos-u65": "Ethos-U65", - "cortex-a": "Cortex-A", - "tosa": "TOSA", - } target = get_target(target_profile) if not backend: return get_default_backends_dict()[target] - compatible_backends = supported_backends(target_map[target]) + compatible_backends = supported_backends(target) nor_backend = list(map(normalize_string, backend)) nor_compat_backend = list(map(normalize_string, compatible_backends)) diff --git a/src/mlia/cli/config.py b/src/mlia/cli/config.py index 0dac3e8..433300c 100644 --- a/src/mlia/cli/config.py +++ b/src/mlia/cli/config.py @@ -4,16 +4,9 @@ from __future__ import annotations import logging -from functools import lru_cache -from typing import List -from typing import Optional -from typing import TypedDict -from mlia.backend.corstone.install import get_corstone_installations -from mlia.backend.manager import DefaultInstallationManager -from mlia.backend.manager import InstallationManager -from mlia.backend.registry import get_supported_backends -from mlia.backend.tosa_checker.install import get_tosa_backend_installation +from mlia.backend.manager import get_installation_manager +from mlia.target.registry import all_supported_backends logger = logging.getLogger(__name__) @@ -21,31 +14,24 @@ DEFAULT_PRUNING_TARGET = 0.5 DEFAULT_CLUSTERING_TARGET = 32 -def get_installation_manager(noninteractive: bool = False) -> InstallationManager: - """Return installation manager.""" - backends = get_corstone_installations() - backends.append(get_tosa_backend_installation()) - - return DefaultInstallationManager(backends, noninteractive=noninteractive) - - -@lru_cache def get_available_backends() -> list[str]: """Return list of the available backends.""" + available_backends = ["Vela", "ArmNNTFLiteDelegate"] + # Add backends using backend manager manager = get_installation_manager() - available_backends = [ + available_backends.extend( backend - for backend in get_supported_backends() + for backend in all_supported_backends() if manager.backend_installed(backend) - ] + ) return available_backends # List of mutually exclusive Corstone backends ordered by priority _CORSTONE_EXCLUSIVE_PRIORITY = ("Corstone-310", "Corstone-300") -_NON_ETHOS_U_BACKENDS = ("TOSA-Checker", "ArmNNTFLiteDelegate") +_NON_ETHOS_U_BACKENDS = ("tosa-checker", "ArmNNTFLiteDelegate") def get_ethos_u_default_backends(backends: list[str]) -> list[str]: @@ -70,29 +56,14 @@ def get_default_backends() -> list[str]: return backends -def is_corstone_backend(backend: str) -> bool: - """Check if the given backend is a Corstone backend.""" - return backend in _CORSTONE_EXCLUSIVE_PRIORITY - - -BackendCompatibility = TypedDict( - "BackendCompatibility", - { - "partial-match": bool, - "backends": List[str], - "default-return": Optional[List[str]], - "use-custom-return": bool, - "custom-return": Optional[List[str]], - }, -) - - def get_default_backends_dict() -> dict[str, list[str]]: """Return default backends for all targets.""" - ethos_u_defaults = get_ethos_u_default_backends(get_default_backends()) + default_backends = get_default_backends() + ethos_u_defaults = get_ethos_u_default_backends(default_backends) + return { "ethos-u55": ethos_u_defaults, "ethos-u65": ethos_u_defaults, "tosa": ["tosa-checker"], - "cortex-a": ["armnn-tflitedelegate"], + "cortex-a": ["ArmNNTFLiteDelegate"], } diff --git a/src/mlia/cli/main.py b/src/mlia/cli/main.py index 4a91b08..76f199e 100644 --- a/src/mlia/cli/main.py +++ b/src/mlia/cli/main.py @@ -74,7 +74,7 @@ def get_commands() -> list[CommandInfo]: partial(add_target_options, profiles_to_skip=["tosa", "cortex-a"]), partial( add_backend_options, - backends_to_skip=["tosa-checker", "armnn-tflitedelegate"], + backends_to_skip=["tosa-checker", "ArmNNTFLiteDelegate"], ), add_multi_optimization_options, add_output_options, diff --git a/src/mlia/cli/options.py b/src/mlia/cli/options.py index dac8c82..421533a 100644 --- a/src/mlia/cli/options.py +++ b/src/mlia/cli/options.py @@ -8,10 +8,10 @@ from pathlib import Path from typing import Any from typing import Callable +from mlia.backend.corstone import is_corstone_backend from mlia.cli.config import DEFAULT_CLUSTERING_TARGET from mlia.cli.config import DEFAULT_PRUNING_TARGET from mlia.cli.config import get_available_backends -from mlia.cli.config import is_corstone_backend from mlia.core.typing import OutputFormat from mlia.target.config import get_builtin_supported_profile_names @@ -47,12 +47,12 @@ def add_target_options( "--target-profile", required=required, default=default_target_profile, - help="Builtin target profile: {target_profiles}" - "or path to custom target profile" + help="Built-in target profile or path to the custom target profile. " + f"Built-in target profiles are {', '.join(target_profiles)}. " "Target profile that will set the target options " "such as target, mac value, memory mode, etc. " "For the values associated with each target profile " - "please refer to the documentation.", + "please refer to the documentation. ", ) |