diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/cmake/common_user_options.cmake | 8 | ||||
-rw-r--r-- | scripts/cmake/tensorflow.cmake | 26 | ||||
-rw-r--r-- | scripts/make/cortex_m_ethos_eval_makefile.inc | 149 |
3 files changed, 14 insertions, 169 deletions
diff --git a/scripts/cmake/common_user_options.cmake b/scripts/cmake/common_user_options.cmake index afc5386..9a13287 100644 --- a/scripts/cmake/common_user_options.cmake +++ b/scripts/cmake/common_user_options.cmake @@ -84,14 +84,6 @@ if (NOT TARGET_PLATFORM STREQUAL native) "${DEPENDENCY_ROOT_DIR}/cmsis" PATH) - if (CMAKE_BUILD_TYPE STREQUAL Debug) - # For use with Arm compiler: - USER_OPTION(ARMCLANG_DEBUG_DWARF_LEVEL - "Dwarf conformance level for armclang toolchain" - "4" # Default = 4 (Arm-DS etc). For model debugger specify "3" - STRING) - endif() - # If we need NPU libraries: if (ETHOS_U_NPU_ENABLED) USER_OPTION(ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH diff --git a/scripts/cmake/tensorflow.cmake b/scripts/cmake/tensorflow.cmake index 9d72405..284c70a 100644 --- a/scripts/cmake/tensorflow.cmake +++ b/scripts/cmake/tensorflow.cmake @@ -45,24 +45,19 @@ set(TENSORFLOW_LITE_MICRO_PATH "${TENSORFLOW_SRC_PATH}/tensorflow/lite/micro") set(TENSORFLOW_LITE_MICRO_GENDIR ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/) set(TENSORFLOW_LITE_MICRO_PLATFORM_LIB_NAME "libtensorflow-microlite.a") -set(ETHOS_EVAL_TARGET_MAKEFILE_INC ${CMAKE_CURRENT_SOURCE_DIR}/scripts/make/cortex_m_ethos_eval_makefile.inc) - if (TARGET_PLATFORM STREQUAL native) set(TENSORFLOW_LITE_MICRO_TARGET "linux") set(TENSORFLOW_LITE_MICRO_TARGET_ARCH x86_64) else() - set(TENSORFLOW_LITE_MICRO_TARGET "cortex_m_ethos_eval") + set(TENSORFLOW_LITE_MICRO_TARGET "cortex_m_generic") set(TENSORFLOW_LITE_MICRO_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}${CPU_FEATURES}) if(ETHOS_U_NPU_ENABLED) # Arm Ethos-U55 NPU is the co-processor for ML workload: set(TENSORFLOW_LITE_MICRO_CO_PROCESSOR "ethos_u") + string(TOLOWER ${ETHOS_U_NPU_ID} ETHOSU_ARCH) endif() set(TENSORFLOW_LITE_MICRO_OPTIMIZED_KERNEL "cmsis_nn") - - # Copy over the target helper (cortex_m_ethos_eval) - file(COPY ${ETHOS_EVAL_TARGET_MAKEFILE_INC} - DESTINATION ${TENSORFLOW_LITE_MICRO_PATH}/tools/make/targets/) endif() if (TENSORFLOW_LITE_MICRO_CLEAN_DOWNLOADS) @@ -92,11 +87,12 @@ add_custom_target(tensorflow_build ALL TARGET=${TENSORFLOW_LITE_MICRO_TARGET} TARGET_ARCH=${TENSORFLOW_LITE_MICRO_TARGET_ARCH} BUILD_TYPE=${TENSORFLOW_LITE_MICRO_BUILD_TYPE} - ETHOSU_ARCH=${ETHOSU_ARCH} - ETHOSU_DRIVER_PATH=${ETHOS_U_NPU_DRIVER_SRC_PATH} CMSIS_PATH=${CMSIS_SRC_PATH} # Conditional arguments - $<$<BOOL:${ARMCLANG_DEBUG_DWARF_LEVEL}>:ARMCLANG_DEBUG_DWARF_LEVEL=${ARMCLANG_DEBUG_DWARF_LEVEL}> + $<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_ARCH=${ETHOSU_ARCH}> + $<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_DRIVER_PATH=${ETHOS_U_NPU_DRIVER_SRC_PATH}> + $<$<BOOL:${ETHOS_U_NPU_ENABLED}>:ETHOSU_DRIVER_LIBS=$<TARGET_FILE:ethosu_core_driver>> + $<$<BOOL:${TENSORFLOW_LITE_MICRO_CORE_OPTIMIZATION_LEVEL}>:CORE_OPTIMIZATION_LEVEL=${TENSORFLOW_LITE_MICRO_CORE_OPTIMIZATION_LEVEL}> $<$<BOOL:${TENSORFLOW_LITE_MICRO_KERNEL_OPTIMIZATION_LEVEL}>:KERNEL_OPTIMIZATION_LEVEL=${TENSORFLOW_LITE_MICRO_KERNEL_OPTIMIZATION_LEVEL}> $<$<BOOL:${TENSORFLOW_LITE_MICRO_OPTIMIZED_KERNEL}>:OPTIMIZED_KERNEL_DIR=${TENSORFLOW_LITE_MICRO_OPTIMIZED_KERNEL}> @@ -116,7 +112,13 @@ add_custom_target(tensorflow_build ALL # Create library -add_library(tensorflow-lite-micro STATIC IMPORTED) + +set(TENSORFLOW_LITE_MICRO_TARGET tensorflow-lite-micro) +add_library(${TENSORFLOW_LITE_MICRO_TARGET} STATIC IMPORTED) + +if(ETHOS_U_NPU_ENABLED) + add_dependencies(tensorflow_build ethosu_core_driver) +endif() add_dependencies(tensorflow-lite-micro tensorflow_build) @@ -129,4 +131,4 @@ target_include_directories(tensorflow-lite-micro target_compile_definitions(tensorflow-lite-micro INTERFACE - TF_LITE_STATIC_MEMORY) + TF_LITE_STATIC_MEMORY)
\ No newline at end of file diff --git a/scripts/make/cortex_m_ethos_eval_makefile.inc b/scripts/make/cortex_m_ethos_eval_makefile.inc deleted file mode 100644 index 234534a..0000000 --- a/scripts/make/cortex_m_ethos_eval_makefile.inc +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright (c) 2021 Arm Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Generic Makefile target for ARM Cortex M builds. -# For more info see: tensorflow/lite/micro/cortex_m_generic/README.md -ifeq ($(TARGET),$(filter $(TARGET), cortex_m_ethos_eval)) - FLOAT := soft - GCC_TARGET_ARCH := $(TARGET_ARCH) - - ifeq ($(TARGET_ARCH), cortex-m0) - CORE=M0 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M0 - - else ifeq ($(TARGET_ARCH), cortex-m3) - CORE=M3 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M3 - - else ifeq ($(TARGET_ARCH), cortex-m33) - CORE=M33 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M33 - TARGET_SPECIFIC_FLAGS += -D__DSP_PRESENT=1 -D__FPU_PRESENT=1 -D__VTOR_PRESENT=1 -D__FPU_USED=1 - FLOAT=hard - - else ifeq ($(TARGET_ARCH), cortex-m33+nodsp) - CORE=M33 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M33.no_dsp.no_fp - - else ifeq ($(TARGET_ARCH), cortex-m4) - CORE=M4 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M4.no_fp - GCC_TARGET_ARCH := cortex-m4+nofp - - else ifeq ($(TARGET_ARCH), cortex-m4+fp) - CORE=M4 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M4 - TARGET_SPECIFIC_FLAGS += -D__FPU_PRESENT=1 - FLOAT=hard - GCC_TARGET_ARCH := cortex-m4 - - else ifeq ($(TARGET_ARCH), cortex-m55) - CORE=M55 - ARM_LDFLAGS := -Wl,--cpu=8.1-M.Main.mve.fp - TARGET_SPECIFIC_FLAGS += -D__DSP_PRESENT=1 -D__FPU_PRESENT=1 - FLOAT=hard - - else ifeq ($(TARGET_ARCH), cortex-m55+nodsp+nofp) - CORE=M55 - ARM_LDFLAGS := -Wl,--cpu=8.1-M.Main.mve.no_dsp.no_fp - - else ifeq ($(TARGET_ARCH), cortex-m55+nofp) - CORE=M55 - ARM_LDFLAGS := -Wl,--cpu=8.1-M.Main.mve.no_fp - TARGET_SPECIFIC_FLAGS += -D__DSP_PRESENT=1 - - else ifeq ($(TARGET_ARCH), cortex-m7) - CORE=M7 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M7.no_fp - GCC_TARGET_ARCH := cortex-m7+nofp - - else ifeq ($(TARGET_ARCH), cortex-m7+fp) - CORE=M7 - ARM_LDFLAGS := -Wl,--cpu=Cortex-M7 - FLOAT=hard - GCC_TARGET_ARCH := cortex-m7 - - else - $(error "TARGET_ARCH=$(TARGET_ARCH) is not supported") - endif - - ifneq ($(filter cortex-m55%,$(TARGET_ARCH)),) - # soft-abi=soft disables MVE - use softfp instead for M55. - ifeq ($(FLOAT),soft) - FLOAT=softfp - endif - endif - - # Toolchain specfic flags - ifeq ($(TOOLCHAIN), armclang) - CXX_TOOL := armclang - CC_TOOL := armclang - AR_TOOL := armar - LD := armlink - - FLAGS_ARMC = \ - --target=arm-arm-none-eabi \ - -mcpu=$(TARGET_ARCH) - - # For debug, include specific dwarf format symbols - ifeq ($(BUILD_TYPE), debug) - ifneq ($(ARMCLANG_DEBUG_DWARF_LEVEL),) - FLAGS_ARMC += -gdwarf-$(ARMCLANG_DEBUG_DWARF_LEVEL) - endif - endif - - CXXFLAGS += $(FLAGS_ARMC) - CCFLAGS += $(FLAGS_ARMC) - LDFLAGS += $(ARM_LDFLAGS) - - # Arm Compiler will not link the Math library (see below), therefore we're filtering it out. - # See Fatal error: L6450U: Cannot find library m: - # "Arm Compiler is designed to run in a bare metal environment, - # and automatically includes implementations of these functions, - # and so no such flag is necessary." - # https://developer.arm.com/documentation/100891/0611/troubleshooting/general-troubleshooting-advice - MICROLITE_LIBS := $(filter-out -lm,$(MICROLITE_LIBS)) - - else ifeq ($(TOOLCHAIN), gcc) - TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- - - FLAGS_GCC = -mcpu=$(GCC_TARGET_ARCH) -mfpu=auto - CXXFLAGS += $(FLAGS_GCC) - CCFLAGS += $(FLAGS_GCC) - - else - $(error "TOOLCHAIN=$(TOOLCHAIN) is not supported.") - endif - - - PLATFORM_FLAGS = \ - -DTF_LITE_MCU_DEBUG_LOG \ - -mthumb \ - -mfloat-abi=$(FLOAT) \ - -funsigned-char \ - -mlittle-endian \ - -Wno-type-limits \ - -Wno-unused-private-field \ - -fomit-frame-pointer \ - -MD \ - -DCPU_CORTEX_$(CORE)=1 \ - -DETHOSU_ARCH=${ETHOSU_ARCH} \ - $(TARGET_SPECIFIC_FLAGS) - - # Common + C/C++ flags - CXXFLAGS += $(PLATFORM_FLAGS) - CCFLAGS += $(PLATFORM_FLAGS) - -endif |