alexander | 3c79893 | 2021-03-26 21:42:19 +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 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 17 | # Append the API to use for this use case |
| 18 | list(APPEND ${use_case}_API_LIST "inference_runner") |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 19 | |
| 20 | USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model" |
| 21 | 0x00200000 |
| 22 | STRING) |
| 23 | |
| 24 | generate_default_input_code(${INC_GEN_DIR}) |
| 25 | |
Cisco Cervellera | f085fa5 | 2021-08-02 09:32:07 +0100 | [diff] [blame] | 26 | if (ETHOS_U_NPU_ENABLED) |
Kshitij Sisodia | 3be2623 | 2021-10-29 12:29:06 +0100 | [diff] [blame] | 27 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 28 | else() |
Isabella Gottardi | 2181d0a | 2021-04-07 09:27:38 +0100 | [diff] [blame] | 29 | set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized.tflite) |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 30 | endif() |
| 31 | |
Kshitij Sisodia | aa5e1f6 | 2021-09-24 14:42:08 +0100 | [diff] [blame] | 32 | if (NOT TARGET_PLATFORM STREQUAL native) |
| 33 | USER_OPTION( |
| 34 | ${use_case}_DYNAMIC_MEM_LOAD_ENABLED |
| 35 | "Allow dynamically loading model and ifm at runtime (valid for FVP only)" |
| 36 | OFF |
| 37 | BOOL) |
| 38 | endif() |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 39 | |
Kshitij Sisodia | aa5e1f6 | 2021-09-24 14:42:08 +0100 | [diff] [blame] | 40 | # For non-native targets, for use with the FVPs only. |
| 41 | if (${${use_case}_DYNAMIC_MEM_LOAD_ENABLED}) |
| 42 | |
| 43 | message(STATUS "NOTE: Dynamic memory load enabled. This ${use_case} application will run on FVP only.") |
| 44 | |
| 45 | if (NOT DEFINED DYNAMIC_MODEL_BASE AND DEFINED DYNAMIC_MODEL_SIZE) |
| 46 | message(FATAL_ERROR "${TARGET_PLATFORM} does not support dynamic load for model files.") |
| 47 | else() |
| 48 | set(${use_case}_COMPILE_DEFS |
| 49 | "DYNAMIC_MODEL_BASE=${DYNAMIC_MODEL_BASE};DYNAMIC_MODEL_SIZE=${DYNAMIC_MODEL_SIZE}") |
| 50 | endif() |
| 51 | |
| 52 | if (DEFINED DYNAMIC_IFM_BASE AND DEFINED DYNAMIC_IFM_SIZE) |
| 53 | string(APPEND ${use_case}_COMPILE_DEFS |
| 54 | ";DYNAMIC_IFM_BASE=${DYNAMIC_IFM_BASE};DYNAMIC_IFM_SIZE=${DYNAMIC_IFM_SIZE}") |
| 55 | else() |
| 56 | message(WARNING "${TARGET_PLATFORM} does not support dynamic load for input tensors.") |
| 57 | endif() |
| 58 | |
| 59 | if (DEFINED DYNAMIC_OFM_BASE AND DEFINED DYNAMIC_OFM_SIZE) |
| 60 | string(APPEND ${use_case}_COMPILE_DEFS |
| 61 | ";DYNAMIC_OFM_BASE=${DYNAMIC_OFM_BASE};DYNAMIC_OFM_SIZE=${DYNAMIC_OFM_SIZE}") |
| 62 | else() |
| 63 | message(WARNING "${TARGET_PLATFORM} does not support dumping of output tensors.") |
| 64 | endif() |
| 65 | |
| 66 | else() |
| 67 | USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format." |
| 68 | ${DEFAULT_MODEL_PATH} |
| 69 | FILEPATH) |
| 70 | |
| 71 | # Generate model file |
| 72 | generate_tflite_code( |
| 73 | MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} |
| 74 | DESTINATION ${SRC_GEN_DIR} |
Liam Barry | 213a543 | 2022-05-09 17:06:19 +0100 | [diff] [blame^] | 75 | NAMESPACE "arm" "app" "inference_runner") |
Kshitij Sisodia | aa5e1f6 | 2021-09-24 14:42:08 +0100 | [diff] [blame] | 76 | endif() |