From 245d64c60d0ea30f5080ff53225b5169927e24d6 Mon Sep 17 00:00:00 2001 From: Matthew Bentham Date: Mon, 2 Dec 2019 12:59:43 +0000 Subject: Work in progress of python bindings for Arm NN Not built or tested in any way Signed-off-by: Matthew Bentham Change-Id: Ie7f92b529aa5087130f0c5cc8c17db1581373236 --- python/pyarmnn/test/test_profiling_utilities.py | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 python/pyarmnn/test/test_profiling_utilities.py (limited to 'python/pyarmnn/test/test_profiling_utilities.py') diff --git a/python/pyarmnn/test/test_profiling_utilities.py b/python/pyarmnn/test/test_profiling_utilities.py new file mode 100644 index 0000000000..57f32e80ac --- /dev/null +++ b/python/pyarmnn/test/test_profiling_utilities.py @@ -0,0 +1,63 @@ +# Copyright © 2019 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, '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"] == [16035243.953000, 16096248.590000, 16138614.290000, + 16140544.388000, 16228118.274000, 16543585.760000]) + assert (profiling_data_obj.inference_data["time_unit"] == "us") + + +@pytest.mark.parametrize("exec_times, unit, backend, workload", [([1233915.166, 1221125.149, + 1228359.494, 1235065.662, + 1244369.694, 1240633.922], + 'us', + 'CpuRef', + 'RefConvolution2dWorkload_Execute_#25'), + ([270.64, 256.379, + 269.664, 259.449, + 266.65, 277.05], + 'us', + 'CpuAcc', + 'NeonActivationWorkload_Execute_#70'), + ([715.474, 729.23, + 711.325, 729.151, + 741.231, 729.702], + 'us', + 'GpuAcc', + 'ClConvolution2dWorkload_Execute_#80') + ]) +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 -- cgit v1.2.1