blob: 13c88d21a7d4d1356f84cfd6b8f91682dfce92d6 [file] [log] [blame]
Kshitij Sisodiab59ba682021-11-23 17:19:52 +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
18#----------------------------------------------------------------------------
19# This file should contain all the common user options for the application
20# For use case specific options, see individual usecase.cmake files under
21# each example use case.
22#----------------------------------------------------------------------------
23
24if (NOT DEFINED USER_OPTIONS_INCLUDED)
25 set(USER_OPTIONS_INCLUDED ON)
26else()
27 return()
28endif()
29
30message(STATUS "Assessing common user options...")
31
32set(CMAKE_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}/toolchains)
33set(DEPENDENCY_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../dependencies)
34include(${CMAKE_CURRENT_LIST_DIR}/util_functions.cmake)
35
36USER_OPTION(LOG_LEVEL "Log level for the application"
37 LOG_LEVEL_INFO
38 STRING)
39
40USER_OPTION(TENSORFLOW_SRC_PATH "Path to the root of the tensor flow directory"
41 "${DEPENDENCY_ROOT_DIR}/tensorflow"
42 PATH)
43
44USER_OPTION(TARGET_PLATFORM "Target platform to execute evaluation application: mps3, simple_platform, native"
45 mps3
46 STRING)
47
48USER_OPTION(TARGET_SUBSYSTEM "Specify platform target subsystem: sse-300 or none"
49 sse-300
50 STRING)
51
52if (TARGET_PLATFORM STREQUAL native)
53 set(NPU_AVAILABLE OFF)
54else()
55 set(NPU_AVAILABLE ON)
56endif()
57
58USER_OPTION(ETHOS_U_NPU_ENABLED "If Arm Ethos-U NPU is enabled in the target system."
59 ${NPU_AVAILABLE}
60 BOOL)
61
62USER_OPTION(USE_CASE_BUILD "Optional. Defines the use-case to build from the available sources. By default, all use-cases are built."
63 all
64 STRING)
65
66USER_OPTION(CPU_PROFILE_ENABLED "Output CPU performance profiling information. Should be used only for MPS3 board."
67 OFF
68 BOOL)
69
70USER_OPTION(TENSORFLOW_LITE_MICRO_BUILD_TYPE "TensorFlow Lite Mirco build type (release/debug etc.)"
71 $<IF:$<CONFIG:RELEASE>,release_with_logs,debug>
72 STRING)
73
74USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_DOWNLOADS "Select if TPIP downloads should be cleaned before each build."
75 OFF
76 BOOL)
77
78USER_OPTION(TENSORFLOW_LITE_MICRO_CLEAN_BUILD "Select if clean target should be added to a list of targets"
79 ON
80 BOOL)
81
82if (NOT TARGET_PLATFORM STREQUAL native)
83
84 USER_OPTION(CMSIS_SRC_PATH
85 "Path to CMSIS-5 sources"
86 "${DEPENDENCY_ROOT_DIR}/cmsis"
87 PATH)
88
89 if (CMAKE_BUILD_TYPE STREQUAL Debug)
90 # For use with Arm compiler:
91 USER_OPTION(ARMCLANG_DEBUG_DWARF_LEVEL
92 "Dwarf conformance level for armclang toolchain"
93 "4" # Default = 4 (Arm-DS etc). For model debugger specify "3"
94 STRING)
95 endif()
96
97 # If we need NPU libraries:
98 if (ETHOS_U_NPU_ENABLED)
99 USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH
100 "Path to Ethos-U NPU timing adapter sources"
101 "${DEPENDENCY_ROOT_DIR}/core-software/drivers/timing_adapter"
102 PATH
103 )
104
105 USER_OPTION(ETHOS_U_NPU_DRIVER_SRC_PATH
106 "Path to Ethos-U NPU core driver sources"
107 "${DEPENDENCY_ROOT_DIR}/core-driver"
108 PATH
109 )
110
111 USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
112 "U55"
113 STRING)
114
115 if ((ETHOS_U_NPU_ID STREQUAL U55) OR (ETHOS_U_NPU_ID STREQUAL U65))
116 if (ETHOS_U_NPU_ID STREQUAL U55)
117 set(DEFAULT_NPU_MEM_MODE "Shared_Sram")
118 set(DEFAULT_NPU_CONFIG_ID "H128")
119 elseif(ETHOS_U_NPU_ID STREQUAL U65)
120 set(DEFAULT_NPU_MEM_MODE "Dedicated_Sram")
121 set(DEFAULT_NPU_CONFIG_ID "Y256")
122 endif()
123 else ()
124 message(FATAL_ERROR "Non compatible Ethos-U NPU processor ${ETHOS_U_NPU_ID}")
125 endif ()
126
127 USER_OPTION(ETHOS_U_NPU_MEMORY_MODE "Specifies the memory mode used in the Vela command."
128 "${DEFAULT_NPU_MEM_MODE}"
129 STRING)
130
131 USER_OPTION(ETHOS_U_NPU_CONFIG_ID "Specifies the configuration ID for the NPU."
132 "${DEFAULT_NPU_CONFIG_ID}"
133 STRING)
134
135 if (ETHOS_U_NPU_ID STREQUAL U55)
136 set(DEFAULT_TA_CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_DIR}/timing_adapter/ta_config_u55_high_end.cmake")
137 else ()
138 set(DEFAULT_TA_CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_DIR}/timing_adapter/ta_config_u65_high_end.cmake")
139 endif ()
140
141 USER_OPTION(TA_CONFIG_FILE "Path to the timing adapter configuration file"
142 ${DEFAULT_TA_CONFIG_FILE_PATH}
143 FILEPATH)
144 endif()
145endif()
146
147if (TARGET_PLATFORM STREQUAL mps3)
148 message(STATUS "Platform: MPS3 FPGA Prototyping Board or FVP")
149 set(DEFAULT_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake)
150elseif (TARGET_PLATFORM STREQUAL simple_platform)
151 message(STATUS "Platform: Simple platform with minimal peripherals")
152 set(DEFAULT_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake)
153elseif (TARGET_PLATFORM STREQUAL native)
154 message(STATUS "Platform: Native (Linux based x86_64/aarch64 system)")
155 set(DEFAULT_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/native-gcc.cmake)
156else ()
157 message(FATAL_ERROR "Invalid platform specified: ${TARGET_PLATFORM}")
158endif ()
159
160if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
161 set(CMAKE_TOOLCHAIN_FILE ${DEFAULT_TOOLCHAIN_FILE}
162 CACHE FILEPATH "Toolchain file")
163endif()
164message(STATUS "Using CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")