aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/cli/config.py
diff options
context:
space:
mode:
authorRaul Farkas <raul.farkas@arm.com>2022-11-29 13:29:04 +0000
committerRaul Farkas <raul.farkas@arm.com>2023-01-10 10:46:07 +0000
commit5800fc990ed1e36ce7d06670f911fbb12a0ec771 (patch)
tree294605295cd2624ba63e6ad3df335a2a4b2700ab /src/mlia/cli/config.py
parentdcd0bd31985c27e1d07333351b26cf8ad12ad1fd (diff)
downloadmlia-5800fc990ed1e36ce7d06670f911fbb12a0ec771.tar.gz
MLIA-650 Implement new CLI changes
Breaking change in the CLI and API: Sub-commands "optimization", "operators", and "performance" were replaced by "check", which incorporates compatibility and performance checks, and "optimize" which is used for optimization. "get_advice" API was adapted to these CLI changes. API changes: * Remove previous advice category "all" that would perform all three operations (when possible). Replace them with the ability to pass a set of the advice categories. * Update api.get_advice method docstring to reflect new changes. * Set default advice category to COMPATIBILITY * Update core.common.AdviceCategory by changing the "OPERATORS" advice category to "COMPATIBILITY" and removing "ALL" enum type. Update all subsequent methods that previously used "OPERATORS" to use "COMPATIBILITY". * Update core.context.ExecutionContext to have "COMPATIBILITY" as default advice_category instead of "ALL". * Remove api.generate_supported_operators_report and all related functions from cli.commands, cli.helpers, cli.main, cli.options, core.helpers * Update tests to reflect new API changes. CLI changes: * Update README.md to contain information on the new CLI * Remove the ability to generate supported operators support from MLIA CLI * Replace `mlia ops` and `mlia perf` with the new `mlia check` command that can be used to perform both operations. * Replace `mlia opt` with the new `mlia optimize` command. * Replace `--evaluate-on` flag with `--backend` flag * Replace `--verbose` flag with `--debug` flag (no behaviour change). * Remove the ability for the user to select MLIA working directory. Create and use a temporary directory in /temp instead. * Change behaviour of `--output` flag to not format the content automatically based on file extension anymore. Instead it will simply redirect to a file. * Add the `--json` flag to specfy that the format of the output should be json. * Add command validators that are used to validate inter-dependent flags (e.g. backend validation based on target_profile). * Add support for selecting built-in backends for both `check` and `optimize` commands. * Add new unit tests and update old ones to test the new CLI changes. * Update RELEASES.md * Update copyright notice Change-Id: Ia6340797c7bee3acbbd26601950e5a16ad5602db
Diffstat (limited to 'src/mlia/cli/config.py')
-rw-r--r--src/mlia/cli/config.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/mlia/cli/config.py b/src/mlia/cli/config.py
index 2d694dc..680b4b6 100644
--- a/src/mlia/cli/config.py
+++ b/src/mlia/cli/config.py
@@ -1,10 +1,13 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Environment configuration functions."""
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.install import supported_backends
@@ -14,6 +17,9 @@ from mlia.backend.tosa_checker.install import get_tosa_backend_installation
logger = logging.getLogger(__name__)
+DEFAULT_PRUNING_TARGET = 0.5
+DEFAULT_CLUSTERING_TARGET = 32
+
def get_installation_manager(noninteractive: bool = False) -> InstallationManager:
"""Return installation manager."""
@@ -26,7 +32,7 @@ def get_installation_manager(noninteractive: bool = False) -> InstallationManage
@lru_cache
def get_available_backends() -> list[str]:
"""Return list of the available backends."""
- available_backends = ["Vela"]
+ available_backends = ["Vela", "tosa-checker", "armnn-tflitedelegate"]
# Add backends using backend manager
manager = get_installation_manager()
@@ -41,9 +47,10 @@ def get_available_backends() -> list[str]:
# List of mutually exclusive Corstone backends ordered by priority
_CORSTONE_EXCLUSIVE_PRIORITY = ("Corstone-310", "Corstone-300")
+_NON_ETHOS_U_BACKENDS = ("tosa-checker", "armnn-tflitedelegate")
-def get_default_backends() -> list[str]:
+def get_ethos_u_default_backends() -> list[str]:
"""Get default backends for evaluation."""
backends = get_available_backends()
@@ -57,9 +64,34 @@ def get_default_backends() -> list[str]:
]
break
+ # Filter out non ethos-u backends
+ backends = [x for x in backends if x not in _NON_ETHOS_U_BACKENDS]
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[str, list[str]]:
+ """Return default backends for all targets."""
+ ethos_u_defaults = get_ethos_u_default_backends()
+ return {
+ "ethos-u55": ethos_u_defaults,
+ "ethos-u65": ethos_u_defaults,
+ "tosa": ["tosa-checker"],
+ "cortex-a": ["armnn-tflitedelegate"],
+ }