blob: 199f8e172edca95e1a0beb0f1e6a74b92af1912a [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#----------------------------------------------------------------------------
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
34USER_OPTION(${use_case}_FILE_PATH "Directory with custom WAV input files, or path to a single WAV file, to use in the evaluation application."
35 ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
36 PATH_OR_FILE)
37
38USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 48000."
39 48000
40 STRING)
41
42USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON."
43 ON
44 BOOL)
45
46USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0."
47 0
48 STRING)
49
50USER_OPTION(${use_case}_AUDIO_DURATION "Specify the audio duration to load (in seconds). If set to 0 the entire audio will be processed."
51 0
52 STRING)
53
54USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'."
55 kaiser_best
56 STRING)
57
Richard Burton033c9152021-12-07 14:04:44 +000058USER_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."
59 512
Richard Burton00553462021-11-10 16:27:14 +000060 STRING)
61
62# Generate input files from audio wav files
63generate_audio_code(${${use_case}_FILE_PATH} ${SRC_GEN_DIR} ${INC_GEN_DIR}
64 ${${use_case}_AUDIO_RATE}
65 ${${use_case}_AUDIO_MONO}
66 ${${use_case}_AUDIO_OFFSET}
67 ${${use_case}_AUDIO_DURATION}
68 ${${use_case}_AUDIO_RES_TYPE}
69 ${${use_case}_AUDIO_MIN_SAMPLES})
70
71
72set(EXTRA_MODEL_CODE
73 "/* Model parameters for ${use_case} */"
Richard Burton033c9152021-12-07 14:04:44 +000074 "extern const int g_FrameLength = 512"
75 "extern const int g_FrameStride = 512"
Richard Burton00553462021-11-10 16:27:14 +000076 "extern const uint32_t g_NumInputFeatures = 42*1" # Single time-step input of 42 features.
77 )
78
79# Generate model file.
80generate_tflite_code(
81 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
82 DESTINATION ${SRC_GEN_DIR}
83 EXPRESSIONS ${EXTRA_MODEL_CODE}
Liam Barry213a5432022-05-09 17:06:19 +010084 NAMESPACE "arm" "app" "rnn")
Richard Burton00553462021-11-10 16:27:14 +000085
86
87# For MPS3, allow dumping of output data to memory, based on these parameters:
88if (TARGET_PLATFORM STREQUAL mps3)
89 USER_OPTION(${use_case}_MEM_DUMP_BASE_ADDR
90 "Inference output dump address for ${use_case}"
91 0x80000000 # DDR bank 2
92 STRING)
93
94 USER_OPTION(${use_case}_MEM_DUMP_LEN
95 "Inference output dump buffer size for ${use_case}"
96 0x00100000 # 1 MiB
97 STRING)
98
99 # Add special compile definitions for this use case files:
100 set(${use_case}_COMPILE_DEFS
101 "MEM_DUMP_BASE_ADDR=${${use_case}_MEM_DUMP_BASE_ADDR}"
102 "MEM_DUMP_LEN=${${use_case}_MEM_DUMP_LEN}")
103
104 file(GLOB_RECURSE SRC_FILES
105 "${SRC_USE_CASE}/${use_case}/src/*.cpp"
106 "${SRC_USE_CASE}/${use_case}/src/*.cc")
107
108 set_source_files_properties(
109 ${SRC_FILES}
110 PROPERTIES COMPILE_DEFINITIONS
111 "${${use_case}_COMPILE_DEFS}")
112endif()