blob: 7b69d2e81e8b282ce2ca83f970cd16b983e7d7a6 [file] [log] [blame]
Richard Burton00553462021-11-10 16:27:14 +00001#----------------------------------------------------------------------------
Richard Burtonf32a86a2022-11-15 11:46:11 +00002# SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
Richard Burton00553462021-11-10 16:27:14 +00003# 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#----------------------------------------------------------------------------
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +010017# Append the API to use for this use case
18list(APPEND ${use_case}_API_LIST "noise_reduction")
Richard Burton00553462021-11-10 16:27:14 +000019
20USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
21 0x00200000
22 STRING)
23
24if (ETHOS_U_NPU_ENABLED)
Ayaan Masood233cec02021-12-09 17:22:22 +000025 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)
Richard Burton00553462021-11-10 16:27:14 +000026else()
27 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8.tflite)
28endif()
29
30USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
31 ${DEFAULT_MODEL_PATH}
32 FILEPATH)
33
Eanna O Cathain4c0ac912022-09-22 15:18:34 +010034set_input_file_path_user_option(".wav" ${use_case})
Richard Burton00553462021-11-10 16:27:14 +000035
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
Richard Burton033c9152021-12-07 14:04:44 +000056USER_OPTION(${use_case}_AUDIO_MIN_SAMPLES "Specify the minimum number of samples to use. Default is 512, if the audio is shorter it will be automatically padded."
57 512
Richard Burton00553462021-11-10 16:27:14 +000058 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} */"
Richard Burton033c9152021-12-07 14:04:44 +000072 "extern const int g_FrameLength = 512"
73 "extern const int g_FrameStride = 512"
Richard Burton00553462021-11-10 16:27:14 +000074 "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}
Liam Barry213a5432022-05-09 17:06:19 +010082 NAMESPACE "arm" "app" "rnn")
Richard Burton00553462021-11-10 16:27:14 +000083
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()