blob: 14cff17abe5caf24e0e8a861aad75c7eead263e0 [file] [log] [blame]
Richard Burton00553462021-11-10 16:27:14 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2021 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
17
18USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
19 0x00200000
20 STRING)
21
22if (ETHOS_U_NPU_ENABLED)
23 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8_vela_${DEFAULT_NPU_CONFIG_ID}.tflite)
24else()
25 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8.tflite)
26endif()
27
28USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
29 ${DEFAULT_MODEL_PATH}
30 FILEPATH)
31
32USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single WAV file, to use in the evaluation application."
33 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
34 PATH_OR_FILE)
35
36USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 48000."
37 48000
38 STRING)
39
40USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON."
41 ON
42 BOOL)
43
44USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0."
45 0
46 STRING)
47
48USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed."
49 0
50 STRING)
51
52USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'."
53 kaiser_best
54 STRING)
55
56USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. Default is 480, if the audio is shorter it will be automatically padded."
57 480
58 STRING)
59
60# Generate input files from audio wav files
61generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
62 ${${use_case}_AUDIO_RATE}
63 ${${use_case}_AUDIO_MONO}
64 ${${use_case}_AUDIO_OFFSET}
65 ${${use_case}_AUDIO_DURATION}
66 ${${use_case}_AUDIO_RES_TYPE}
67 ${${use_case}_AUDIO_MIN_SAMPLES})
68
69
70set(EXTRA_MODEL_CODE
71 "/* Model parameters for ${use_case} */"
72 "extern const int g_FrameLength = 480"
73 "extern const int g_FrameStride = 480"
74 "extern const uint32_t g_NumInputFeatures = 42*1" # Single time-step input of 42 features.
75 )
76
77# Generate model file.
78generate_tflite_code(
79 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
80 DESTINATION ${SRC_GEN_DIR}
81 EXPRESSIONS ${EXTRA_MODEL_CODE}
82)
83
84
85# For MPS3, allow dumping of output data to memory, based on these parameters:
86if (TARGET_PLATFORM STREQUAL mps3)
87 USER_OPTION(${use_case}_MEM_DUMP_BASE_ADDR
88 "Inference output dump address for ${use_case}"
89 0x80000000 # DDR bank 2
90 STRING)
91
92 USER_OPTION(${use_case}_MEM_DUMP_LEN
93 "Inference output dump buffer size for ${use_case}"
94 0x00100000 # 1 MiB
95 STRING)
96
97 # Add special compile definitions for this use case files:
98 set(${use_case}_COMPILE_DEFS
99 "MEM_DUMP_BASE_ADDR=${${use_case}_MEM_DUMP_BASE_ADDR}"
100 "MEM_DUMP_LEN=${${use_case}_MEM_DUMP_LEN}")
101
102 file(GLOB_RECURSE SRC_FILES
103 "${SRC_USE_CASE}/${use_case}/src/*.cpp"
104 "${SRC_USE_CASE}/${use_case}/src/*.cc")
105
106 set_source_files_properties(
107 ${SRC_FILES}
108 PROPERTIES COMPILE_DEFINITIONS
109 "${${use_case}_COMPILE_DEFS}")
110endif()