aboutsummaryrefslogtreecommitdiff
path: root/tests
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 /tests
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
Diffstat (limited to 'tests')
-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
8 files changed, 43 insertions, 43 deletions
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()