diff options
author | Gergely Nagy <gergely.nagy@arm.com> | 2023-06-22 14:35:21 +0100 |
---|---|---|
committer | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2023-10-11 16:16:11 +0100 |
commit | baaf4de286762c1955c874f78cd802d4703a8ba5 (patch) | |
tree | 3b80f906672f91e7e24723720b2d164d360f3edf /src/mlia/target/cortex_a | |
parent | 3cd84481fa25e64c29e57396d4bf32d7a3ca490a (diff) | |
download | mlia-baaf4de286762c1955c874f78cd802d4703a8ba5.tar.gz |
Re-factoring of rewrite management & added metrics
- List available rewrites
- Refactor/rename 'Rewrite' class to 'RewritingOptimizer'
- Introduce a registry for rewrite functions
- Refactor 'Rewriter' to use the registry to look up rewrite functions
- Remove mentions of hardcoded "fully_connected" from CLI help and
error messages, using the registry instead
- Add unit tests
- Enable rewrites for all targets:
Extract optimization (including rewrite specific code) from the
Ethos-U-specific data collector into OptimizingDataCollector.
This is reused in other targets' collectors, such as TOSA
and Cortex-A.
- Add more logging for rewrite
- add display of MAE and NRMSE values for the trained result
- add total model MAE and NRMSE metric
Resolves: MLIA-891, MLIA-899, MLIA-906
Change-Id: Ie798749e1ed60cab14fdb6d9c2271c833960e93f
Signed-off-by: Benjamin Klimczak <benjamin.klimczak@arm.com>
Diffstat (limited to 'src/mlia/target/cortex_a')
-rw-r--r-- | src/mlia/target/cortex_a/advisor.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mlia/target/cortex_a/advisor.py b/src/mlia/target/cortex_a/advisor.py index db07b96..eb7720a 100644 --- a/src/mlia/target/cortex_a/advisor.py +++ b/src/mlia/target/cortex_a/advisor.py @@ -16,6 +16,8 @@ from mlia.core.context import ExecutionContext from mlia.core.data_analysis import DataAnalyzer from mlia.core.data_collection import DataCollector from mlia.core.events import Event +from mlia.target.common.optimization import add_common_optimization_params +from mlia.target.common.optimization import OptimizingDataCollector from mlia.target.cortex_a.advice_generation import CortexAAdviceProducer from mlia.target.cortex_a.config import CortexAConfiguration from mlia.target.cortex_a.data_analysis import CortexADataAnalyzer @@ -50,9 +52,7 @@ class CortexAInferenceAdvisor(DefaultInferenceAdvisor): ) if context.category_enabled(AdviceCategory.OPTIMIZATION): - raise RuntimeError( - "Model optimizations are currently not supported for Cortex-A." - ) + collectors.append(OptimizingDataCollector(model, target_config)) return collectors @@ -82,20 +82,22 @@ def configure_and_get_cortexa_advisor( context: ExecutionContext, target_profile: str | Path, model: str | Path, - **_extra_args: Any, + **extra_args: Any, ) -> InferenceAdvisor: """Create and configure Cortex-A advisor.""" if context.event_handlers is None: context.event_handlers = [CortexAEventHandler()] if context.config_parameters is None: - context.config_parameters = _get_config_parameters(model, target_profile) + context.config_parameters = _get_config_parameters( + model, target_profile, **extra_args + ) return CortexAInferenceAdvisor() def _get_config_parameters( - model: str | Path, target_profile: str | Path + model: str | Path, target_profile: str | Path, **extra_args: Any ) -> dict[str, Any]: """Get configuration parameters for the advisor.""" advisor_parameters: dict[str, Any] = { @@ -104,5 +106,5 @@ def _get_config_parameters( "target_profile": target_profile, }, } - + add_common_optimization_params(advisor_parameters, extra_args) return advisor_parameters |