Richard Burton | 0055346 | 2021-11-10 16:27:14 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 | |
| 18 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
| 19 | 0x00200000 |
| 20 | STRING) |
| 21 | |
| 22 | if (ETHOS_U_NPU_ENABLED) |
Ayaan Masood | 233cec0 | 2021-12-09 17:22:22 +0000 | [diff] [blame] | 23 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
Richard Burton | 0055346 | 2021-11-10 16:27:14 +0000 | [diff] [blame] | 24 | else() |
| 25 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/rnnoise_INT8.tflite) |
| 26 | endif() |
| 27 | |
| 28 | USER_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 | |
| 32 | 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." |
| 33 | ${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/ |
| 34 | PATH_OR_FILE) |
| 35 | |
| 36 | USER_OPTION(${use_case}_AUDIO_RATE "Specify the target sampling rate. Default is 48000." |
| 37 | 48000 |
| 38 | STRING) |
| 39 | |
| 40 | USER_OPTION(${use_case}_AUDIO_MONO "Specify if the audio needs to be converted to mono. Default is ON." |
| 41 | ON |
| 42 | BOOL) |
| 43 | |
| 44 | USER_OPTION(${use_case}_AUDIO_OFFSET "Specify the offset to start reading after this time (in seconds). Default is 0." |
| 45 | 0 |
| 46 | STRING) |
| 47 | |
| 48 | USER_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 | |
| 52 | USER_OPTION(${use_case}_AUDIO_RES_TYPE "Specify re-sampling algorithm to use. By default is 'kaiser_best'." |
| 53 | kaiser_best |
| 54 | STRING) |
| 55 | |
Richard Burton | 033c915 | 2021-12-07 14:04:44 +0000 | [diff] [blame] | 56 | USER_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 Burton | 0055346 | 2021-11-10 16:27:14 +0000 | [diff] [blame] | 58 | STRING) |
| 59 | |
| 60 | # Generate input files from audio wav files |
| 61 | generate_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 | |
| 70 | set(EXTRA_MODEL_CODE |
| 71 | "/* Model parameters for ${use_case} */" |
Richard Burton | 033c915 | 2021-12-07 14:04:44 +0000 | [diff] [blame] | 72 | "extern const int g_FrameLength = 512" |
| 73 | "extern const int g_FrameStride = 512" |
Richard Burton | 0055346 | 2021-11-10 16:27:14 +0000 | [diff] [blame] | 74 | "extern const uint32_t g_NumInputFeatures = 42*1" # Single time-step input of 42 features. |
| 75 | ) |
| 76 | |
| 77 | # Generate model file. |
| 78 | generate_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: |
| 86 | if (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}") |
| 110 | endif() |