aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2023-02-08 16:00:34 +0000
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2023-02-10 13:45:18 +0000
commitfa1fad9332e2912f12a44a1b07716ee434174308 (patch)
tree246dfdb4ec9c495faaa55d73e061bcb4f8171d98
parent7a661257b6adad0c8f53e32b42ced56a1e7d952f (diff)
downloadmlia-fa1fad9332e2912f12a44a1b07716ee434174308.tar.gz
MLIA-769 Replace use of 'device' with 'target'
Term 'device' can be ambiguous and is replaced with 'target'. Change-Id: I5e5108d033a13b98e4c2997713e1c32bce63ae62
-rw-r--r--src/mlia/backend/vela/compiler.py4
-rw-r--r--src/mlia/backend/vela/performance.py4
-rw-r--r--src/mlia/cli/commands.py2
-rw-r--r--src/mlia/cli/helpers.py30
-rw-r--r--src/mlia/cli/options.py8
-rw-r--r--src/mlia/core/data_collection.py4
-rw-r--r--src/mlia/target/cortex_a/events.py4
-rw-r--r--src/mlia/target/cortex_a/handlers.py2
-rw-r--r--src/mlia/target/cortex_a/reporters.py14
-rw-r--r--src/mlia/target/ethos_u/advisor.py18
-rw-r--r--src/mlia/target/ethos_u/config.py2
-rw-r--r--src/mlia/target/ethos_u/data_collection.py20
-rw-r--r--src/mlia/target/ethos_u/events.py4
-rw-r--r--src/mlia/target/ethos_u/handlers.py2
-rw-r--r--src/mlia/target/ethos_u/performance.py34
-rw-r--r--src/mlia/target/ethos_u/reporters.py18
-rw-r--r--src/mlia/target/tosa/events.py2
-rw-r--r--src/mlia/target/tosa/handlers.py2
-rw-r--r--src/mlia/target/tosa/reporters.py12
-rw-r--r--tests/test_backend_vela_compat.py4
-rw-r--r--tests/test_backend_vela_compiler.py4
-rw-r--r--tests/test_backend_vela_performance.py18
-rw-r--r--tests/test_target_cortex_a_reporters.py8
-rw-r--r--tests/test_target_ethos_u_config.py4
-rw-r--r--tests/test_target_ethos_u_data_collection.py26
-rw-r--r--tests/test_target_ethos_u_reporters.py14
-rw-r--r--tests/test_target_tosa_reporters.py8
27 files changed, 136 insertions, 136 deletions
diff --git a/src/mlia/backend/vela/compiler.py b/src/mlia/backend/vela/compiler.py
index b62df24..afad05b 100644
--- a/src/mlia/backend/vela/compiler.py
+++ b/src/mlia/backend/vela/compiler.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
"""Vela compiler wrapper module."""
from __future__ import annotations
@@ -268,7 +268,7 @@ def optimize_model(
) -> None:
"""Optimize model and return it's path after optimization."""
logger.debug(
- "Optimize model %s for device %s",
+ "Optimize model %s for target %s",
model_path,
compiler_options.accelerator_config,
)
diff --git a/src/mlia/backend/vela/performance.py b/src/mlia/backend/vela/performance.py
index ccd2f6f..e545b85 100644
--- a/src/mlia/backend/vela/performance.py
+++ b/src/mlia/backend/vela/performance.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
"""Vela performance module."""
from __future__ import annotations
@@ -42,7 +42,7 @@ class PerformanceMetrics: # pylint: disable=too-many-instance-attributes
def estimate_performance(
model_path: Path, compiler_options: VelaCompilerOptions
) -> PerformanceMetrics:
- """Return performance estimations for the model/device.
+ """Return performance estimations for the model/target.
Logic for this function comes from Vela module stats_writer.py
"""
diff --git a/src/mlia/cli/commands.py b/src/mlia/cli/commands.py
index 27f5b2b..f0ba519 100644
--- a/src/mlia/cli/commands.py
+++ b/src/mlia/cli/commands.py
@@ -48,7 +48,7 @@ def check(
comprehensive report/advice:
- converts the input Keras model into TensorFlow Lite format
- - checks the model for operator compatibility on the specified device
+ - checks the model for operator compatibility on the specified target
- generates a final report on the steps above
- provides advice on how to (possibly) improve the inference performance
diff --git a/src/mlia/cli/helpers.py b/src/mlia/cli/helpers.py
index 576670b..abc6df0 100644
--- a/src/mlia/cli/helpers.py
+++ b/src/mlia/cli/helpers.py
@@ -42,7 +42,7 @@ class CLIActionResolver(ActionResolver):
@staticmethod
def _specific_optimization_command(
model_path: str,
- device_opts: str,
+ target_opts: str,
opt_settings: list[OptimizationSettings],
) -> list[str]:
"""Return specific optimization command description."""
@@ -56,43 +56,43 @@ class CLIActionResolver(ActionResolver):
return [
"For more info: mlia optimize --help",
"Optimization command: "
- f"mlia optimize {model_path}{device_opts} {opt_types} {opt_targs}",
+ f"mlia optimize {model_path}{target_opts} {opt_types} {opt_targs}",
]
def apply_optimizations(self, **kwargs: Any) -> list[str]:
"""Return command details for applying optimizations."""
- model_path, device_opts = self._get_model_and_device_opts()
+ model_path, target_opts = self._get_model_and_target_opts()
if (opt_settings := kwargs.pop("opt_settings", None)) is None:
return self._general_optimization_command(model_path)
if is_list_of(opt_settings, OptimizationSettings) and model_path:
return self._specific_optimization_command(
- model_path, device_opts, opt_settings
+ model_path, target_opts, opt_settings
)
return []
def check_performance(self) -> list[str]:
"""Return command details for checking performance."""
- model_path, device_opts = self._get_model_and_device_opts()
+ model_path, target_opts = self._get_model_and_target_opts()
if not model_path:
return []
return [
"Check the estimated performance by running the following command: ",
- f"mlia check {model_path}{device_opts} --performance",
+ f"mlia check {model_path}{target_opts} --performance",
]
def check_operator_compatibility(self) -> list[str]:
"""Return command details for op compatibility."""
- model_path, device_opts = self._get_model_and_device_opts()
+ model_path, target_opts = self._get_model_and_target_opts()
if not model_path:
return []
return [
"Try running the following command to verify that:",
- f"mlia check {model_path}{device_opts}",
+ f"mlia check {model_path}{target_opts}",
]
def operator_compatibility_details(self) -> list[str]:
@@ -103,16 +103,16 @@ class CLIActionResolver(ActionResolver):
"""Return command details for optimization."""
return ["For more info, see: mlia optimize --help"]
- def _get_model_and_device_opts(
- self, separate_device_opts: bool = True
+ def _get_model_and_target_opts(
+ self, separate_target_opts: bool = True
) -> tuple[str | None, str]:
- """Get model and device options."""
- device_opts = " ".join(get_target_profile_opts(self.args))
- if separate_device_opts and device_opts:
- device_opts = f" {device_opts}"
+ """Get model and target options."""
+ target_opts = " ".join(get_target_profile_opts(self.args))
+ if separate_target_opts and target_opts:
+ target_opts = f" {target_opts}"
model_path = self.args.get("model")
- return model_path, device_opts
+ return model_path, target_opts
def copy_profile_file_to_output_dir(
diff --git a/src/mlia/cli/options.py b/src/mlia/cli/options.py
index 8cd2935..b16f77f 100644
--- a/src/mlia/cli/options.py
+++ b/src/mlia/cli/options.py
@@ -282,9 +282,9 @@ def parse_optimization_parameters(
return optimizer_params
-def get_target_profile_opts(device_args: dict | None) -> list[str]:
+def get_target_profile_opts(target_args: dict | None) -> list[str]:
"""Get non default values passed as parameters for the target profile."""
- if not device_args:
+ if not target_args:
return []
parser = argparse.ArgumentParser()
@@ -298,7 +298,7 @@ def get_target_profile_opts(device_args: dict | None) -> list[str]:
non_default = [
arg_name
- for arg_name, arg_value in device_args.items()
+ for arg_name, arg_value in target_args.items()
if arg_name in args and vars(args)[arg_name] != arg_value
]
@@ -312,7 +312,7 @@ def get_target_profile_opts(device_args: dict | None) -> list[str]:
return [
item
for name in non_default
- for item in construct_param(params_name[name], device_args[name])
+ for item in construct_param(params_name[name], target_args[name])
]
diff --git a/src/mlia/core/data_collection.py b/src/mlia/core/data_collection.py
index 43b6d1c..24b6542 100644
--- a/src/mlia/core/data_collection.py
+++ b/src/mlia/core/data_collection.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 data collection.
@@ -20,7 +20,7 @@ class DataCollector(NamedEntity):
generation.
Different implementations of this class can provide various
- information about model or device. This information is being used
+ information about model or target. This information is being used
at later stages.
"""
diff --git a/src/mlia/target/cortex_a/events.py b/src/mlia/target/cortex_a/events.py
index a172d0d..76f17ba 100644
--- a/src/mlia/target/cortex_a/events.py
+++ b/src/mlia/target/cortex_a/events.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
"""Cortex-A MLIA module events."""
from dataclasses import dataclass
@@ -14,7 +14,7 @@ class CortexAAdvisorStartedEvent(Event):
"""Event with Cortex-A advisor parameters."""
model: Path
- device: CortexAConfiguration
+ target: CortexAConfiguration
class CortexAAdvisorEventHandler(EventDispatcher):
diff --git a/src/mlia/target/cortex_a/handlers.py b/src/mlia/target/cortex_a/handlers.py
index 1a74da7..d46197c 100644
--- a/src/mlia/target/cortex_a/handlers.py
+++ b/src/mlia/target/cortex_a/handlers.py
@@ -35,4 +35,4 @@ class CortexAEventHandler(WorkflowEventsHandler, CortexAAdvisorEventHandler):
def on_cortex_a_advisor_started(self, event: CortexAAdvisorStartedEvent) -> None:
"""Handle CortexAAdvisorStarted event."""
- self.reporter.submit(event.device)
+ self.reporter.submit(event.target)
diff --git a/src/mlia/target/cortex_a/reporters.py b/src/mlia/target/cortex_a/reporters.py
index d43d6c3..e23bf4d 100644
--- a/src/mlia/target/cortex_a/reporters.py
+++ b/src/mlia/target/cortex_a/reporters.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
"""Reports module."""
from __future__ import annotations
@@ -23,13 +23,13 @@ from mlia.utils.console import style_improvement
from mlia.utils.types import is_list_of
-def report_device(device: CortexAConfiguration) -> Report:
- """Generate report for the device."""
+def report_target(target: CortexAConfiguration) -> Report:
+ """Generate report for the target."""
return NestedReport(
- "Device information",
- "device",
+ "Target information",
+ "target",
[
- ReportItem("Target", alias="target", value=device.target),
+ ReportItem("Target", alias="target", value=target.target),
],
)
@@ -129,7 +129,7 @@ def cortex_a_formatters(data: Any) -> Callable[[Any], Report]:
return report_advice
if isinstance(data, CortexAConfiguration):
- return report_device
+ return report_target
if isinstance(data, TFLiteCompatibilityInfo):
return report_tflite_compatiblity
diff --git a/src/mlia/target/ethos_u/advisor.py b/src/mlia/target/ethos_u/advisor.py
index 5f23fdd..b34d1e0 100644
--- a/src/mlia/target/ethos_u/advisor.py
+++ b/src/mlia/target/ethos_u/advisor.py
@@ -41,13 +41,13 @@ class EthosUInferenceAdvisor(DefaultInferenceAdvisor):
def get_collectors(self, context: Context) -> list[DataCollector]:
"""Return list of the data collectors."""
model = self.get_model(context)
- device = self._get_device_cfg(context)
+ target = self._get_target_cfg(context)
backends = self._get_backends(context)
collectors: list[DataCollector] = []
if context.category_enabled(AdviceCategory.COMPATIBILITY):
- collectors.append(EthosUOperatorCompatibility(model, device))
+ collectors.append(EthosUOperatorCompatibility(model, target))
# Performance and optimization are mutually exclusive.
# Decide which one to use (taking into account the model format).
@@ -58,18 +58,18 @@ class EthosUInferenceAdvisor(DefaultInferenceAdvisor):
"Command 'optimization' is not supported for TensorFlow Lite files."
)
if context.category_enabled(AdviceCategory.PERFORMANCE):
- collectors.append(EthosUPerformance(model, device, backends))
+ collectors.append(EthosUPerformance(model, target, backends))
else:
# Keras/SavedModel: Prefer optimization
if context.category_enabled(AdviceCategory.OPTIMIZATION):
optimization_settings = self._get_optimization_settings(context)
collectors.append(
EthosUOptimizationPerformance(
- model, device, optimization_settings, backends
+ model, target, optimization_settings, backends
)
)
elif context.category_enabled(AdviceCategory.PERFORMANCE):
- collectors.append(EthosUPerformance(model, device, backends))
+ collectors.append(EthosUPerformance(model, target, backends))
return collectors
@@ -89,14 +89,14 @@ class EthosUInferenceAdvisor(DefaultInferenceAdvisor):
def get_events(self, context: Context) -> list[Event]:
"""Return list of the startup events."""
model = self.get_model(context)
- device = self._get_device_cfg(context)
+ target = self._get_target_cfg(context)
return [
- EthosUAdvisorStartedEvent(device=device, model=model),
+ EthosUAdvisorStartedEvent(target=target, model=model),
]
- def _get_device_cfg(self, context: Context) -> EthosUConfiguration:
- """Get device configuration."""
+ def _get_target_cfg(self, context: Context) -> EthosUConfiguration:
+ """Get target configuration."""
target_profile = self.get_target_profile(context)
return cast(EthosUConfiguration, profile(target_profile))
diff --git a/src/mlia/target/ethos_u/config.py b/src/mlia/target/ethos_u/config.py
index d1a2c7a..73baa61 100644
--- a/src/mlia/target/ethos_u/config.py
+++ b/src/mlia/target/ethos_u/config.py
@@ -49,7 +49,7 @@ class EthosUConfiguration(TargetProfile):
target_mac_range = target_mac_ranges[self.target]
if self.mac not in target_mac_range:
raise ValueError(
- f"Mac value for selected device should be in {target_mac_range}."
+ f"Mac value for selected target should be in {target_mac_range}."
)
@property
diff --git a/src/mlia/target/ethos_u/data_collection.py b/src/mlia/target/ethos_u/data_collection.py
index 258876d..96fe240 100644
--- a/src/mlia/target/ethos_u/data_collection.py
+++ b/src/mlia/target/ethos_u/data_collection.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
"""Data collection module for Ethos-U."""
from __future__ import annotations
@@ -31,10 +31,10 @@ logger = logging.getLogger(__name__)
class EthosUOperatorCompatibility(ContextAwareDataCollector):
"""Collect operator compatibility information."""
- def __init__(self, model: Path, device: EthosUConfiguration) -> None:
+ def __init__(self, model: Path, target: EthosUConfiguration) -> None:
"""Init operator compatibility data collector."""
self.model = model
- self.device = device
+ self.target = target
def collect_data(self) -> Operators:
"""Collect operator compatibility information."""
@@ -42,7 +42,7 @@ class EthosUOperatorCompatibility(ContextAwareDataCollector):
with log_action("Checking operator compatibility ..."):
return supported_operators(
- Path(tflite_model.model_path), self.device.compiler_options
+ Path(tflite_model.model_path), self.target.compiler_options
)
@classmethod
@@ -57,12 +57,12 @@ class EthosUPerformance(ContextAwareDataCollector):
def __init__(
self,
model: Path,
- device: EthosUConfiguration,
+ target: EthosUConfiguration,
backends: list[str] | None = None,
) -> None:
"""Init performance data collector."""
self.model = model
- self.device = device
+ self.target = target
self.backends = backends
def collect_data(self) -> PerformanceMetrics:
@@ -70,7 +70,7 @@ class EthosUPerformance(ContextAwareDataCollector):
tflite_model = get_tflite_model(self.model, self.context)
estimator = EthosUPerformanceEstimator(
self.context,
- self.device,
+ self.target,
self.backends,
)
@@ -113,13 +113,13 @@ class EthosUOptimizationPerformance(ContextAwareDataCollector):
def __init__(
self,
model: Path,
- device: EthosUConfiguration,
+ target: EthosUConfiguration,
optimizations: list[list[dict]],
backends: list[str] | None = None,
) -> None:
"""Init performance optimizations data collector."""
self.model = model
- self.device = device
+ self.target = target
self.optimizations = optimizations
self.backends = backends
@@ -148,7 +148,7 @@ class EthosUOptimizationPerformance(ContextAwareDataCollector):
estimator = EthosUPerformanceEstimator(
self.context,
- self.device,
+ self.target,
self.backends,
)
original_metrics, *optimized_metrics = estimate_performance(
diff --git a/src/mlia/target/ethos_u/events.py b/src/mlia/target/ethos_u/events.py
index 37cc1a9..8060382 100644
--- a/src/mlia/target/ethos_u/events.py
+++ b/src/mlia/target/ethos_u/events.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
"""Ethos-U MLIA module events."""
from dataclasses import dataclass
@@ -14,7 +14,7 @@ class EthosUAdvisorStartedEvent(Event):
"""Event with Ethos-U advisor parameters."""
model: Path
- device: EthosUConfiguration
+ target: EthosUConfiguration
class EthosUAdvisorEventHandler(EventDispatcher):
diff --git a/src/mlia/target/ethos_u/handlers.py b/src/mlia/target/ethos_u/handlers.py
index 9873014..c9d0dc7 100644
--- a/src/mlia/target/ethos_u/handlers.py
+++ b/src/mlia/target/ethos_u/handlers.py
@@ -51,4 +51,4 @@ class EthosUEventHandler(WorkflowEventsHandler, EthosUAdvisorEventHandler):
def on_ethos_u_advisor_started(self, event: EthosUAdvisorStartedEvent) -> None:
"""Handle EthosUAdvisorStarted event."""
- self.reporter.submit(event.device)
+ self.reporter.submit(event.target)
diff --git a/src/mlia/target/ethos_u/performance.py b/src/mlia/target/ethos_u/performance.py
index be1a287..5bcafab 100644
--- a/src/mlia/target/ethos_u/performance.py
+++ b/src/mlia/target/ethos_u/performance.py
@@ -92,17 +92,17 @@ class MemoryUsage:
class PerformanceMetrics:
"""Performance metrics."""
- device: EthosUConfiguration
+ target: EthosUConfiguration
npu_cycles: NPUCycles | None
memory_usage: MemoryUsage | None
def in_kilobytes(self) -> PerformanceMetrics:
"""Return metrics with memory usage in KiB."""
if self.memory_usage is None:
- return PerformanceMetrics(self.device, self.npu_cycles, self.memory_usage)
+ return PerformanceMetrics(self.target, self.npu_cycles, self.memory_usage)
return PerformanceMetrics(
- self.device, self.npu_cycles, self.memory_usage.in_kilobytes()
+ self.target, self.npu_cycles, self.memory_usage.in_kilobytes()
)
@@ -121,10 +121,10 @@ class VelaPerformanceEstimator(
):
"""Vela based performance estimator."""
- def __init__(self, context: Context, device: EthosUConfiguration) -> None:
+ def __init__(self, context: Context, target: EthosUConfiguration) -> None:
"""Init Vela based performance estimator."""
self.context = context
- self.device = device
+ self.target = target
def estimate(self, model: Path | ModelConfiguration) -> MemoryUsage:
"""Estimate performance."""
@@ -136,7 +136,7 @@ class VelaPerformanceEstimator(
)
vela_perf_metrics = vela_perf.estimate_performance(
- model_path, self.device.compiler_options
+ model_path, self.target.compiler_options
)
return MemoryUsage(
@@ -154,11 +154,11 @@ class CorstonePerformanceEstimator(
"""Corstone-based performance estimator."""
def __init__(
- self, context: Context, device: EthosUConfiguration, backend: str
+ self, context: Context, target: EthosUConfiguration, backend: str
) -> None:
"""Init Corstone-based performance estimator."""
self.context = context
- self.device = device
+ self.target = target
self.backend = backend
def estimate(self, model: Path | ModelConfiguration) -> NPUCycles:
@@ -180,12 +180,12 @@ class CorstonePerformanceEstimator(
)
vela_comp.optimize_model(
- model_path, self.device.compiler_options, optimized_model_path
+ model_path, self.target.compiler_options, optimized_model_path
)
corstone_perf_metrics = estimate_performance(
- self.device.target,
- self.device.mac,
+ self.target.target,
+ self.target.mac,
optimized_model_path,
self.backend,
)
@@ -208,15 +208,15 @@ class EthosUPerformanceEstimator(
def __init__(
self,
context: Context,
- device: EthosUConfiguration,
+ target: EthosUConfiguration,
backends: list[str] | None = None,
) -> None:
"""Init performance estimator."""
self.context = context
- self.device = device
+ self.target = target
if backends is None:
backends = ["Vela"] # Only Vela is always available as default
- ethos_u_backends = supported_backends(device.target)
+ ethos_u_backends = supported_backends(target.target)
for backend in backends:
if backend != "Vela" and backend not in ethos_u_backends:
raise ValueError(
@@ -238,11 +238,11 @@ class EthosUPerformanceEstimator(
npu_cycles = None
for backend in self.backends:
if backend == "Vela":
- vela_estimator = VelaPerformanceEstimator(self.context, self.device)
+ vela_estimator = VelaPerformanceEstimator(self.context, self.target)
memory_usage = vela_estimator.estimate(tflite_model)
elif is_corstone_backend(backend):
corstone_estimator = CorstonePerformanceEstimator(
- self.context, self.device, backend
+ self.context, self.target, backend
)
npu_cycles = corstone_estimator.estimate(tflite_model)
else:
@@ -252,4 +252,4 @@ class EthosUPerformanceEstimator(
backend,
)
- return PerformanceMetrics(self.device, npu_cycles, memory_usage)
+ return PerformanceMetrics(self.target, npu_cycles, memory_usage)
diff --git a/src/mlia/target/ethos_u/reporters.py b/src/mlia/target/ethos_u/reporters.py
index dbc6f4a..4de60bb 100644
--- a/src/mlia/target/ethos_u/reporters.py
+++ b/src/mlia/target/ethos_u/reporters.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
"""Reports module."""
from __future__ import annotations
@@ -110,9 +110,9 @@ def report_operators(ops: list[Operator]) -> Report:
return Table(columns, rows, name="Operators", alias="operators")
-def report_device_details(device: EthosUConfiguration) -> Report:
- """Return table representation for the device."""
- compiler_config = device.resolved_compiler_config
+def report_target_details(target: EthosUConfiguration) -> Report:
+ """Return table representation for the target."""
+ compiler_config = target.resolved_compiler_config
memory_settings = [
ReportItem(
@@ -208,11 +208,11 @@ def report_device_details(device: EthosUConfiguration) -> Report:
]
return NestedReport(
- "Device information",
- "device",
+ "Target information",
+ "target",
[
- ReportItem("Target", alias="target", value=device.target),
- ReportItem("MAC", alias="mac", value=device.mac),
+ ReportItem("Target", alias="target", value=target.target),
+ ReportItem("MAC", alias="mac", value=target.mac),
ReportItem(
"Memory mode",
alias="memory_mode",
@@ -376,7 +376,7 @@ def ethos_u_formatters(data: Any) -> Callable[[Any], Report]:
return report_operators_stat
if isinstance(data, EthosUConfiguration):
- return report_device_details
+ return report_target_details
if isinstance(data, (list, tuple)):
formatters = [ethos_u_formatters(item) for item in data]
diff --git a/src/mlia/target/tosa/events.py b/src/mlia/target/tosa/events.py
index cbfd199..06a05af 100644
--- a/src/mlia/target/tosa/events.py
+++ b/src/mlia/target/tosa/events.py
@@ -17,7 +17,7 @@ class TOSAAdvisorStartedEvent(Event):
"""Event with TOSA advisor parameters."""
model: Path
- device: TOSAConfiguration
+ target: TOSAConfiguration
tosa_metadata: MetadataDisplay | None
diff --git a/src/mlia/target/tosa/handlers.py b/src/mlia/target/tosa/handlers.py
index f222823..131afa7 100644
--- a/src/mlia/target/tosa/handlers.py
+++ b/src/mlia/target/tosa/handlers.py
@@ -25,7 +25,7 @@ class TOSAEventHandler(WorkflowEventsHandler, TOSAAdvisorEventHandler):
def on_tosa_advisor_started(self, event: TOSAAdvisorStartedEvent) -> None:
"""Handle TOSAAdvisorStartedEvent event."""
- self.reporter.submit(event.device)
+ self.reporter.submit(event.target)
self.reporter.submit(event.tosa_metadata)
def on_collected_data(self, event: CollectedDataEvent) -> None:
diff --git a/src/mlia/target/tosa/reporters.py b/src/mlia/target/tosa/reporters.py
index 283f61f..5c015ff 100644
--- a/src/mlia/target/tosa/reporters.py
+++ b/src/mlia/target/tosa/reporters.py
@@ -42,13 +42,13 @@ class MetadataDisplay: # pylint: disable=too-few-public-methods
self.model_name = model_meta.model_name
-def report_device(device: TOSAConfiguration) -> Report:
- """Generate report for the device."""
+def report_target(target: TOSAConfiguration) -> Report:
+ """Generate report for the target."""
return NestedReport(
- "Device information",
- "device",
+ "Target information",
+ "target",
[
- ReportItem("Target", alias="target", value=device.target),
+ ReportItem("Target", alias="target", value=target.target),
],
)
@@ -160,7 +160,7 @@ def tosa_formatters(data: Any) -> Callable[[Any], Report]:
return report_advice
if isinstance(data, TOSAConfiguration):
- return report_device
+ return report_target
if isinstance(data, MetadataDisplay):
return report_metadata
diff --git a/tests/test_backend_vela_compat.py b/tests/test_backend_vela_compat.py
index 4653d7d..4e0f149 100644
--- a/tests/test_backend_vela_compat.py
+++ b/tests/test_backend_vela_compat.py
@@ -55,9 +55,9 @@ from mlia.utils.filesystem import working_directory
)
def test_operators(test_models_path: Path, model: str, expected_ops: Operators) -> None:
"""Test operators function."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
- operators = supported_operators(test_models_path / model, device.compiler_options)
+ operators = supported_operators(test_models_path / model, target.compiler_options)
for expected, actual in zip(expected_ops.ops, operators.ops):
# do not compare names as they could be different on each model generation
assert expected.op_type == actual.op_type
diff --git a/tests/test_backend_vela_compiler.py b/tests/test_backend_vela_compiler.py
index 2d937ea..0434ccf 100644
--- a/tests/test_backend_vela_compiler.py
+++ b/tests/test_backend_vela_compiler.py
@@ -158,8 +158,8 @@ def test_optimize_model(tmp_path: Path, test_tflite_model: Path) -> None:
"""Test model optimization and saving into file."""
tmp_file = tmp_path / "temp.tflite"
- device = EthosUConfiguration.load_profile("ethos-u55-256")
- optimize_model(test_tflite_model, device.compiler_options, tmp_file.absolute())
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
+ optimize_model(test_tflite_model, target.compiler_options, tmp_file.absolute())
assert tmp_file.is_file()
assert tmp_file.stat().st_size > 0
diff --git a/tests/test_backend_vela_performance.py b/tests/test_backend_vela_performance.py
index 569de61..68b96ab 100644
--- a/tests/test_backend_vela_performance.py
+++ b/tests/test_backend_vela_performance.py
@@ -14,8 +14,8 @@ from mlia.target.ethos_u.config import EthosUConfiguration
def test_estimate_performance(test_tflite_model: Path) -> None:
"""Test getting performance estimations."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
- perf_metrics = estimate_performance(test_tflite_model, device.compiler_options)
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
+ perf_metrics = estimate_performance(test_tflite_model, target.compiler_options)
assert isinstance(perf_metrics, PerformanceMetrics)
@@ -24,16 +24,16 @@ def test_estimate_performance_already_optimized(
tmp_path: Path, test_tflite_model: Path
) -> None:
"""Test that performance estimation should fail for already optimized model."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
optimized_model_path = tmp_path / "optimized_model.tflite"
- optimize_model(test_tflite_model, device.compiler_options, optimized_model_path)
+ optimize_model(test_tflite_model, target.compiler_options, optimized_model_path)
with pytest.raises(
Exception, match="Unable to estimate performance for the given optimized model"
):
- estimate_performance(optimized_model_path, device.compiler_options)
+ estimate_performance(optimized_model_path, target.compiler_options)
def test_read_invalid_model(test_tflite_invalid_model: Path) -> None:
@@ -41,8 +41,8 @@ def test_read_invalid_model(test_tflite_invalid_model: Path) -> None:
with pytest.raises(
Exception, match=f"Unable to read model {test_tflite_invalid_model}"
):
- device = EthosUConfiguration.load_profile("ethos-u55-256")
- estimate_performance(test_tflite_invalid_model, device.compiler_options)
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
+ estimate_performance(test_tflite_invalid_model, target.compiler_options)
def test_compile_invalid_model(
@@ -58,7 +58,7 @@ def test_compile_invalid_model(
with pytest.raises(
Exception, match="Model could not be optimized with Vela compiler"
):
- device = EthosUConfiguration.load_profile("ethos-u55-256")
- optimize_model(test_tflite_model, device.compiler_options, model_path)
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
+ optimize_model(test_tflite_model, target.compiler_options, model_path)
assert not model_path.exists()
diff --git a/tests/test_target_cortex_a_reporters.py b/tests/test_target_cortex_a_reporters.py
index c32ef7b..6866396 100644
--- a/tests/test_target_cortex_a_reporters.py
+++ b/tests/test_target_cortex_a_reporters.py
@@ -13,12 +13,12 @@ from mlia.nn.tensorflow.tflite_graph import TFL_ACTIVATION_FUNCTION
from mlia.target.cortex_a.config import CortexAConfiguration
from mlia.target.cortex_a.operators import Operator
from mlia.target.cortex_a.reporters import cortex_a_formatters
-from mlia.target.cortex_a.reporters import report_device
+from mlia.target.cortex_a.reporters import report_target
-def test_report_device() -> None:
- """Test function report_device()."""
- report = report_device(CortexAConfiguration.load_profile("cortex-a"))
+def test_report_target() -> None:
+ """Test function report_target()."""
+ report = report_target(CortexAConfiguration.load_profile("cortex-a"))
assert report.to_plain_text()
diff --git a/tests/test_target_ethos_u_config.py b/tests/test_target_ethos_u_config.py
index 7f13b26..49e7a40 100644
--- a/tests/test_target_ethos_u_config.py
+++ b/tests/test_target_ethos_u_config.py
@@ -63,7 +63,7 @@ def test_ethosu_target() -> None:
},
pytest.raises(
Exception,
- match=r"Mac value for selected device should be in \[256, 512\]",
+ match=r"Mac value for selected target should be in \[256, 512\]",
),
],
[
@@ -75,7 +75,7 @@ def test_ethosu_target() -> None:
},
pytest.raises(
Exception,
- match="Mac value for selected device should be "
+ match="Mac value for selected target should be "
r"in \[32, 64, 128, 256\]",
),
],
diff --git a/tests/test_target_ethos_u_data_collection.py b/tests/test_target_ethos_u_data_collection.py
index 829d2a7..fd824ae 100644
--- a/tests/test_target_ethos_u_data_collection.py
+++ b/tests/test_target_ethos_u_data_collection.py
@@ -50,9 +50,9 @@ def test_operator_compatibility_collector(
sample_context: Context, test_tflite_model: Path
) -> None:
"""Test operator compatibility data collector."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
- collector = EthosUOperatorCompatibility(test_tflite_model, device)
+ collector = EthosUOperatorCompatibility(test_tflite_model, target)
collector.set_context(sample_context)
result = collector.collect_data()
@@ -63,11 +63,11 @@ def test_performance_collector(
monkeypatch: pytest.MonkeyPatch, sample_context: Context, test_tflite_model: Path
) -> None:
"""Test performance data collector."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
- mock_performance_estimation(monkeypatch, device)
+ mock_performance_estimation(monkeypatch, target)
- collector = EthosUPerformance(test_tflite_model, device)
+ collector = EthosUPerformance(test_tflite_model, target)
collector.set_context(sample_context)
result = collector.collect_data()
@@ -81,12 +81,12 @@ def test_optimization_performance_collector(
test_tflite_model: Path,
) -> None:
"""Test optimization performance data collector."""
- device = EthosUConfiguration.load_profile("ethos-u55-256")
+ target = EthosUConfiguration.load_profile("ethos-u55-256")
- mock_performance_estimation(monkeypatch, device)
+ mock_performance_estimation(monkeypatch, target)
collector = EthosUOptimizationPerformance(
test_keras_model,
- device,
+ target,
[
[
{"optimization_type": "pruning", "optimization_target": 0.5},
@@ -107,7 +107,7 @@ def test_optimization_performance_collector(
collector_no_optimizations = EthosUOptimizationPerformance(
test_keras_model,
- device,
+ target,
[],
)
with pytest.raises(FunctionalityNotSupportedError):
@@ -115,7 +115,7 @@ def test_optimization_performance_collector(
collector_tflite = EthosUOptimizationPerformance(
test_tflite_model,
- device,
+ target,
[
[
{"optimization_type": "pruning", "optimization_target": 0.5},
@@ -130,18 +130,18 @@ def test_optimization_performance_collector(
Exception, match="Optimization parameters expected to be a list"
):
collector_bad_config = EthosUOptimizationPerformance(
- test_keras_model, device, {"optimization_type": "pruning"} # type: ignore
+ test_keras_model, target, {"optimization_type": "pruning"} # type: ignore
)
collector.set_context(sample_context)
collector_bad_config.collect_data()
def mock_performance_estimation(
- monkeypatch: pytest.MonkeyPatch, device: EthosUConfiguration
+ monkeypatch: pytest.MonkeyPatch, target: EthosUConfiguration
) -> None:
"""Mock performance estimation."""
metrics = PerformanceMetrics(
- device,
+ target,
NPUCycles(1, 2, 3, 4, 5, 6),
MemoryUsage(1, 2, 3, 4, 5),
)
diff --git a/tests/test_target_ethos_u_reporters.py b/tests/test_target_ethos_u_reporters.py
index 9707dff..b8014e4 100644
--- a/tests/test_target_ethos_u_reporters.py
+++ b/tests/test_target_ethos_u_reporters.py
@@ -12,8 +12,8 @@ from mlia.backend.vela.compat import Operator
from mlia.core.reporting import Report
from mlia.core.reporting import Table
from mlia.target.ethos_u.config import EthosUConfiguration
-from mlia.target.ethos_u.reporters import report_device_details
from mlia.target.ethos_u.reporters import report_operators
+from mlia.target.ethos_u.reporters import report_target_details
from mlia.target.registry import profile
from mlia.utils.console import remove_ascii_codes
@@ -118,11 +118,11 @@ def test_report_operators(
@pytest.mark.parametrize(
- "device, expected_plain_text, expected_json_dict",
+ "target, expected_plain_text, expected_json_dict",
[
[
cast(EthosUConfiguration, profile("ethos-u55-256")),
- """Device information:
+ """Target information:
Target ethos-u55
MAC 256
@@ -167,7 +167,7 @@ def test_report_operators(
Feature map storage mem area Sram
Fast storage mem area Sram""",
{
- "device": {
+ "target": {
"target": "ethos-u55",
"mac": 256,
"memory_mode": {
@@ -217,13 +217,13 @@ def test_report_operators(
],
],
)
-def test_report_device_details(
- device: EthosUConfiguration,
+def test_report_target_details(
+ target: EthosUConfiguration,
expected_plain_text: str,
expected_json_dict: dict,
) -> None:
"""Test report_operatos formatter."""
- report = report_device_details(device)
+ report = report_target_details(target)
assert isinstance(report, Report)
plain_text = report.to_plain_text()
diff --git a/tests/test_target_tosa_reporters.py b/tests/test_target_tosa_reporters.py
index 43d2a56..0578b1a 100644
--- a/tests/test_target_tosa_reporters.py
+++ b/tests/test_target_tosa_reporters.py
@@ -12,13 +12,13 @@ from mlia.core.reporting import Report
from mlia.target.tosa.config import TOSAConfiguration
from mlia.target.tosa.metadata import TOSAMetadata
from mlia.target.tosa.reporters import MetadataDisplay
-from mlia.target.tosa.reporters import report_device
+from mlia.target.tosa.reporters import report_target
from mlia.target.tosa.reporters import tosa_formatters
-def test_tosa_report_device() -> None:
- """Test function report_device()."""
- report = report_device(TOSAConfiguration.load_profile("tosa"))
+def test_tosa_report_target() -> None:
+ """Test function report_target()."""
+ report = report_target(TOSAConfiguration.load_profile("tosa"))
assert report.to_plain_text()