aboutsummaryrefslogtreecommitdiff
path: root/tests/test_backend_vela_performance.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_backend_vela_performance.py')
-rw-r--r--tests/test_backend_vela_performance.py27
1 files changed, 6 insertions, 21 deletions
diff --git a/tests/test_backend_vela_performance.py b/tests/test_backend_vela_performance.py
index 5800630..b4f8d4c 100644
--- a/tests/test_backend_vela_performance.py
+++ b/tests/test_backend_vela_performance.py
@@ -6,13 +6,14 @@ from unittest.mock import MagicMock
import pytest
-from mlia.backend.vela.compiler import optimize_model
+from mlia.backend.vela.compiler import compile_model
from mlia.backend.vela.performance import estimate_performance
from mlia.backend.vela.performance import layer_metrics
from mlia.backend.vela.performance import LayerwisePerfInfo
from mlia.backend.vela.performance import parse_layerwise_perf_csv
from mlia.backend.vela.performance import PerformanceMetrics
from mlia.target.ethos_u.config import EthosUConfiguration
+from mlia.utils.filesystem import recreate_directory
def test_estimate_performance(test_tflite_model: Path) -> None:
@@ -142,24 +143,6 @@ def test_estimate_performance_parse_layerwise_empty_csv_file(
assert len(layerwise_object.layerwise_info) == 0
-def test_estimate_performance_already_optimized(
- tmp_path: Path, test_tflite_model: Path
-) -> None:
- """Test that performance estimation should fail for already optimized model."""
- target_config = EthosUConfiguration.load_profile("ethos-u55-256")
-
- optimized_model_path = tmp_path / "optimized_model.tflite"
-
- optimize_model(
- test_tflite_model, target_config.compiler_options, optimized_model_path
- )
-
- with pytest.raises(
- Exception, match="Unable to estimate performance for the given optimized model"
- ):
- estimate_performance(optimized_model_path, target_config.compiler_options)
-
-
def test_read_invalid_model(test_tflite_invalid_model: Path) -> None:
"""Test that reading invalid model should fail with exception."""
with pytest.raises(
@@ -173,16 +156,18 @@ def test_compile_invalid_model(
test_tflite_model: Path, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
"""Test that if model could not be compiled then correct exception raised."""
+
mock_compiler = MagicMock()
mock_compiler.side_effect = Exception("Bad model!")
- monkeypatch.setattr("mlia.backend.vela.compiler.compiler_driver", mock_compiler)
+ monkeypatch.setattr("mlia.backend.vela.compiler.main", mock_compiler)
model_path = tmp_path / "optimized_model.tflite"
with pytest.raises(
Exception, match="Model could not be optimized with Vela compiler"
):
target_config = EthosUConfiguration.load_profile("ethos-u55-256")
- optimize_model(test_tflite_model, target_config.compiler_options, model_path)
+ recreate_directory(Path(target_config.compiler_options.output_dir))
+ compile_model(test_tflite_model, target_config.compiler_options)
assert not model_path.exists()