diff options
author | Raul Farkas <raul.farkas@arm.com> | 2022-11-29 13:29:04 +0000 |
---|---|---|
committer | Raul Farkas <raul.farkas@arm.com> | 2023-01-10 10:46:07 +0000 |
commit | 5800fc990ed1e36ce7d06670f911fbb12a0ec771 (patch) | |
tree | 294605295cd2624ba63e6ad3df335a2a4b2700ab /tests/test_cli_helpers.py | |
parent | dcd0bd31985c27e1d07333351b26cf8ad12ad1fd (diff) | |
download | mlia-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 'tests/test_cli_helpers.py')
-rw-r--r-- | tests/test_cli_helpers.py | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/tests/test_cli_helpers.py b/tests/test_cli_helpers.py index c8aeebe..8f7e4b0 100644 --- a/tests/test_cli_helpers.py +++ b/tests/test_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 """Tests for the helper classes.""" from __future__ import annotations @@ -28,40 +28,39 @@ class TestCliActionResolver: {}, [ "Note: you will need a Keras model for that.", - "For example: mlia optimization --optimization-type " - "pruning,clustering --optimization-target 0.5,32 " - "/path/to/keras_model", - "For more info: mlia optimization --help", + "For example: mlia optimize /path/to/keras_model " + "--pruning --clustering " + "--pruning-target 0.5 --clustering-target 32", + "For more info: mlia optimize --help", ], ], [ {"model": "model.h5"}, {}, [ - "For example: mlia optimization --optimization-type " - "pruning,clustering --optimization-target 0.5,32 model.h5", - "For more info: mlia optimization --help", + "For example: mlia optimize model.h5 --pruning --clustering " + "--pruning-target 0.5 --clustering-target 32", + "For more info: mlia optimize --help", ], ], [ {"model": "model.h5"}, {"opt_settings": [OptimizationSettings("pruning", 0.5, None)]}, [ - "For more info: mlia optimization --help", + "For more info: mlia optimize --help", "Optimization command: " - "mlia optimization --optimization-type pruning " - "--optimization-target 0.5 model.h5", + "mlia optimize model.h5 --pruning " + "--pruning-target 0.5", ], ], [ {"model": "model.h5", "target_profile": "target_profile"}, {"opt_settings": [OptimizationSettings("pruning", 0.5, None)]}, [ - "For more info: mlia optimization --help", + "For more info: mlia optimize --help", "Optimization command: " - "mlia optimization --optimization-type pruning " - "--optimization-target 0.5 " - "--target-profile target_profile model.h5", + "mlia optimize model.h5 --target-profile target_profile " + "--pruning --pruning-target 0.5", ], ], ], @@ -76,20 +75,11 @@ class TestCliActionResolver: assert resolver.apply_optimizations(**params) == expected_result @staticmethod - def test_supported_operators_info() -> None: - """Test supported operators info.""" - resolver = CLIActionResolver({}) - assert resolver.supported_operators_info() == [ - "For guidance on supported operators, run: mlia operators " - "--supported-ops-report", - ] - - @staticmethod def test_operator_compatibility_details() -> None: """Test operator compatibility details info.""" resolver = CLIActionResolver({}) assert resolver.operator_compatibility_details() == [ - "For more details, run: mlia operators --help" + "For more details, run: mlia check --help" ] @staticmethod @@ -97,7 +87,7 @@ class TestCliActionResolver: """Test optimization details info.""" resolver = CLIActionResolver({}) assert resolver.optimization_details() == [ - "For more info, see: mlia optimization --help" + "For more info, see: mlia optimize --help" ] @staticmethod @@ -109,19 +99,12 @@ class TestCliActionResolver: [], ], [ - {"model": "model.tflite"}, - [ - "Check the estimated performance by running the " - "following command: ", - "mlia performance model.tflite", - ], - ], - [ {"model": "model.tflite", "target_profile": "target_profile"}, [ "Check the estimated performance by running the " "following command: ", - "mlia performance --target-profile target_profile model.tflite", + "mlia check model.tflite " + "--target-profile target_profile --performance", ], ], ], @@ -142,17 +125,10 @@ class TestCliActionResolver: [], ], [ - {"model": "model.tflite"}, - [ - "Try running the following command to verify that:", - "mlia operators model.tflite", - ], - ], - [ {"model": "model.tflite", "target_profile": "target_profile"}, [ "Try running the following command to verify that:", - "mlia operators --target-profile target_profile model.tflite", + "mlia check model.tflite --target-profile target_profile", ], ], ], |