blob: 60c163586cc2850a61f0f3a355015fe62e689f96 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
Richard Burtonf32a86a2022-11-15 11:46:11 +00002# SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
alexander3c798932021-03-26 21:42:19 +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 "inference_runner")
alexander3c798932021-03-26 21:42:19 +000019
20USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
21 0x00200000
22 STRING)
23
24generate_default_input_code(${INC_GEN_DIR})
25
Cisco Cervelleraf085fa52021-08-02 09:32:07 +010026if (ETHOS_U_NPU_ENABLED)
Kshitij Sisodia3be26232021-10-29 12:29:06 +010027 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)
alexander3c798932021-03-26 21:42:19 +000028else()
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010029 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized.tflite)
alexander3c798932021-03-26 21:42:19 +000030endif()
31
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010032if (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)
38endif()
alexander3c798932021-03-26 21:42:19 +000039
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010040# For non-native targets, for use with the FVPs only.
41if (${${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
66else()
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 Barry213a5432022-05-09 17:06:19 +010075 NAMESPACE "arm" "app" "inference_runner")
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010076endif()