From 6a88ee5315b4ce5b023370c1e55e48bf9f2b6f67 Mon Sep 17 00:00:00 2001 From: Dmitrii Agibov Date: Fri, 18 Nov 2022 17:21:09 +0000 Subject: Rename modules - Rename module "mlia.devices" into "mlia.target" - Rename module "mlia.target.ethosu" into "mlia.target.ethos_u" - Rename module "mlia.target.cortexa" into "mlia.target.cortex_a" - Rename and update tests Change-Id: I6dca7c8646d881f739fb6b5914d1cc7e45e63dc2 --- tests/test_target_cortex_a_data_collection.py | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/test_target_cortex_a_data_collection.py (limited to 'tests/test_target_cortex_a_data_collection.py') diff --git a/tests/test_target_cortex_a_data_collection.py b/tests/test_target_cortex_a_data_collection.py new file mode 100644 index 0000000..7504166 --- /dev/null +++ b/tests/test_target_cortex_a_data_collection.py @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Tests for Cortex-A data collection module.""" +from pathlib import Path +from unittest.mock import MagicMock + +import pytest + +from mlia.core.context import ExecutionContext +from mlia.target.cortex_a.data_collection import CortexAOperatorCompatibility +from mlia.target.cortex_a.operators import CortexACompatibilityInfo + + +def check_cortex_a_data_collection( + monkeypatch: pytest.MonkeyPatch, model: Path, tmpdir: str +) -> None: + """Test Cortex-A data collection.""" + assert CortexAOperatorCompatibility.name() + + monkeypatch.setattr( + "mlia.target.cortex_a.data_collection.get_cortex_a_compatibility_info", + MagicMock(return_value=CortexACompatibilityInfo(True, [])), + ) + + context = ExecutionContext(working_dir=tmpdir) + collector = CortexAOperatorCompatibility(model) + collector.set_context(context) + + data_item = collector.collect_data() + + assert isinstance(data_item, CortexACompatibilityInfo) + + +def test_cortex_a_data_collection_tflite( + monkeypatch: pytest.MonkeyPatch, test_tflite_model: Path, tmpdir: str +) -> None: + """Test Cortex-A data collection with a TensorFlow Lite model.""" + check_cortex_a_data_collection(monkeypatch, test_tflite_model, tmpdir) + + +def test_cortex_a_data_collection_keras( + monkeypatch: pytest.MonkeyPatch, test_keras_model: Path, tmpdir: str +) -> None: + """Test Cortex-A data collection with a Keras model.""" + check_cortex_a_data_collection(monkeypatch, test_keras_model, tmpdir) + + +def test_cortex_a_data_collection_tf( + monkeypatch: pytest.MonkeyPatch, test_tf_model: Path, tmpdir: str +) -> None: + """Test Cortex-A data collection with a SavedModel.""" + check_cortex_a_data_collection(monkeypatch, test_tf_model, tmpdir) -- cgit v1.2.1