blob: 7d1212037806118c7b926420602e88815924bba4 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +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#----------------------------------------------------------------------------
17
18USER_OPTION(${use_case}_ACTIVATION_BUF_SZ "Activation buffer size for the chosen model"
19 0x00200000
20 STRING)
21
22generate_default_input_code(${INC_GEN_DIR})
23
Cisco Cervelleraf085fa52021-08-02 09:32:07 +010024if (ETHOS_U_NPU_ENABLED)
Kshitij Sisodia3be26232021-10-29 12:29:06 +010025 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized_vela_${ETHOS_U_NPU_CONFIG_ID}.tflite)
alexander3c798932021-03-26 21:42:19 +000026else()
Isabella Gottardi2181d0a2021-04-07 09:27:38 +010027 set(DEFAULT_MODEL_PATH ${DEFAULT_MODEL_DIR}/dnn_s_quantized.tflite)
alexander3c798932021-03-26 21:42:19 +000028endif()
29
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010030if (NOT TARGET_PLATFORM STREQUAL native)
31 USER_OPTION(
32 ${use_case}_DYNAMIC_MEM_LOAD_ENABLED
33 "Allow dynamically loading model and ifm at runtime (valid for FVP only)"
34 OFF
35 BOOL)
36endif()
alexander3c798932021-03-26 21:42:19 +000037
Kshitij Sisodiaaa5e1f62021-09-24 14:42:08 +010038# For non-native targets, for use with the FVPs only.
39if (${${use_case}_DYNAMIC_MEM_LOAD_ENABLED})
40
41 message(STATUS "NOTE: Dynamic memory load enabled. This ${use_case} application will run on FVP only.")
42
43 if (NOT DEFINED DYNAMIC_MODEL_BASE AND DEFINED DYNAMIC_MODEL_SIZE)
44 message(FATAL_ERROR "${TARGET_PLATFORM} does not support dynamic load for model files.")
45 else()
46 set(${use_case}_COMPILE_DEFS
47 "DYNAMIC_MODEL_BASE=${DYNAMIC_MODEL_BASE};DYNAMIC_MODEL_SIZE=${DYNAMIC_MODEL_SIZE}")
48 endif()
49
50 if (DEFINED DYNAMIC_IFM_BASE AND DEFINED DYNAMIC_IFM_SIZE)
51 string(APPEND ${use_case}_COMPILE_DEFS
52 ";DYNAMIC_IFM_BASE=${DYNAMIC_IFM_BASE};DYNAMIC_IFM_SIZE=${DYNAMIC_IFM_SIZE}")
53 else()
54 message(WARNING "${TARGET_PLATFORM} does not support dynamic load for input tensors.")
55 endif()
56
57 if (DEFINED DYNAMIC_OFM_BASE AND DEFINED DYNAMIC_OFM_SIZE)
58 string(APPEND ${use_case}_COMPILE_DEFS
59 ";DYNAMIC_OFM_BASE=${DYNAMIC_OFM_BASE};DYNAMIC_OFM_SIZE=${DYNAMIC_OFM_SIZE}")
60 else()
61 message(WARNING "${TARGET_PLATFORM} does not support dumping of output tensors.")
62 endif()
63
64else()
65 USER_OPTION(${use_case}_MODEL_TFLITE_PATH "NN models file to be used in the evaluation application. Model files must be in tflite format."
66 ${DEFAULT_MODEL_PATH}
67 FILEPATH)
68
69 # Generate model file
70 generate_tflite_code(
71 MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH}
72 DESTINATION ${SRC_GEN_DIR}
73 )
74endif()