aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaul Farkas <raul.farkas@arm.com>2022-11-04 16:12:52 +0000
committerRaul Farkas <raul.farkas@arm.com>2022-11-07 11:56:49 +0000
commit27668f6837c4f0a7197d13baff7bffc11f652fba (patch)
treefc363c7538d8f62ea841a55ec7d912bf9f41d446 /tests
parente356ab410ff9c1d36186cac57ca7457964ef97f2 (diff)
downloadmlia-27668f6837c4f0a7197d13baff7bffc11f652fba.tar.gz
MLIA-688 Fix --supported-ops-report flag
* Add `api.generate_supported_operators_report` that calls a report generator based on given target profile. * Update `--supported-ops-report` cli flag help section and README.md info by specifying that it is currently only supported for Ethos-U. * Add tests for `generate_supported_operators_report` method. * Add stub methods `report` for Cortex-A and Tosa operators.py module that throw a "Not supported" exception. Change-Id: Iaf373fe48299d807e48fd6a0e6c029ce32203f4f
Diffstat (limited to 'tests')
-rw-r--r--tests/test_api.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 7b567bf..6fa15b3 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1,11 +1,15 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Tests for the API functions."""
+from __future__ import annotations
+
from pathlib import Path
from unittest.mock import MagicMock
+from unittest.mock import patch
import pytest
+from mlia.api import generate_supported_operators_report
from mlia.api import get_advice
from mlia.api import get_advisor
from mlia.core.common import AdviceCategory
@@ -107,3 +111,50 @@ def test_get_advisor(
tosa_advisor = get_advisor(ExecutionContext(), "tosa", str(test_keras_model))
assert isinstance(tosa_advisor, TOSAInferenceAdvisor)
+
+
+@pytest.mark.parametrize(
+ ["target_profile", "required_calls", "exception_msg"],
+ [
+ [
+ "ethos-u55-128",
+ "mlia.tools.vela_wrapper.generate_supported_operators_report",
+ None,
+ ],
+ [
+ "ethos-u65-256",
+ "mlia.tools.vela_wrapper.generate_supported_operators_report",
+ None,
+ ],
+ [
+ "tosa",
+ None,
+ "Generating a supported operators report is not "
+ "currently supported with TOSA target profile.",
+ ],
+ [
+ "cortex-a",
+ None,
+ "Generating a supported operators report is not "
+ "currently supported with Cortex-A target profile.",
+ ],
+ [
+ "Unknown",
+ None,
+ "Unable to find target profile Unknown",
+ ],
+ ],
+)
+def test_supported_ops_report_generator(
+ target_profile: str, required_calls: str | None, exception_msg: str | None
+) -> None:
+ """Test supported operators report generator with different target profiles."""
+ if exception_msg:
+ with pytest.raises(Exception) as exc:
+ generate_supported_operators_report(target_profile)
+ assert str(exc.value) == exception_msg
+
+ if required_calls:
+ with patch(required_calls) as mock_method:
+ generate_supported_operators_report(target_profile)
+ mock_method.assert_called_once()