summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2021-04-07 09:27:38 +0100
committerIsabella Gottardi <isabella.gottardi@arm.com>2021-05-07 12:19:19 +0100
commit2181d0ac35f30202985a877950c88325ff665f6b (patch)
treee16c50d41d85945e0c2c864323ac1769b02af64f
parentd580eee180be219e118152cedabc9637da8574d6 (diff)
downloadml-embedded-evaluation-kit-2181d0ac35f30202985a877950c88325ff665f6b.tar.gz
MLECO-1766: Default build flow helper scripts added
MLECO-1882: Anomaly Detection use-case default model download added and tests updated to run with it. Test data generation cmake logic moved from use-case cmakes to top-level cmake script. Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com> Change-Id: Ifde469e3585c37b9a53810236a92ce52d4fbb407
-rw-r--r--.gitignore4
-rw-r--r--CMakeLists.txt37
-rw-r--r--build_default.py89
-rw-r--r--release_notes.txt5
-rw-r--r--scripts/cmake/source_gen_utils.cmake71
-rw-r--r--scripts/cmake/util_functions.cmake17
-rw-r--r--scripts/vela/default_vela.ini (renamed from scripts/vela/vela.ini)34
-rw-r--r--set_up_default_resources.py216
-rw-r--r--source/use_case/ad/usecase.cmake33
-rw-r--r--source/use_case/asr/usecase.cmake72
-rw-r--r--source/use_case/img_class/usecase.cmake70
-rw-r--r--source/use_case/inference_runner/usecase.cmake26
-rw-r--r--source/use_case/kws/usecase.cmake70
-rw-r--r--source/use_case/kws_asr/usecase.cmake227
-rw-r--r--tests/use_case/ad/InferenceTestAD.cc29
-rw-r--r--tests/use_case/ad/include/AdGoldenInput.hpp132
-rw-r--r--tests/use_case/asr/InferenceTestWav2Letter.cc2
-rw-r--r--tests/use_case/img_class/InferenceTestMobilenetV2.cc1
-rw-r--r--tests/use_case/kws/InferenceTestDSCNN.cc2
-rw-r--r--tests/use_case/kws_asr/InferenceTestDSCNN.cc41
-rw-r--r--tests/use_case/kws_asr/InferenceTestWav2Letter.cc4
21 files changed, 524 insertions, 658 deletions
diff --git a/.gitignore b/.gitignore
index ba6dc28..2a80d95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,10 @@
.idea
# Downloaded files
+resources_downloaded
+
+#Logs
+*.log
# Build files
CMakeFiles
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bc8d08..0581a2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -284,7 +284,8 @@ foreach(use_case ${USE_CASES})
# Executable application:
set(TARGET_NAME "ethos-u-${use_case}")
- set(DEFAULT_MODEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/models)
+ set(DEFAULT_MODEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources_downloaded/${use_case})
+ set(DEFAULT_TEST_DATA_DIR ${DEFAULT_MODEL_DIR})
set(SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/src)
set(INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/include)
@@ -424,21 +425,25 @@ foreach(use_case ${USE_CASES})
"${TEST_SRC_USE_CASE}/${use_case}/**/*.c"
)
- if (DEFINED ${use_case}_TEST_IFM AND DEFINED ${use_case}_TEST_OFM)
- message(STATUS "Test vectors are available for ${${use_case}_MODEL_TFLITE_PATH} "
- "Input: ${${use_case}_TEST_IFM} "
- "Output: ${${use_case}_TEST_OFM}")
-
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(GLOB_RECURSE TEST_SOURCES_GEN
- "${TEST_SRC_GEN_DIR}/*.cc"
- "${TEST_SRC_GEN_DIR}/**/*.cc"
- )
- message(STATUS "Adding ${TEST_SOURCES_GEN} to test sources")
- list(APPEND TEST_SOURCES ${TEST_SOURCES_GEN})
- list(APPEND TEST_RESOURCES_INCLUDE ${TEST_INC_GEN_DIR})
- endif()
+ set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
+ set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
+ file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
+
+ # Generate test data files to be included in x86 tests
+ generate_test_data_code(
+ INPUT_DIR "${DEFAULT_TEST_DATA_DIR}"
+ DESTINATION_SRC ${TEST_SRC_GEN_DIR}
+ DESTINATION_HDR ${TEST_INC_GEN_DIR}
+ NAMESPACE "test"
+ )
+
+ file(GLOB_RECURSE TEST_SOURCES_GEN
+ "${TEST_SRC_GEN_DIR}/*.cc"
+ "${TEST_SRC_GEN_DIR}/**/*.cc"
+ )
+ message(STATUS "Adding ${TEST_SOURCES_GEN} to test sources")
+ list(APPEND TEST_SOURCES ${TEST_SOURCES_GEN})
+ list(APPEND TEST_RESOURCES_INCLUDE ${TEST_INC_GEN_DIR})
set(TEST_TARGET_NAME "${CMAKE_PROJECT_NAME}-${use_case}-tests")
add_executable(${TEST_TARGET_NAME} ${TEST_SOURCES})
diff --git a/build_default.py b/build_default.py
new file mode 100644
index 0000000..318ccb1
--- /dev/null
+++ b/build_default.py
@@ -0,0 +1,89 @@
+#!env/bin/python3
+
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import subprocess
+import shutil
+import multiprocessing
+import logging
+import sys
+from argparse import ArgumentParser
+
+from set_up_default_resources import set_up_resources
+
+
+def run(download_resources, run_vela_on_models):
+ """
+ Run the helpers scripts.
+
+ Parameters:
+ ----------
+ download_resources (bool): Specifies if 'Download resources' step is performed.
+ run_vela_on_models (bool): Only if `download_resources` is True, specifies if run vela on downloaded models.
+ """
+
+ current_file_dir = os.path.dirname(os.path.abspath(__file__))
+ logging.basicConfig(filename='log_build_default.log', level=logging.DEBUG)
+ logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
+
+ # 1. Download models if specified
+ if download_resources is True:
+ logging.info("Downloading resources.")
+ set_up_resources(run_vela_on_models)
+
+ # 2. Build default configuration
+ logging.info("Building default configuration.")
+ target_platform = "mps3"
+ target_subsystem = "sse-300"
+ build_dir = os.path.join(current_file_dir, f"cmake-build-{target_platform}-{target_subsystem}-release")
+ try:
+ os.mkdir(build_dir)
+ except FileExistsError:
+ # Directory already exists, clean it
+ for filename in os.listdir(build_dir):
+ filepath = os.path.join(build_dir, filename)
+ try:
+ if os.path.isfile(filepath) or os.path.islink(filepath):
+ os.unlink(filepath)
+ elif os.path.isdir(filepath):
+ shutil.rmtree(filepath)
+ except Exception as e:
+ logging.error('Failed to delete %s. Reason: %s' % (filepath, e))
+ os.chdir(build_dir)
+ cmake_toolchain_file = os.path.join(current_file_dir, "scripts", "cmake", "bare-metal-toolchain.cmake")
+ cmake_command = (f"cmake .. -DTARGET_PLATFORM={target_platform} -DTARGET_SUBSYSTEM={target_subsystem} " +
+ f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file} ")
+ logging.info(cmake_command)
+ state = subprocess.run(cmake_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ logging.info(state.stdout.decode('utf-8'))
+
+ make_command = f"make -j{multiprocessing.cpu_count()}"
+ logging.info(make_command)
+ state = subprocess.run(make_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ logging.info(state.stdout.decode('utf-8'))
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument("--skip-download",
+ help="Do not download resources: models and test vectors",
+ action="store_true")
+ parser.add_argument("--skip-vela",
+ help="Do not run Vela optimizer on downloaded models.",
+ action="store_true")
+ args = parser.parse_args()
+ run(not args.skip_download, not args.skip_vela)
diff --git a/release_notes.txt b/release_notes.txt
index 13c40a7..abf605b 100644
--- a/release_notes.txt
+++ b/release_notes.txt
@@ -1,3 +1,8 @@
+Changes in 21.05
+ * Added script to download and optimize default models.
+ * Added script to run default build flow.
+ * Added a model for Anomaly Detection use case.
+
Changes in 21.03
* simple platform support added
* model conditioning examples added
diff --git a/scripts/cmake/source_gen_utils.cmake b/scripts/cmake/source_gen_utils.cmake
index 8653016..92ec53d 100644
--- a/scripts/cmake/source_gen_utils.cmake
+++ b/scripts/cmake/source_gen_utils.cmake
@@ -194,39 +194,62 @@ endfunction()
# placed
# @param[in] DESTINATION_HDR directory in which the output h file must be
# placed
-# @param[in] USECASE name of the sub-usecase
# @param[in] NAMESPACE data name space
# NOTE: Uses python
##############################################################################
function(generate_test_data_code)
- set(multiValueArgs NAMESPACE)
- set(oneValueArgs INPUT_DIR DESTINATION_SRC DESTINATION_HDR USECASE)
+ set(multiValueArgs NAMESPACE INPUT_DIR)
+ set(oneValueArgs DESTINATION_SRC DESTINATION_HDR)
cmake_parse_arguments(PARSED "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
- # Absolute paths for passing into python script
- get_filename_component(input_dir_abs ${PARSED_INPUT_DIR} ABSOLUTE)
- get_filename_component(src_out_abs ${PARSED_DESTINATION_SRC} ABSOLUTE)
- get_filename_component(hdr_out_abs ${PARSED_DESTINATION_HDR} ABSOLUTE)
-
- foreach(name ${PARSED_NAMESPACE})
- set(py_arg_exp ${py_arg_exp} --namespaces=${name})
- endforeach()
+ list(LENGTH PARSED_INPUT_DIR input_dir_length)
- message(STATUS "Generating test ifm and ofm files from ${input_dir_abs}")
- execute_process(
- COMMAND ${PYTHON} ${SCRIPTS_DIR}/py/gen_test_data_cpp.py
- --data_folder_path ${input_dir_abs}
- --source_folder_path ${src_out_abs}
- --header_folder_path ${hdr_out_abs}
- --usecase ${PARSED_USECASE}
- ${py_arg_exp}
- RESULT_VARIABLE return_code
- )
- if (NOT return_code EQUAL "0")
- message(FATAL_ERROR "Failed to generate test data files.")
- endif ()
+ if (${input_dir_length} GREATER 1)
+ set(add_extra_namespace TRUE)
+ else()
+ set(add_extra_namespace FALSE)
+ endif()
+ foreach(input_dir ${PARSED_INPUT_DIR})
+ unset(py_arg_exp)
+ file(GLOB_RECURSE input_data_files
+ "${input_dir}/*.npy"
+ )
+ # no input NPY data found => skip code generation.
+ if(NOT input_data_files)
+ message(WARNING "No files were found to generated input data: ${input_dir}")
+ break()
+ endif()
+
+ # Absolute paths for passing into python script
+ get_filename_component(input_dir_abs ${input_dir} ABSOLUTE)
+ get_filename_component(input_dir_name ${input_dir} NAME)
+ get_filename_component(src_out_abs ${PARSED_DESTINATION_SRC} ABSOLUTE)
+ get_filename_component(hdr_out_abs ${PARSED_DESTINATION_HDR} ABSOLUTE)
+
+ foreach(name ${PARSED_NAMESPACE})
+ set(py_arg_exp ${py_arg_exp} --namespaces=${name})
+ endforeach()
+
+ if (${add_extra_namespace})
+ set(py_arg_exp ${py_arg_exp} --namespaces=${input_dir_name})
+ endif()
+
+ message(STATUS "Generating test ifm and ofm files from ${input_dir_abs}")
+ execute_process(
+ COMMAND ${PYTHON} ${SCRIPTS_DIR}/py/gen_test_data_cpp.py
+ --data_folder_path ${input_dir_abs}
+ --source_folder_path ${src_out_abs}
+ --header_folder_path ${hdr_out_abs}
+ --usecase ${input_dir_name}
+ ${py_arg_exp}
+ RESULT_VARIABLE return_code
+ )
+ if (NOT return_code EQUAL "0")
+ message(FATAL_ERROR "Failed to generate test data files.")
+ endif ()
+ endforeach()
endfunction()
diff --git a/scripts/cmake/util_functions.cmake b/scripts/cmake/util_functions.cmake
index e39de2f..ecd9d2a 100644
--- a/scripts/cmake/util_functions.cmake
+++ b/scripts/cmake/util_functions.cmake
@@ -20,6 +20,21 @@
##############################################################################
function(USER_OPTION name description default type)
+ if (${type} STREQUAL PATH_OR_FILE)
+
+ if (DEFINED ${name})
+ get_path_type(${${name}} PATH_TYPE)
+ else()
+ get_path_type(${default} PATH_TYPE)
+ endif()
+
+ # Set the default type if path is not a dir or file path (or undefined)
+ if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
+ message(FATAL_ERROR "Invalid ${name}. It should be a dir or file path.")
+ endif()
+ set(type ${PATH_TYPE})
+ endif()
+
if (NOT DEFINED ${name})
set(${name} ${default} CACHE ${type} ${description})
endif()
@@ -123,7 +138,7 @@ endfunction()
# download_path: location where this file is to be downloaded (path including filename)
function(download_file_from_modelzoo model_zoo_version file_sub_path download_path)
- set(MODEL_ZOO_REPO "https://github.com/ARM-software/ML-zoo/raw")
+ set(MODEL_ZOO_REPO "https://github.com/ARM-software/ML-zoo/raw")
string(JOIN "/" FILE_URL
${MODEL_ZOO_REPO} ${model_zoo_version} ${file_sub_path})
diff --git a/scripts/vela/vela.ini b/scripts/vela/default_vela.ini
index fcd18be..c49b597 100644
--- a/scripts/vela/vela.ini
+++ b/scripts/vela/default_vela.ini
@@ -21,20 +21,6 @@
; -----------------------------------------------------------------------------
; System Configuration
-; Ethos-U55 Deep Embedded: SRAM (1.6 GB/s) and Flash (0.1 GB/s)
-[System_Config.Ethos_U55_Deep_Embedded]
-core_clock=200e6
-axi0_port=Sram
-axi1_port=OffChipFlash
-Sram_clock_scale=1.0
-Sram_burst_length=32
-Sram_read_latency=32
-Sram_write_latency=32
-OffChipFlash_clock_scale=0.0625
-OffChipFlash_burst_length=128
-OffChipFlash_read_latency=64
-OffChipFlash_write_latency=64
-
; Ethos-U55 High-End Embedded: SRAM (4 GB/s) and Flash (0.5 GB/s)
[System_Config.Ethos_U55_High_End_Embedded]
core_clock=500e6
@@ -52,29 +38,9 @@ OffChipFlash_write_latency=64
; -----------------------------------------------------------------------------
; Memory Mode
-; SRAM Only: only one AXI port is used and the SRAM is used for all storage
-[Memory_Mode.Sram_Only]
-const_mem_area=Axi0
-arena_mem_area=Axi0
-cache_mem_area=Axi0
-
; Shared SRAM: the SRAM is shared between the Ethos-U and the Cortex-M software
; The non-SRAM memory is assumed to be read-only
[Memory_Mode.Shared_Sram]
const_mem_area=Axi1
arena_mem_area=Axi0
cache_mem_area=Axi0
-
-; Dedicated SRAM: the SRAM (384KB) is only for use by the Ethos-U
-; The non-SRAM memory is assumed to be read-writeable
-[Memory_Mode.Dedicated_Sram]
-const_mem_area=Axi1
-arena_mem_area=Axi1
-cache_mem_area=Axi0
-cache_sram_size=393216
-
-; Dedicated SRAM 512KB: the SRAM (512KB) is only for use by the Ethos-U
-; The non-SRAM memory is assumed to be read-writeable
-[Memory_Mode.Dedicated_Sram_512KB]
-inherit=Memory_Mode.Dedicated_Sram
-cache_sram_size=524288
diff --git a/set_up_default_resources.py b/set_up_default_resources.py
new file mode 100644
index 0000000..60c1747
--- /dev/null
+++ b/set_up_default_resources.py
@@ -0,0 +1,216 @@
+#!env/bin/python3
+
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os, errno
+import urllib.request
+import subprocess
+import fnmatch
+import logging
+import sys
+
+from argparse import ArgumentParser
+from urllib.error import URLError
+
+json_uc_res = [{
+ "use_case_name": "ad",
+ "resources": [{"name": "ad_medium_int8.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/7c32b097f7d94aae2cd0b98a8ed5a3ba81e66b18/models/anomaly_detection/micronet_medium/tflite_int8/ad_medium_int8.tflite"},
+ {"name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/7c32b097f7d94aae2cd0b98a8ed5a3ba81e66b18/models/anomaly_detection/micronet_medium/tflite_int8/testing_input/input/0.npy"},
+ {"name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/7c32b097f7d94aae2cd0b98a8ed5a3ba81e66b18/models/anomaly_detection/micronet_medium/tflite_int8/testing_output/Identity/0.npy"}]
+},
+ {
+ "use_case_name": "asr",
+ "resources": [{"name": "wav2letter_int8.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/wav2letter_int8.tflite"},
+ {"name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/testing_input/input_2_int8/0.npy"},
+ {"name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/testing_output/Identity_int8/0.npy"}]
+ },
+ {
+ "use_case_name": "img_class",
+ "resources": [{"name": "mobilenet_v2_1.0_224_quantized_1_default_1.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/image_classification/mobilenet_v2_1.0_224/tflite_uint8/mobilenet_v2_1.0_224_quantized_1_default_1.tflite"},
+ {"name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/image_classification/mobilenet_v2_1.0_224/tflite_uint8/testing_input/input/0.npy"},
+ {"name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/image_classification/mobilenet_v2_1.0_224/tflite_uint8/testing_output/output/0.npy"}]
+ },
+ {
+ "use_case_name": "kws",
+ "resources": [{"name": "ds_cnn_clustered_int8.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/ds_cnn_clustered_int8.tflite"},
+ {"name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/testing_input/input_2/0.npy"},
+ {"name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/testing_output/Identity/0.npy"}]
+ },
+ {
+ "use_case_name": "kws_asr",
+ "resources": [{"name": "wav2letter_int8.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/wav2letter_int8.tflite"},
+ {"sub_folder": "asr", "name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/testing_input/input_2_int8/0.npy"},
+ {"sub_folder": "asr", "name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/speech_recognition/wav2letter/tflite_int8/testing_output/Identity_int8/0.npy"},
+ {"name": "ds_cnn_clustered_int8.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/ds_cnn_clustered_int8.tflite"},
+ {"sub_folder": "kws", "name": "ifm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/testing_input/input_2/0.npy"},
+ {"sub_folder": "kws", "name": "ofm0.npy",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/ds_cnn_large/tflite_clustered_int8/testing_output/Identity/0.npy"}]
+ },
+ {
+ "use_case_name": "inference_runner",
+ "resources": [{"name": "dnn_s_quantized.tflite",
+ "url": "https://github.com/ARM-software/ML-zoo/raw/68b5fbc77ed28e67b2efc915997ea4477c1d9d5b/models/keyword_spotting/dnn_small/tflite_int8/dnn_s_quantized.tflite"}
+ ]
+ },]
+
+
+def call_command(command: str) -> str:
+ """
+ Helpers function that call subprocess and return the output.
+
+ Parameters:
+ ----------
+ command (string): Specifies the command to run.
+ """
+ logging.info(command)
+ proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+ stdout_log = proc.communicate()[0].decode("utf-8")
+ logging.info(stdout_log)
+ return stdout_log
+
+
+def set_up_resources(run_vela_on_models=False):
+ """
+ Helpers function that retrieve the output from a command.
+
+ Parameters:
+ ----------
+ run_vela_on_models (bool): Specifies if run vela on downloaded models.
+ """
+ current_file_dir = os.path.dirname(os.path.abspath(__file__))
+ download_dir = os.path.abspath(os.path.join(current_file_dir, "resources_downloaded"))
+ logging.basicConfig(filename='log_build_default.log', level=logging.DEBUG)
+ logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
+
+ try:
+ # 1.1 Does the download dir exist?
+ os.mkdir(download_dir)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ logging.info("'resources_downloaded' directory exists.")
+ else:
+ raise
+
+ # 1.2 Does the virtual environment exist?
+ env_python = str(os.path.abspath(os.path.join(download_dir, "env", "bin", "python3")))
+ env_activate = str(os.path.abspath(os.path.join(download_dir, "env", "bin", "activate")))
+ if not os.path.isdir(os.path.join(download_dir, "env")):
+ os.chdir(download_dir)
+ # Create the virtual environment
+ command = "python3 -m venv env"
+ call_command(command)
+ commands = ["pip install --upgrade pip", "pip install --upgrade setuptools"]
+ for c in commands:
+ command = f"{env_python} -m {c}"
+ call_command(command)
+ os.chdir(current_file_dir)
+ # 1.3 Make sure to have all the requirement
+ requirements = ["ethos-u-vela==2.1.1"]
+ command = f"{env_python} -m pip freeze"
+ packages = call_command(command)
+ for req in requirements:
+ if req not in packages:
+ command = f"{env_python} -m pip install {req}"
+ call_command(command)
+
+ # 2. Download models
+ for uc in json_uc_res:
+ try:
+ # Does the usecase_name download dir exist?
+ os.mkdir(os.path.join(download_dir, uc["use_case_name"]))
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ logging.error(f"Error creating {uc['use_case_name']} directory.")
+ raise
+
+ for res in uc["resources"]:
+ res_name = res["name"]
+ res_url = res["url"]
+ if "sub_folder" in res:
+ try:
+ # Does the usecase_name/sub_folder download dir exist?
+ os.mkdir(os.path.join(download_dir, uc["use_case_name"], res["sub_folder"]))
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ logging.error(f"Error creating {uc['use_case_name']} / {res['sub_folder']} directory.")
+ raise
+ res_dst = os.path.join(download_dir,
+ uc["use_case_name"],
+ res["sub_folder"],
+ res_name)
+ else:
+ res_dst = os.path.join(download_dir,
+ uc["use_case_name"],
+ res_name)
+ try:
+ g = urllib.request.urlopen(res_url)
+ with open(res_dst, 'b+w') as f:
+ f.write(g.read())
+ logging.info(f"- Downloaded {res_url} to {res_dst}.")
+ except URLError:
+ logging.error(f"URLError while downloading {res_url}.")
+ raise
+
+ # 3. Run vela on models in resources_downloaded
+ # New models will have same name with '_vela' appended.
+ # For example:
+ # original model: ds_cnn_clustered_int8.tflite
+ # after vela model: ds_cnn_clustered_int8_vela.tflite
+ #
+ # Note: To avoid to run vela twice on the same model, it's supposed that
+ # downloaded model names don't contain the 'vela' word.
+ if run_vela_on_models is True:
+ config_file = os.path.join(current_file_dir, "scripts", "vela", "default_vela.ini")
+ models = [os.path.join(dirpath, f)
+ for dirpath, dirnames, files in os.walk(download_dir)
+ for f in fnmatch.filter(files, '*.tflite') if "vela" not in f]
+
+ for model in models:
+ output_dir = os.path.dirname(model)
+ command = (f". {env_activate} && vela {model} " +
+ "--accelerator-config=ethos-u55-128 " +
+ "--block-config-limit=0 " +
+ f"--config {config_file} " +
+ "--memory-mode=Shared_Sram " +
+ "--system-config=Ethos_U55_High_End_Embedded " +
+ f"--output-dir={output_dir}")
+ call_command(command)
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument("--skip-vela",
+ help="Do not run Vela optimizer on downloaded models.",
+ action="store_true")
+ args = parser.parse_args()
+ set_up_resources(not args.skip_vela)
diff --git a/source/use_case/ad/usecase.cmake b/source/use_case/ad/usecase.cmake
index 46e4101..d591f98 100644
--- a/source/use_case/ad/usecase.cmake
+++ b/source/use_case/ad/usecase.cmake
@@ -15,25 +15,9 @@
# limitations under the License.
#----------------------------------------------------------------------------
-# If the path to a directory or source file has been defined,
-# get the type here (FILEPATH or PATH):
-if (DEFINED ${use_case}_FILE_PATH)
- get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
-
- # Set the default type if path is not a dir or file path (or undefined)
- if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
- message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
- endif()
-else()
- # Default is a directory path
- set(PATH_TYPE PATH)
-endif()
-
-message(STATUS "${use_case}_FILE_PATH is of type: ${PATH_TYPE}")
-
USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single input WAV file, to use in the evaluation application."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
- ${PATH_TYPE})
+ PATH_OR_FILE)
USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000."
16000
@@ -76,19 +60,10 @@ USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen
0x00200000
STRING)
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH)
-
- set(MODEL_RESOURCES_DIR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR})
- set(MODEL_FILENAME ad_med_nov11_int8.tflite)
- set(DEFAULT_MODEL_PATH ${MODEL_RESOURCES_DIR}/${MODEL_FILENAME})
-
- # TODO: Download the model here for this use case when available on Model Zoo.
- # For now we write a place holder file.
- file(WRITE ${DEFAULT_MODEL_PATH} "Placeholder")
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH "N/A")
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ad_medium_int8.tflite)
endif()
set(EXTRA_MODEL_CODE
diff --git a/source/use_case/asr/usecase.cmake b/source/use_case/asr/usecase.cmake
index cac1862..2b17d84 100644
--- a/source/use_case/asr/usecase.cmake
+++ b/source/use_case/asr/usecase.cmake
@@ -15,25 +15,9 @@
# limitations under the License.
#----------------------------------------------------------------------------
-# If the path to a directory or source file has been defined,
-# get the type here (FILEPATH or PATH):
-if (DEFINED ${use_case}_FILE_PATH)
- get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
-
- # Set the default type if path is not a dir or file path (or undefined)
- if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
- message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
- endif()
-else()
- # Default is a directory path
- set(PATH_TYPE PATH)
-endif()
-
-message(STATUS "${use_case}_FILE_PATH is of type: ${PATH_TYPE}")
-
USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single WAV file, to use in the evaluation application."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
- ${PATH_TYPE})
+ PATH_OR_FILE)
USER_OPTION(${use_case}_LABELS_TXT_FILE "Labels' txt file for the chosen model."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/labels_wav2letter.txt
@@ -90,58 +74,10 @@ USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen
0x00200000
STRING)
-
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH)
-
- set(MODEL_FILENAME wav2letter_int8.tflite)
- set(MODEL_RESOURCES_DIR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR})
- set(DEFAULT_MODEL_PATH ${MODEL_RESOURCES_DIR}/${MODEL_FILENAME})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH "models/speech_recognition/wav2letter/tflite_int8")
- set(ZOO_MODEL_SUBPATH "${ZOO_COMMON_SUBPATH}/${MODEL_FILENAME}")
- set(ZOO_MODEL_VERSION "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_MODEL_SUBPATH} ${DEFAULT_MODEL_PATH})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH to the CMake configuration.")
- endif()
-
- # If the target platform is native
- if (${TARGET_PLATFORM} STREQUAL native)
-
- # Download test vectors
- set(ZOO_TEST_IFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_input/input_2_int8/0.npy")
- set(ZOO_TEST_OFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_output/Identity_int8/0.npy")
-
- set(${use_case}_TEST_IFM ${MODEL_RESOURCES_DIR}/ifm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
- set(${use_case}_TEST_OFM ${MODEL_RESOURCES_DIR}/ofm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_IFM_SUBPATH} ${${use_case}_TEST_IFM})
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_OFM_SUBPATH} ${${use_case}_TEST_OFM})
-
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
-
- # Generate test data files to be included in x86 tests
- generate_test_data_code(
- INPUT_DIR "${DOWNLOAD_DEP_DIR}/${use_case}"
- DESTINATION_SRC ${TEST_SRC_GEN_DIR}
- DESTINATION_HDR ${TEST_INC_GEN_DIR}
- USECASE "${use_case}")
- endif()
-
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/wav2letter_int8_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH "N/A")
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/wav2letter_int8.tflite)
endif()
set(EXTRA_MODEL_CODE
diff --git a/source/use_case/img_class/usecase.cmake b/source/use_case/img_class/usecase.cmake
index 384c58e..0089356 100644
--- a/source/use_case/img_class/usecase.cmake
+++ b/source/use_case/img_class/usecase.cmake
@@ -15,24 +15,9 @@
# limitations under the License.
#----------------------------------------------------------------------------
-# If the path to a directory or source file has been defined,
-# get the type here (FILEPATH or PATH):
-if (DEFINED ${use_case}_FILE_PATH)
- get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
- # Set the default type if path is not a dir or file path (or undefined)
- if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
- message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
- endif()
-else()
- # Default is a directory path
- set(PATH_TYPE PATH)
-endif()
-
-message(STATUS "${use_case}_FILE_PATH is of type: ${PATH_TYPE}")
-
USER_OPTION(${use_case}_FILE_PATH "Directory with custom image files to use, or path to a single image, in the evaluation application"
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
- ${PATH_TYPE})
+ PATH_OR_FILE)
USER_OPTION(${use_case}_IMAGE_SIZE "Square image size in pixels. Images will be resized to this size."
224
@@ -61,57 +46,10 @@ USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen
0x00200000
STRING)
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH)
-
- set(MODEL_RESOURCES_DIR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR})
- set(MODEL_FILENAME mobilenet_v2_1.0_224_quantized_1_default_1.tflite)
- set(DEFAULT_MODEL_PATH ${MODEL_RESOURCES_DIR}/${MODEL_FILENAME})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH "models/image_classification/mobilenet_v2_1.0_224/tflite_uint8")
- set(ZOO_MODEL_SUBPATH "${ZOO_COMMON_SUBPATH}/${MODEL_FILENAME}")
- set(ZOO_MODEL_VERSION "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_MODEL_SUBPATH} ${DEFAULT_MODEL_PATH})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH to the CMake configuration.")
- endif()
-
- # If the target platform is native
- if (${TARGET_PLATFORM} STREQUAL native)
-
- # Download test vectors
- set(ZOO_TEST_IFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_input/input/0.npy")
- set(ZOO_TEST_OFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_output/output/0.npy")
-
- set(${use_case}_TEST_IFM ${MODEL_RESOURCES_DIR}/ifm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
- set(${use_case}_TEST_OFM ${MODEL_RESOURCES_DIR}/ofm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_IFM_SUBPATH} ${${use_case}_TEST_IFM})
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_OFM_SUBPATH} ${${use_case}_TEST_OFM})
-
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
-
- # Generate test data files to be included in x86 tests
- generate_test_data_code(
- INPUT_DIR "${DOWNLOAD_DEP_DIR}/${use_case}"
- DESTINATION_SRC ${TEST_SRC_GEN_DIR}
- DESTINATION_HDR ${TEST_INC_GEN_DIR}
- USECASE "${use_case}")
- endif()
-
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/mobilenet_v2_1.0_224_quantized_1_default_1_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH "N/A")
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/mobilenet_v2_1.0_224_quantized_1_default_1.tflite)
endif()
USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
diff --git a/source/use_case/inference_runner/usecase.cmake b/source/use_case/inference_runner/usecase.cmake
index 0fd159f..225aaf4 100644
--- a/source/use_case/inference_runner/usecase.cmake
+++ b/source/use_case/inference_runner/usecase.cmake
@@ -21,30 +21,10 @@ USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen
generate_default_input_code(${INC_GEN_DIR})
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH)
-
- set(MODEL_RESOURCES_DIR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR})
- set(MODEL_FILENAME dnn_s_quantized.tflite)
- set(DEFAULT_MODEL_PATH ${MODEL_RESOURCES_DIR}/${MODEL_FILENAME})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH "models/keyword_spotting/dnn_small/tflite_int8/")
- set(ZOO_MODEL_SUBPATH "${ZOO_COMMON_SUBPATH}/${MODEL_FILENAME}")
- set(ZOO_MODEL_VERSION "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_MODEL_SUBPATH} ${DEFAULT_MODEL_PATH})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH to the CMake configuration.")
- endif()
-
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH "N/A")
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized.tflite)
endif()
USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
diff --git a/source/use_case/kws/usecase.cmake b/source/use_case/kws/usecase.cmake
index e6fbf69..23de212 100644
--- a/source/use_case/kws/usecase.cmake
+++ b/source/use_case/kws/usecase.cmake
@@ -15,24 +15,9 @@
# limitations under the License.
#----------------------------------------------------------------------------
-# If the path to a directory or source file has been defined,
-# get the type here (FILEPATH or PATH):
-if (DEFINED ${use_case}_FILE_PATH)
- get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
-
- # Set the default type if path is not a dir or file path (or undefined)
- if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
- message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
- endif()
-else()
- # Default is a directory path
- set(PATH_TYPE PATH)
-endif()
-
-message(STATUS "${use_case}_FILE_PATH is of type: ${PATH_TYPE}")
USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single WAV file, to use in the evaluation application."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
- ${PATH_TYPE})
+ PATH_OR_FILE)
USER_OPTION(${use_case}_LABELS_TXT_FILE "Labels' txt file for the chosen model."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/ds_cnn_labels.txt
@@ -88,57 +73,10 @@ USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen
0x00100000
STRING)
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH)
-
- set(MODEL_FILENAME ds_cnn_clustered_int8.tflite)
- set(MODEL_RESOURCES_DIR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR})
- set(DEFAULT_MODEL_PATH ${MODEL_RESOURCES_DIR}/${MODEL_FILENAME})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH "models/keyword_spotting/ds_cnn_large/tflite_clustered_int8")
- set(ZOO_MODEL_SUBPATH "${ZOO_COMMON_SUBPATH}/${MODEL_FILENAME}")
- set(ZOO_MODEL_VERSION "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_MODEL_SUBPATH} ${DEFAULT_MODEL_PATH})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH to the CMake configuration.")
- endif()
-
- # If the target platform is native
- if (${TARGET_PLATFORM} STREQUAL native)
-
- # Download test vectors
- set(ZOO_TEST_IFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_input/input_2/0.npy")
- set(ZOO_TEST_OFM_SUBPATH "${ZOO_COMMON_SUBPATH}/testing_output/Identity/0.npy")
-
- set(${use_case}_TEST_IFM ${MODEL_RESOURCES_DIR}/ifm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
- set(${use_case}_TEST_OFM ${MODEL_RESOURCES_DIR}/ofm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_IFM_SUBPATH} ${${use_case}_TEST_IFM})
- download_file_from_modelzoo(${ZOO_MODEL_VERSION} ${ZOO_TEST_OFM_SUBPATH} ${${use_case}_TEST_OFM})
-
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
-
- # Generate test data files to be included in x86 tests
- generate_test_data_code(
- INPUT_DIR "${DOWNLOAD_DEP_DIR}/${use_case}"
- DESTINATION_SRC ${TEST_SRC_GEN_DIR}
- DESTINATION_HDR ${TEST_INC_GEN_DIR}
- USECASE "${use_case}")
- endif()
-
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ds_cnn_clustered_int8_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH "N/A")
+ set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/ds_cnn_clustered_int8.tflite)
endif()
set(EXTRA_MODEL_CODE
diff --git a/source/use_case/kws_asr/usecase.cmake b/source/use_case/kws_asr/usecase.cmake
index 5729be2..d8ac897 100644
--- a/source/use_case/kws_asr/usecase.cmake
+++ b/source/use_case/kws_asr/usecase.cmake
@@ -17,23 +17,21 @@
# If the path to a directory or source file has been defined,
# get the type here (FILEPATH or PATH):
-if (DEFINED ${use_case}_FILE_PATH)
- get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
-
- # Set the default type if path is not a dir or file path (or undefined)
- if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
- message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
- endif()
-else()
- # Default is a directory path
- set(PATH_TYPE PATH)
-endif()
-
-message(STATUS "${use_case}_FILE_PATH is of type: ${PATH_TYPE}")
+#if (DEFINED ${use_case}_FILE_PATH)
+# get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
+#
+# # Set the default type if path is not a dir or file path (or undefined)
+# if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
+# message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
+# endif()
+#else()
+# # Default is a directory path
+# set(PATH_TYPE PATH)
+#endif()
USER_OPTION(${use_case}_FILE_PATH "Directory with WAV files, or path to a single WAV file, to use in the evaluation application."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
- ${PATH_TYPE})
+ PATH_OR_FILE)
USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 16000."
16000
@@ -59,42 +57,16 @@ USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples
16000
STRING)
-# Generate audio .cc files:
-generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
- ${${use_case}_AUDIO_RATE}
- ${${use_case}_AUDIO_MONO}
- ${${use_case}_AUDIO_OFFSET}
- ${${use_case}_AUDIO_DURATION}
- ${${use_case}_AUDIO_RES_TYPE}
- ${${use_case}_AUDIO_MIN_SAMPLES})
-
# Generate kws labels file:
USER_OPTION(${use_case}_LABELS_TXT_FILE_KWS "Labels' txt file for the chosen model."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/ds_cnn_labels.txt
FILEPATH)
-set(${use_case}_LABELS_CPP_FILE_KWS Labels_dscnn)
-generate_labels_code(
- INPUT "${${use_case}_LABELS_TXT_FILE_KWS}"
- DESTINATION_SRC ${SRC_GEN_DIR}
- DESTINATION_HDR ${INC_GEN_DIR}
- OUTPUT_FILENAME "${${use_case}_LABELS_CPP_FILE_KWS}"
- NAMESPACE "arm" "app" "kws"
-)
-
# Generate asr labels file:
USER_OPTION(${use_case}_LABELS_TXT_FILE_ASR "Labels' txt file for the chosen model."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/labels/labels_wav2letter.txt
FILEPATH)
-set(${use_case}_LABELS_CPP_FILE_ASR Labels_wav2letter)
-generate_labels_code(
- INPUT "${${use_case}_LABELS_TXT_FILE_ASR}"
- DESTINATION_SRC ${SRC_GEN_DIR}
- DESTINATION_HDR ${INC_GEN_DIR}
- OUTPUT_FILENAME "${${use_case}_LABELS_CPP_FILE_ASR}"
- NAMESPACE "arm" "app" "asr"
-)
USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
0x00200000
@@ -108,132 +80,14 @@ USER_OPTION(${use_case}_MODEL_SCORE_THRESHOLD_ASR "Specify the score threshold [
0.5
STRING)
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH_KWS)
-
- set(SUB_USECASE_KWS "kws")
- set(MODEL_FILENAME_KWS ds_cnn_clustered_int8.tflite)
- set(MODEL_RESOURCES_DIR_KWS ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR_KWS})
- set(DEFAULT_MODEL_PATH_KWS ${MODEL_RESOURCES_DIR_KWS}/${MODEL_FILENAME_KWS})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH_KWS "models/keyword_spotting/ds_cnn_large/tflite_clustered_int8")
- set(ZOO_MODEL_SUBPATH_KWS "${ZOO_COMMON_SUBPATH_KWS}/${MODEL_FILENAME_KWS}")
- set(ZOO_MODEL_VERSION_KWS "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_KWS} ${ZOO_MODEL_SUBPATH_KWS} ${DEFAULT_MODEL_PATH_KWS})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH_KWS to the CMake configuration.")
- endif()
-
- if (${TARGET_PLATFORM} STREQUAL native)
-
- # Download test vectors
- set(ZOO_TEST_IFM_SUBPATH_KWS "${ZOO_COMMON_SUBPATH_KWS}/testing_input/input_2/0.npy")
- set(ZOO_TEST_OFM_SUBPATH_KWS "${ZOO_COMMON_SUBPATH_KWS}/testing_output/Identity/0.npy")
-
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR_KWS}/${SUB_USECASE_KWS})
- set(${use_case}_TEST_IFM ${MODEL_RESOURCES_DIR_KWS}/${SUB_USECASE_KWS}/ifm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}-${SUB_USECASE_KWS}")
- set(${use_case}_TEST_OFM ${MODEL_RESOURCES_DIR_KWS}/${SUB_USECASE_KWS}/ofm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}-${SUB_USECASE_KWS}.")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_KWS} ${ZOO_TEST_IFM_SUBPATH_KWS} ${${use_case}_TEST_IFM})
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_KWS} ${ZOO_TEST_OFM_SUBPATH_KWS} ${${use_case}_TEST_OFM})
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
-
- generate_test_data_code(
- INPUT_DIR "${DOWNLOAD_DEP_DIR}/${use_case}/${SUB_USECASE_KWS}"
- DESTINATION_SRC ${TEST_SRC_GEN_DIR}
- DESTINATION_HDR ${TEST_INC_GEN_DIR}
- USECASE ${SUB_USECASE_KWS}
- NAMESPACE "arm" "app" ${SUB_USECASE_KWS})
- endif()
-
-else()
- set(DEFAULT_MODEL_PATH_KWS "N/A")
-endif()
-
-set(EXTRA_MODEL_CODE_KWS
- "/* Model parameters for ${use_case} */"
- "extern const uint32_t g_NumMfcc = 10"
- "extern const uint32_t g_NumAudioWins = 49"
- "extern const int g_FrameLength = 640"
- "extern const int g_FrameStride = 320"
- "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD_KWS}"
- )
-
-# If there is no tflite file pointed to
-if (NOT DEFINED ${use_case}_MODEL_TFLITE_PATH_ASR)
-
- set(SUB_USECASE_ASR "asr")
- set(MODEL_FILENAME_ASR wav2letter_int8.tflite)
- set(MODEL_RESOURCES_DIR_ASR ${DOWNLOAD_DEP_DIR}/${use_case})
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR_ASR})
- set(DEFAULT_MODEL_PATH_ASR ${MODEL_RESOURCES_DIR_ASR}/${MODEL_FILENAME_ASR})
-
- # Download the default model
- set(ZOO_COMMON_SUBPATH_ASR "models/speech_recognition/wav2letter/tflite_int8")
- set(ZOO_MODEL_SUBPATH_ASR "${ZOO_COMMON_SUBPATH_ASR}/${MODEL_FILENAME_ASR}")
- set(ZOO_MODEL_VERSION_ASR "68b5fbc77ed28e67b2efc915997ea4477c1d9d5b")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_ASR} ${ZOO_MODEL_SUBPATH_ASR} ${DEFAULT_MODEL_PATH_ASR})
-
- if (ETHOS_U55_ENABLED)
- message(STATUS
- "Ethos-U55 is enabled, but the model downloaded is not optimized by vela. "
- "To use Ethos-U55 acceleration, optimise the downloaded model and pass it "
- "as ${use_case}_MODEL_TFLITE_PATH to the CMake configuration.")
- endif()
-
- # If the target platform is native
- if (${TARGET_PLATFORM} STREQUAL native)
-
- # Download test vectors
- set(ZOO_TEST_IFM_SUBPATH_ASR "${ZOO_COMMON_SUBPATH_ASR}/testing_input/input_2_int8/0.npy")
- set(ZOO_TEST_OFM_SUBPATH_ASR "${ZOO_COMMON_SUBPATH_ASR}/testing_output/Identity_int8/0.npy")
-
- file(MAKE_DIRECTORY ${MODEL_RESOURCES_DIR_ASR}/${SUB_USECASE_ASR})
- set(${use_case}_TEST_IFM_ASR ${MODEL_RESOURCES_DIR_ASR}/${SUB_USECASE_ASR}/ifm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}-${SUB_USECASE_ASR}")
- set(${use_case}_TEST_OFM_ASR ${MODEL_RESOURCES_DIR_ASR}/${SUB_USECASE_ASR}/ofm0.npy CACHE FILEPATH
- "Input test vector for ${use_case}-${SUB_USECASE_ASR}")
-
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_ASR} ${ZOO_TEST_IFM_SUBPATH_KWS} ${${use_case}_TEST_IFM_ASR})
- download_file_from_modelzoo(${ZOO_MODEL_VERSION_ASR} ${ZOO_TEST_OFM_SUBPATH_KWS} ${${use_case}_TEST_OFM_ASR})
-
- set(TEST_SRC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/src)
- set(TEST_INC_GEN_DIR ${CMAKE_BINARY_DIR}/generated/${use_case}/tests/include)
- file(MAKE_DIRECTORY ${TEST_SRC_GEN_DIR} ${TEST_INC_GEN_DIR})
-
- # Generate test data files to be included in x86 tests
- generate_test_data_code(
- INPUT_DIR "${DOWNLOAD_DEP_DIR}/${use_case}/${SUB_USECASE_ASR}"
- DESTINATION_SRC ${TEST_SRC_GEN_DIR}
- DESTINATION_HDR ${TEST_INC_GEN_DIR}
- USECASE ${SUB_USECASE_ASR}
- NAMESPACE "arm" "app" ${SUB_USECASE_ASR})
- endif()
-
+if (ETHOS_U55_ENABLED)
+ set(DEFAULT_MODEL_PATH_KWS ${DEFAULT_MODEL_DIR}/ds_cnn_clustered_int8_vela.tflite)
+ set(DEFAULT_MODEL_PATH_ASR ${DEFAULT_MODEL_DIR}/wav2letter_int8_vela.tflite)
else()
- set(DEFAULT_MODEL_PATH_ASR "N/A")
+ set(DEFAULT_MODEL_PATH_KWS ${DEFAULT_MODEL_DIR}/ds_cnn_clustered_int8.tflite)
+ set(DEFAULT_MODEL_PATH_ASR ${DEFAULT_MODEL_DIR}/wav2letter_int8.tflite)
endif()
-set(EXTRA_MODEL_CODE_ASR
- "/* Model parameters for ${use_case} */"
- "extern const int g_FrameLength = 512"
- "extern const int g_FrameStride = 160"
- "extern const int g_ctxLen = 98"
- "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD_ASR}"
- )
-
USER_OPTION(${use_case}_MODEL_TFLITE_PATH_KWS "NN models file to be used for KWS in the evaluation application. Model files must be in tflite format."
${DEFAULT_MODEL_PATH_KWS}
FILEPATH
@@ -244,6 +98,28 @@ USER_OPTION(${use_case}_MODEL_TFLITE_PATH_ASR "NN models file to be used for ASR
FILEPATH
)
+# If the target platform is native
+if (${TARGET_PLATFORM} STREQUAL native)
+ set(DEFAULT_TEST_DATA_DIR ${DEFAULT_TEST_DATA_DIR}/asr ${DEFAULT_TEST_DATA_DIR}/kws)
+endif()
+
+set(EXTRA_MODEL_CODE_KWS
+ "/* Model parameters for ${use_case} */"
+ "extern const uint32_t g_NumMfcc = 10"
+ "extern const uint32_t g_NumAudioWins = 49"
+ "extern const int g_FrameLength = 640"
+ "extern const int g_FrameStride = 320"
+ "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD_KWS}"
+ )
+
+set(EXTRA_MODEL_CODE_ASR
+ "/* Model parameters for ${use_case} */"
+ "extern const int g_FrameLength = 512"
+ "extern const int g_FrameStride = 160"
+ "extern const int g_ctxLen = 98"
+ "extern const float g_ScoreThreshold = ${${use_case}_MODEL_SCORE_THRESHOLD_ASR}"
+ )
+
# Generate model file for KWS
generate_tflite_code(
MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH_KWS}
@@ -259,3 +135,28 @@ generate_tflite_code(
EXPRESSIONS ${EXTRA_MODEL_CODE_ASR}
NAMESPACE "arm" "app" "asr"
)
+
+generate_labels_code(
+ INPUT "${${use_case}_LABELS_TXT_FILE_ASR}"
+ DESTINATION_SRC ${SRC_GEN_DIR}
+ DESTINATION_HDR ${INC_GEN_DIR}
+ OUTPUT_FILENAME "Labels_wav2letter"
+ NAMESPACE "arm" "app" "asr"
+)
+
+generate_labels_code(
+ INPUT "${${use_case}_LABELS_TXT_FILE_KWS}"
+ DESTINATION_SRC ${SRC_GEN_DIR}
+ DESTINATION_HDR ${INC_GEN_DIR}
+ OUTPUT_FILENAME "Labels_dscnn"
+ NAMESPACE "arm" "app" "kws"
+)
+
+# Generate audio .cc files:
+generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
+ ${${use_case}_AUDIO_RATE}
+ ${${use_case}_AUDIO_MONO}
+ ${${use_case}_AUDIO_OFFSET}
+ ${${use_case}_AUDIO_DURATION}
+ ${${use_case}_AUDIO_RES_TYPE}
+ ${${use_case}_AUDIO_MIN_SAMPLES}) \ No newline at end of file
diff --git a/tests/use_case/ad/InferenceTestAD.cc b/tests/use_case/ad/InferenceTestAD.cc
index b87699d..d5e21c2 100644
--- a/tests/use_case/ad/InferenceTestAD.cc
+++ b/tests/use_case/ad/InferenceTestAD.cc
@@ -19,7 +19,7 @@
#include <random>
#include "AdModel.hpp"
-#include "AdGoldenInput.hpp"
+#include "TestData_ad.hpp"
#include "hal.h"
#include "TensorFlowLiteMicro.hpp"
@@ -27,6 +27,8 @@
#define AD_IN_FEATURE_VEC_DATA_SIZE (1024)
#endif /* AD_FEATURE_VEC_DATA_SIZE */
+using namespace test;
+
bool RunInference(arm::app::Model& model, const int8_t vec[])
{
TfLiteTensor *inputTensor = model.GetInputTensor(0);
@@ -67,7 +69,7 @@ void TestInference(const T *input_goldenFV, const T *output_goldenFV, arm::app::
TfLiteTensor *outputTensor = model.GetOutputTensor(0);
REQUIRE(outputTensor);
- REQUIRE(outputTensor->bytes == AD_OUT_FEATURE_VEC_DATA_SIZE);
+ REQUIRE(outputTensor->bytes == OFM_DATA_SIZE);
auto tensorData = tflite::GetTensorData<T>(outputTensor);
REQUIRE(tensorData);
@@ -77,7 +79,7 @@ void TestInference(const T *input_goldenFV, const T *output_goldenFV, arm::app::
}
}
-TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8", "[AD][.]")
+TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8", "[AD]")
{
arm::app::AdModel model{};
@@ -88,13 +90,22 @@ TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8"
REQUIRE(RunInferenceRandom(model));
}
-TEST_CASE("Running golden vector inference with TensorFlow Lite Micro and AdModel Int8", "[AD][.]")
+TEST_CASE("Running golden vector inference with TensorFlow Lite Micro and AdModel Int8", "[AD]")
{
- arm::app::AdModel model{};
+ for (uint32_t i = 0 ; i < NUMBER_OF_FM_FILES; ++i) {
+ auto input_goldenFV = get_ifm_data_array(i);;
+ auto output_goldenFV = get_ofm_data_array(i);
- REQUIRE_FALSE(model.IsInited());
- REQUIRE(model.Init());
- REQUIRE(model.IsInited());
+ DYNAMIC_SECTION("Executing inference with re-init")
+ {
+ arm::app::AdModel model{};
+
+ REQUIRE_FALSE(model.IsInited());
+ REQUIRE(model.Init());
+ REQUIRE(model.IsInited());
- TestInference(ad_golden_input, ad_golden_out, model);
+ TestInference<int8_t>(input_goldenFV, output_goldenFV, model);
+
+ }
+ }
} \ No newline at end of file
diff --git a/tests/use_case/ad/include/AdGoldenInput.hpp b/tests/use_case/ad/include/AdGoldenInput.hpp
deleted file mode 100644
index 41d1a89..0000000
--- a/tests/use_case/ad/include/AdGoldenInput.hpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef AD_GOLDEN_OUTPUTS_HPP
-#define AD_GOLDEN_OUTPUTS_HPP
-
-#include "Model.hpp"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-#ifndef AD_FEATURE_VEC_DATA_SIZE
-#define AD_IN_FEATURE_VEC_DATA_SIZE (1024)
-#define AD_OUT_FEATURE_VEC_DATA_SIZE (8)
-#endif /* AD_FEATURE_VEC_DATA_SIZE */
-
-/* Golden input. */
-uint8_t ad_golden_input[AD_IN_FEATURE_VEC_DATA_SIZE] = {
- 0x7a, 0x7c, 0x7f, 0x7c, 0x7b, 0x61, 0x7f, 0x75, 0x7f, 0x6b, 0x6d, 0x71,
- 0x7f, 0x6e, 0x7a, 0x76, 0x7f, 0x7f, 0x65, 0x7f, 0x7f, 0x6f, 0x5d, 0x67,
- 0x7f, 0x5b, 0x7a, 0x43, 0x65, 0x69, 0x4e, 0x63, 0x5f, 0x56, 0x4e, 0x64,
- 0x36, 0x4a, 0x3c, 0x56, 0x3a, 0x61, 0x71, 0x74, 0x72, 0x6f, 0x71, 0x71,
- 0x66, 0x7b, 0x68, 0x62, 0x44, 0x5f, 0x2f, 0x3d, 0x56, 0x5b, 0x5b, 0x4d,
- 0x5f, 0x59, 0x58, 0x6e, 0x4f, 0x3d, 0x48, 0x5f, 0x46, 0x38, 0x48, 0x4f,
- 0x46, 0x74, 0x6d, 0x61, 0x60, 0x63, 0x6a, 0x68, 0x62, 0x69, 0x63, 0x5c,
- 0x6e, 0x4d, 0x4c, 0x3c, 0x5a, 0x55, 0x4a, 0x5d, 0x59, 0x66, 0x67, 0x6c,
- 0x55, 0x40, 0x49, 0x47, 0x56, 0x61, 0x48, 0x4d, 0x64, 0x61, 0x77, 0x7e,
- 0x37, 0x63, 0x52, 0x3e, 0x57, 0x4d, 0x54, 0x4f, 0x3b, 0x4c, 0x54, 0x50,
- 0x55, 0x4c, 0x57, 0x58, 0x45, 0x7b, 0x74, 0x58, 0x39, 0x34, 0x3c, 0x38,
- 0x3e, 0x1e, 0x22, 0x46, 0x2c, 0x7a, 0x6e, 0x74, 0x72, 0x70, 0x61, 0x7d,
- 0x69, 0x79, 0x66, 0x3c, 0x33, 0x20, 0x3a, 0x20, 0x34, 0x29, 0x3c, 0x4e,
- 0x47, 0x5b, 0x78, 0x47, 0x36, 0x30, 0x18, 0x45, 0x24, 0x25, 0x2c, 0x75,
- 0x71, 0x70, 0x7f, 0x73, 0x6c, 0x6c, 0x77, 0x6a, 0x6d, 0x6b, 0x6d, 0x5b,
- 0x36, 0x43, 0x34, 0x2b, 0x2e, 0x3b, 0x32, 0x67, 0x2a, 0x5b, 0x7f, 0x66,
- 0x32, 0x24, 0x28, 0x29, 0x2d, 0x31, 0x2b, 0x1d, 0x0d, 0x40, 0x3a, 0x49,
- 0x3b, 0x42, 0x37, 0x43, 0x40, 0x44, 0x4f, 0x40, 0x25, 0x1b, 0x33, 0x32,
- 0x15, 0x3b, 0x22, 0x33, 0x45, 0x4e, 0x45, 0x3a, 0x2a, 0x10, 0x19, 0x3a,
- 0x27, 0x25, 0x18, 0x0d, 0x0d, 0x3a, 0x36, 0x2d, 0x21, 0x34, 0x25, 0x38,
- 0x26, 0x33, 0x2f, 0x33, 0x2a, 0x21, 0x36, 0x1e, 0x2b, 0x28, 0x29, 0x31,
- 0x25, 0x2e, 0x4d, 0x32, 0x42, 0x1b, 0x37, 0x1a, 0x34, 0x36, 0x23, 0x25,
- 0x2b, 0x3f, 0x46, 0x41, 0x4c, 0x35, 0x39, 0x2d, 0x37, 0x4d, 0x42, 0x46,
- 0x27, 0x36, 0x20, 0x34, 0x10, 0x32, 0x19, 0x21, 0x33, 0x3b, 0x39, 0x46,
- 0x10, 0xf3, 0x26, 0x13, 0x24, 0x1f, 0x28, 0x18, 0x29, 0x20, 0x20, 0x14,
- 0x1f, 0x17, 0x27, 0x34, 0x38, 0x3e, 0x26, 0x37, 0x20, 0x33, 0x16, 0x26,
- 0x0e, 0x1c, 0x31, 0x1d, 0x23, 0x2e, 0x44, 0x38, 0x25, 0x2f, 0x27, 0x39,
- 0x3b, 0x2b, 0x36, 0x3c, 0x35, 0x3f, 0x2d, 0x3f, 0x42, 0x32, 0x43, 0x4e,
- 0x55, 0x3d, 0x17, 0x2e, 0x39, 0x20, 0x31, 0x41, 0x38, 0x2b, 0x31, 0x38,
- 0x46, 0x3f, 0x1e, 0x2d, 0x0a, 0x07, 0x18, 0xfc, 0x1a, 0x14, 0xec, 0x25,
- 0x1e, 0x30, 0x3c, 0x37, 0x2a, 0x47, 0x3c, 0x3b, 0x3b, 0x37, 0x2b, 0x22,
- 0x18, 0x1b, 0x31, 0x1e, 0x0e, 0x22, 0x13, 0x11, 0x10, 0x10, 0x14, 0x22,
- 0x0c, 0x0e, 0x18, 0x03, 0x0e, 0x03, 0x03, 0x08, 0x26, 0x0c, 0x1a, 0x0a,
- 0x06, 0x2d, 0x1e, 0x1e, 0x14, 0x1a, 0x26, 0x1d, 0x06, 0x06, 0x1c, 0x0e,
- 0x16, 0x06, 0x09, 0x13, 0x1c, 0x21, 0x25, 0x0d, 0x1c, 0x00, 0xfa, 0xfd,
- 0x13, 0xfa, 0x18, 0xff, 0x0d, 0x08, 0x23, 0x2e, 0x26, 0x1d, 0x14, 0x10,
- 0x14, 0x28, 0x14, 0x1b, 0x05, 0x0a, 0xff, 0xfa, 0x1a, 0x18, 0x11, 0x13,
- 0x16, 0x0f, 0x07, 0x12, 0x05, 0x00, 0x13, 0xf3, 0x05, 0x01, 0x01, 0x01,
- 0x1a, 0x16, 0x2b, 0x26, 0x1e, 0x21, 0x15, 0x13, 0x12, 0x28, 0x19, 0x1c,
- 0xff, 0xf8, 0xf0, 0x02, 0x01, 0x05, 0x04, 0x19, 0x11, 0x14, 0x1b, 0x15,
- 0xea, 0x19, 0x12, 0x02, 0x0f, 0x11, 0xee, 0xfe, 0x1c, 0x2f, 0x19, 0x38,
- 0x2a, 0x30, 0x26, 0x1e, 0x28, 0x29, 0x24, 0x12, 0x01, 0x12, 0xff, 0x0c,
- 0x09, 0x0b, 0x26, 0x24, 0x21, 0x24, 0x11, 0x21, 0x13, 0x17, 0xf8, 0x0c,
- 0xfd, 0x03, 0xf9, 0xfc, 0x03, 0x20, 0x14, 0x34, 0x1e, 0x30, 0x2e, 0x25,
- 0x23, 0x29, 0x16, 0x01, 0xf4, 0x05, 0x15, 0x05, 0xf9, 0x02, 0xea, 0x32,
- 0x38, 0x28, 0x28, 0x18, 0xf6, 0xfa, 0xfb, 0xff, 0xf9, 0xee, 0xff, 0x01,
- 0xfc, 0x41, 0x40, 0x2b, 0x2f, 0x1f, 0x1c, 0x20, 0x21, 0x28, 0x2b, 0x17,
- 0xfd, 0xf9, 0x07, 0xf5, 0x01, 0xf8, 0xfe, 0xfe, 0x11, 0x14, 0x27, 0x0e,
- 0xf5, 0xfd, 0xe7, 0x05, 0xef, 0xee, 0xe9, 0xf6, 0xff, 0x10, 0x0c, 0x16,
- 0x15, 0x16, 0x0d, 0x1c, 0x15, 0x1c, 0x09, 0xf6, 0x00, 0xfe, 0xf4, 0xf8,
- 0xe1, 0x0a, 0xfa, 0x05, 0x0b, 0x1b, 0x19, 0x05, 0xf0, 0xec, 0xec, 0x02,
- 0xf0, 0xec, 0xf4, 0xec, 0xe7, 0x30, 0x47, 0x2d, 0x31, 0x2a, 0x24, 0x31,
- 0x1f, 0x31, 0x2c, 0x07, 0xe4, 0xfa, 0xef, 0xee, 0xfe, 0xf5, 0xf1, 0x1a,
- 0x18, 0x33, 0x1c, 0x10, 0xf5, 0xce, 0xeb, 0xe3, 0xf1, 0xec, 0xe7, 0xed,
- 0xde, 0x19, 0x2e, 0x11, 0x1f, 0x17, 0x19, 0x23, 0x17, 0x1d, 0x1b, 0x01,
- 0xef, 0xed, 0xeb, 0xf8, 0xe9, 0xf0, 0xf3, 0x1c, 0x19, 0x2a, 0x0d, 0x19,
- 0xe3, 0xe1, 0xee, 0xe0, 0xe7, 0xee, 0xe7, 0xee, 0xea, 0x30, 0x2e, 0x2f,
- 0x32, 0x11, 0x29, 0x38, 0x0f, 0x1a, 0x29, 0x24, 0xe6, 0xfa, 0xfc, 0xf0,
- 0xed, 0xec, 0xe1, 0x2e, 0x13, 0x29, 0x22, 0x16, 0xd4, 0xee, 0xeb, 0xee,
- 0xd3, 0xe4, 0xe4, 0xe5, 0xee, 0x23, 0x08, 0x10, 0x15, 0x17, 0x1b, 0x2b,
- 0x1b, 0x1d, 0x17, 0x03, 0xf8, 0xdd, 0xe3, 0xe8, 0xe5, 0xd8, 0xdb, 0x09,
- 0xf5, 0x10, 0x16, 0x14, 0xd9, 0xde, 0xd0, 0xd7, 0xd7, 0xda, 0xe0, 0xe1,
- 0xe4, 0x0f, 0x17, 0x04, 0x10, 0x0c, 0x14, 0x1d, 0x1d, 0x17, 0x15, 0xfa,
- 0xd9, 0xd6, 0xe1, 0xdf, 0xd7, 0xdf, 0xd5, 0x18, 0xf5, 0x14, 0x08, 0x0b,
- 0xd0, 0xd6, 0xd4, 0xd7, 0xc6, 0xda, 0xc5, 0xda, 0xdc, 0x14, 0x26, 0x15,
- 0x19, 0x0d, 0x0b, 0x0f, 0x07, 0x09, 0x1b, 0x03, 0xdc, 0xda, 0xd6, 0xd8,
- 0xc0, 0xc5, 0xdc, 0x08, 0xfb, 0x10, 0x0d, 0x13, 0xd8, 0xde, 0xcb, 0xd6,
- 0xd0, 0xc7, 0xcd, 0xdc, 0xc3, 0x0c, 0x0f, 0x08, 0x13, 0x13, 0x25, 0x25,
- 0x13, 0x1f, 0x11, 0xee, 0xd0, 0xd0, 0xd2, 0xcd, 0xbf, 0xca, 0xd2, 0x0a,
- 0xeb, 0x04, 0x03, 0x10, 0xd0, 0xcd, 0xb1, 0xc7, 0xca, 0xbf, 0xe1, 0xdd,
- 0xce, 0x2b, 0x19, 0x20, 0x20, 0x14, 0x24, 0x34, 0x27, 0x2c, 0x25, 0xf8,
- 0xd5, 0xc7, 0xcb, 0xba, 0xc0, 0xcf, 0xc4, 0x14, 0x06, 0x1f, 0x28, 0x10,
- 0xc9, 0xc9, 0xc3, 0xbf, 0xc4, 0xcd, 0xd2, 0xcc, 0xd4, 0x15, 0x27, 0x1e,
- 0x19, 0x05, 0x18, 0x1d, 0x24, 0x1a, 0x1f, 0xf9, 0xcc, 0xd3, 0xc3, 0xcd,
- 0xcc, 0xc1, 0xd5, 0x10, 0xe7, 0x1d, 0x12, 0x04, 0xb4, 0xb9, 0xb0, 0xb9,
- 0xb1, 0xb1, 0xbb, 0xd2, 0xb0, 0xff, 0x22, 0x06, 0xff, 0xf7, 0xfb, 0x07,
- 0xf8, 0xfa, 0x03, 0xef, 0xc2, 0xc7, 0xb9, 0xbb, 0xb4, 0xb2, 0xb5, 0xf2,
- 0xcc, 0x05, 0xf1, 0xea, 0xb0, 0xb1, 0xa7, 0xab, 0xa9, 0xa6, 0xb2, 0xbf,
- 0xb4, 0x04, 0x0f, 0x02, 0x0e, 0x0a, 0x05, 0x07, 0xff, 0x04, 0x0a, 0xe2,
- 0xac, 0xad, 0xa9, 0xa0, 0xa8, 0xa3, 0x9a, 0xef, 0xd3, 0xf5, 0x03, 0xfd,
- 0x9c, 0x99, 0x99, 0x9c, 0x96, 0x99, 0xaf, 0xa8, 0xaa, 0xfd, 0x09, 0x0e,
- 0xf5, 0xed, 0xe7, 0xf4, 0xec, 0xf4, 0xf1, 0xd5, 0xa5, 0x9a, 0x9e, 0x98,
- 0xa7, 0x99, 0xa2, 0xd9, 0xc2, 0xf1, 0xee, 0xec, 0x8a, 0x86, 0x8c, 0x8d,
- 0x84, 0x88, 0xa0, 0xad, 0xa2, 0xe5, 0x02, 0xff, 0xf5, 0xe4, 0xee, 0xf1,
- 0xf2, 0xec, 0xf0, 0xc9, 0x9e, 0x97, 0x98, 0x89, 0x8f, 0x88, 0x93, 0xd9,
- 0xd1, 0xf8, 0xeb, 0xde
-};
-
-/* Golden output */
-uint8_t ad_golden_out[AD_OUT_FEATURE_VEC_DATA_SIZE] = {
- 0x3a, 0x7f, 0x36, 0x76, 0x80, 0x80, 0x80, 0x80
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AD_GOLDEN_OUTPUTS_HPP */
diff --git a/tests/use_case/asr/InferenceTestWav2Letter.cc b/tests/use_case/asr/InferenceTestWav2Letter.cc
index 1fa4092..0943db8 100644
--- a/tests/use_case/asr/InferenceTestWav2Letter.cc
+++ b/tests/use_case/asr/InferenceTestWav2Letter.cc
@@ -22,6 +22,8 @@
#include <catch.hpp>
#include <random>
+using namespace test;
+
bool RunInference(arm::app::Model& model, const int8_t vec[], const size_t copySz)
{
TfLiteTensor* inputTensor = model.GetInputTensor(0);
diff --git a/tests/use_case/img_class/InferenceTestMobilenetV2.cc b/tests/use_case/img_class/InferenceTestMobilenetV2.cc
index 698382f..b2720a8 100644
--- a/tests/use_case/img_class/InferenceTestMobilenetV2.cc
+++ b/tests/use_case/img_class/InferenceTestMobilenetV2.cc
@@ -22,6 +22,7 @@
#include <catch.hpp>
+using namespace test;
bool RunInference(arm::app::Model& model, const uint8_t imageData[])
{
diff --git a/tests/use_case/kws/InferenceTestDSCNN.cc b/tests/use_case/kws/InferenceTestDSCNN.cc
index 06358a4..d02e33c 100644
--- a/tests/use_case/kws/InferenceTestDSCNN.cc
+++ b/tests/use_case/kws/InferenceTestDSCNN.cc
@@ -22,6 +22,8 @@
#include <catch.hpp>
#include <random>
+using namespace test;
+
bool RunInference(arm::app::Model& model, const int8_t vec[])
{
TfLiteTensor* inputTensor = model.GetInputTensor(0);
diff --git a/tests/use_case/kws_asr/InferenceTestDSCNN.cc b/tests/use_case/kws_asr/InferenceTestDSCNN.cc
index f0e5c02..e210c33 100644
--- a/tests/use_case/kws_asr/InferenceTestDSCNN.cc
+++ b/tests/use_case/kws_asr/InferenceTestDSCNN.cc
@@ -22,34 +22,32 @@
#include <catch.hpp>
#include <random>
-namespace arm {
-namespace app {
+namespace test {
namespace kws {
-bool RunInference(arm::app::Model& model, const int8_t vec[])
-{
+
+bool RunInference(arm::app::Model& model, const int8_t vec[]) {
TfLiteTensor* inputTensor = model.GetInputTensor(0);
REQUIRE(inputTensor);
const size_t copySz = inputTensor->bytes < IFM_DATA_SIZE ?
- inputTensor->bytes :
- IFM_DATA_SIZE;
+ inputTensor->bytes :
+ IFM_DATA_SIZE;
memcpy(inputTensor->data.data, vec, copySz);
return model.RunInference();
}
-bool RunInferenceRandom(arm::app::Model& model)
-{
+bool RunInferenceRandom(arm::app::Model& model) {
TfLiteTensor* inputTensor = model.GetInputTensor(0);
REQUIRE(inputTensor);
std::random_device rndDevice;
std::mt19937 mersenneGen{rndDevice()};
- std::uniform_int_distribution<short> dist {-128, 127};
+ std::uniform_int_distribution<short> dist{-128, 127};
- auto gen = [&dist, &mersenneGen](){
- return dist(mersenneGen);
- };
+ auto gen = [&dist, &mersenneGen]() {
+ return dist(mersenneGen);
+ };
std::vector<int8_t> randomAudio(inputTensor->bytes);
std::generate(std::begin(randomAudio), std::end(randomAudio), gen);
@@ -59,8 +57,7 @@ bool RunInferenceRandom(arm::app::Model& model)
}
template<typename T>
-void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::Model& model)
-{
+void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::Model& model) {
REQUIRE(RunInference(model, input_goldenFV));
TfLiteTensor* outputTensor = model.GetOutputTensor(0);
@@ -71,12 +68,11 @@ void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::
REQUIRE(tensorData);
for (size_t i = 0; i < outputTensor->bytes; i++) {
- REQUIRE((int)tensorData[i] == (int)((T)output_goldenFV[i]));
+ REQUIRE((int) tensorData[i] == (int) ((T) output_goldenFV[i]));
}
}
-TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]")
-{
+TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]") {
arm::app::DsCnnModel model{};
REQUIRE_FALSE(model.IsInited());
@@ -86,14 +82,12 @@ TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]")
REQUIRE(RunInferenceRandom(model));
}
-TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]")
-{
- for (uint32_t i = 0 ; i < NUMBER_OF_FM_FILES; ++i) {
+TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]") {
+ for (uint32_t i = 0; i < NUMBER_OF_FM_FILES; ++i) {
const int8_t* input_goldenFV = get_ifm_data_array(i);
const int8_t* output_goldenFV = get_ofm_data_array(i);
- DYNAMIC_SECTION("Executing inference with re-init")
- {
+ DYNAMIC_SECTION("Executing inference with re-init") {
arm::app::DsCnnModel model{};
REQUIRE_FALSE(model.IsInited());
@@ -107,5 +101,4 @@ TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]")
}
} //namespace
-} //namespace
-} //namespace
+} //namespace \ No newline at end of file
diff --git a/tests/use_case/kws_asr/InferenceTestWav2Letter.cc b/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
index ee63c2f..897ad0a 100644
--- a/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
+++ b/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
@@ -22,8 +22,7 @@
#include <catch.hpp>
#include <random>
-namespace arm {
-namespace app {
+namespace test {
namespace asr {
bool RunInference(arm::app::Model& model, const int8_t vec[], const size_t copySz)
@@ -111,4 +110,3 @@ TEST_CASE("Running inference with Tflu and Wav2LetterModel Int8", "[Wav2Letter][
} //namespace
} //namespace
-} //namespace