diff options
author | Richard Burton <richard.burton@arm.com> | 2020-04-08 16:39:05 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-04-10 16:11:09 +0000 |
commit | dc0c6ed9f8b993e63f492f203d7d7080ab4c835c (patch) | |
tree | ea8541990b13ebf1a038009aa6b8b4b1ea8c3f55 /python/pyarmnn/test/test_profiling_utilities.py | |
parent | fe5a24beeef6e9a41366e694f41093565e748048 (diff) | |
download | armnn-dc0c6ed9f8b993e63f492f203d7d7080ab4c835c.tar.gz |
Add PyArmNN to work with ArmNN API of 20.02
* Add Swig rules for generating python wrapper
* Add documentation
* Add tests and testing data
Change-Id: If48eda08931514fa21e72214dfead2835f07237c
Signed-off-by: Richard Burton <richard.burton@arm.com>
Signed-off-by: Derek Lamberti <derek.lamberti@arm.com>
Diffstat (limited to 'python/pyarmnn/test/test_profiling_utilities.py')
-rw-r--r-- | python/pyarmnn/test/test_profiling_utilities.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/python/pyarmnn/test/test_profiling_utilities.py b/python/pyarmnn/test/test_profiling_utilities.py new file mode 100644 index 0000000000..b7b91b5613 --- /dev/null +++ b/python/pyarmnn/test/test_profiling_utilities.py @@ -0,0 +1,68 @@ +# Copyright © 2020 Arm Ltd. All rights reserved. +# SPDX-License-Identifier: MIT +import os + +import pytest + +import pyarmnn as ann + + +class MockIProfiler: + def __init__(self, json_string): + self._profile_json = json_string + + def as_json(self): + return self._profile_json + + +@pytest.fixture() +def mock_profiler(shared_data_folder): + path_to_file = os.path.join(shared_data_folder, 'mock_profile_out.json') + with open(path_to_file, 'r') as file: + profiler_output = file.read() + return MockIProfiler(profiler_output) + + +def test_inference_exec(mock_profiler): + profiling_data_obj = ann.get_profiling_data(mock_profiler) + + assert (len(profiling_data_obj.inference_data) > 0) + assert (len(profiling_data_obj.per_workload_execution_data) > 0) + + # Check each total execution time + assert (profiling_data_obj.inference_data["execution_time"] == [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]) + assert (profiling_data_obj.inference_data["time_unit"] == "us") + + +@pytest.mark.parametrize("exec_times, unit, backend, workload", [([2, 2, + 2, 2, + 2, 2], + 'us', + 'CpuRef', + 'RefSomeMock1dWorkload_Execute_#5'), + ([2, 2, + 2, 2, + 2, 2], + 'us', + 'CpuAcc', + 'NeonSomeMock2Workload_Execute_#6'), + ([2, 2, + 2, 2, + 2, 2], + 'us', + 'GpuAcc', + 'ClSomeMock3dWorkload_Execute_#7'), + ([2, 2, + 2, 2, + 2, 2], + 'us', + 'EthosNAcc', + 'EthosNSomeMock4dWorkload_Execute_#8') + ]) +def test_profiler_workloads(mock_profiler, exec_times, unit, backend, workload): + profiling_data_obj = ann.get_profiling_data(mock_profiler) + + work_load_exec = profiling_data_obj.per_workload_execution_data[workload] + assert work_load_exec["execution_time"] == exec_times + assert work_load_exec["time_unit"] == unit + assert work_load_exec["backend"] == backend |