aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/cli/helpers.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/helpers.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/helpers.py')
-rw-r--r--src/mlia/cli/helpers.py36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mlia/cli/helpers.py b/src/mlia/cli/helpers.py
index acec837..ac64581 100644
--- a/src/mlia/cli/helpers.py
+++ b/src/mlia/cli/helpers.py
@@ -1,4 +1,4 @@
-# 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
"""Module for various helper classes."""
from __future__ import annotations
@@ -29,9 +29,9 @@ class CLIActionResolver(ActionResolver):
return [
*keras_note,
- "For example: mlia optimization --optimization-type "
- f"pruning,clustering --optimization-target 0.5,32 {model_path}",
- "For more info: mlia optimization --help",
+ f"For example: mlia optimize {model_path} --pruning --clustering "
+ "--pruning-target 0.5 --clustering-target 32",
+ "For more info: mlia optimize --help",
]
@staticmethod
@@ -41,14 +41,17 @@ class CLIActionResolver(ActionResolver):
opt_settings: list[OptimizationSettings],
) -> list[str]:
"""Return specific optimization command description."""
- opt_types = ",".join(opt.optimization_type for opt in opt_settings)
- opt_targs = ",".join(str(opt.optimization_target) for opt in opt_settings)
+ opt_types = " ".join("--" + opt.optimization_type for opt in opt_settings)
+ opt_targs_strings = ["--pruning-target", "--clustering-target"]
+ opt_targs = ",".join(
+ f"{opt_targs_strings[i]} {opt.optimization_target}"
+ for i, opt in enumerate(opt_settings)
+ )
return [
- "For more info: mlia optimization --help",
+ "For more info: mlia optimize --help",
"Optimization command: "
- f"mlia optimization --optimization-type {opt_types} "
- f"--optimization-target {opt_targs}{device_opts} {model_path}",
+ f"mlia optimize {model_path}{device_opts} {opt_types} {opt_targs}",
]
def apply_optimizations(self, **kwargs: Any) -> list[str]:
@@ -65,13 +68,6 @@ class CLIActionResolver(ActionResolver):
return []
- def supported_operators_info(self) -> list[str]:
- """Return command details for generating supported ops report."""
- return [
- "For guidance on supported operators, run: mlia operators "
- "--supported-ops-report",
- ]
-
def check_performance(self) -> list[str]:
"""Return command details for checking performance."""
model_path, device_opts = self._get_model_and_device_opts()
@@ -80,7 +76,7 @@ class CLIActionResolver(ActionResolver):
return [
"Check the estimated performance by running the following command: ",
- f"mlia performance{device_opts} {model_path}",
+ f"mlia check {model_path}{device_opts} --performance",
]
def check_operator_compatibility(self) -> list[str]:
@@ -91,16 +87,16 @@ class CLIActionResolver(ActionResolver):
return [
"Try running the following command to verify that:",
- f"mlia operators{device_opts} {model_path}",
+ f"mlia check {model_path}{device_opts}",
]
def operator_compatibility_details(self) -> list[str]:
"""Return command details for op compatibility."""
- return ["For more details, run: mlia operators --help"]
+ return ["For more details, run: mlia check --help"]
def optimization_details(self) -> list[str]:
"""Return command details for optimization."""
- return ["For more info, see: mlia optimization --help"]
+ return ["For more info, see: mlia optimize --help"]
def _get_model_and_device_opts(
self, separate_device_opts: bool = True