Merge pull request #44406 from advaitjain:remove-cmsis-patching
PiperOrigin-RevId: 339572691 Change-Id: I0a4a0359ff958b1aca1c9a6214b4a871f1fd4c1e
This commit is contained in:
commit
57dd39c5df
@ -83,65 +83,6 @@ patch_kissfft() {
|
|||||||
echo "Finished patching kissfft"
|
echo "Finished patching kissfft"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fixes issues with CMSIS.
|
|
||||||
patch_cmsis() {
|
|
||||||
# See the RFC at https://docs.google.com/document/d/14GRxeVEgSKgKBKAijO7oxnI49nLoTYBFQmPok-rG0cw
|
|
||||||
# for full details on the path qualification changes we have to make below to enable the CMSIS-NN
|
|
||||||
# library source files to compile in an environment like the Arduino IDE that doesn't suppport
|
|
||||||
# custom include paths.
|
|
||||||
# These include changes were found through trial and error while trying to get the Arduino
|
|
||||||
# library compiling with the CMSIS-NN kernels included.
|
|
||||||
|
|
||||||
dspfiles="arm_math.h"
|
|
||||||
dspfiles+="\|arm_math_types.h"
|
|
||||||
dspfiles+="\|arm_math_memory.h"
|
|
||||||
dspfiles+="\|arm_common_tables.h"
|
|
||||||
dspfiles+="\|dsp/basic_math_functions.h"
|
|
||||||
dspfiles+="\|dsp/bayes_functions.h"
|
|
||||||
dspfiles+="\|dsp/complex_math_functions.h"
|
|
||||||
dspfiles+="\|dsp/controller_functions.h"
|
|
||||||
dspfiles+="\|dsp/distance_functions.h"
|
|
||||||
dspfiles+="\|dsp/fast_math_functions.h"
|
|
||||||
dspfiles+="\|dsp/filtering_functions.h"
|
|
||||||
dspfiles+="\|dsp/interpolation_functions.h"
|
|
||||||
dspfiles+="\|dsp/matrix_functions.h"
|
|
||||||
dspfiles+="\|dsp/none.h"
|
|
||||||
dspfiles+="\|dsp/statistics_functions.h"
|
|
||||||
dspfiles+="\|dsp/support_functions.h"
|
|
||||||
dspfiles+="\|dsp/svm_functions.h"
|
|
||||||
dspfiles+="\|dsp/svm_defines.h"
|
|
||||||
dspfiles+="\|dsp/transform_functions.h"
|
|
||||||
dspfiles+="\|dsp/utils.h"
|
|
||||||
dspfiles+="\|dsp/arm_helium_utils.h"
|
|
||||||
find tensorflow/lite/micro/tools/make/downloads/cmsis \
|
|
||||||
\( -name *.c -or -name *.h -or -name *.cpp \) -exec \
|
|
||||||
sed -i "s@#include \"\($dspfiles\)\"@#include \"cmsis/CMSIS/DSP/Include/\1\"@g" {} \;
|
|
||||||
|
|
||||||
nnfiles="arm_nn_tables.h"
|
|
||||||
nnfiles+="\|arm_nnfunctions.h"
|
|
||||||
nnfiles+="\|arm_nnsupportfunctions.h"
|
|
||||||
nnfiles+="\|arm_nn_types.h"
|
|
||||||
find tensorflow/lite/micro/tools/make/downloads/cmsis \
|
|
||||||
\( -name *.c -or -name *.h -or -name *.cpp \) -exec \
|
|
||||||
sed -i "s@#include \"\($nnfiles\)\"@#include \"cmsis/CMSIS/NN/Include/\1\"@g" {} \;
|
|
||||||
|
|
||||||
corefiles="cmsis_compiler.h"
|
|
||||||
find tensorflow/lite/micro/tools/make/downloads/cmsis \
|
|
||||||
\( -name *.c -or -name *.h -or -name *.cpp \) -exec \
|
|
||||||
sed -i "s@#include \"\($corefiles\)\"@#include \"cmsis/CMSIS/Core/Include/\1\"@g" {} \;
|
|
||||||
|
|
||||||
# Until the fix for https://github.com/ARMmbed/mbed-os/issues/12568 is
|
|
||||||
# rolled into Mbed version used on the Arduino IDE, we have to replace
|
|
||||||
# one intrinsic with a patched equivalent.
|
|
||||||
sed -i -E 's@__SXTB16_RORn@__patched_SXTB16_RORn@g' \
|
|
||||||
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mult_nt_t_s8.c
|
|
||||||
|
|
||||||
sed -i -E $'33 a \\\n\\\n// Work around for https://github.com/ARMmbed/mbed-os/issues/12568\\\n__STATIC_FORCEINLINE uint32_t __patched_SXTB16_RORn(uint32_t op1, uint32_t rotate) {\\\n uint32_t result;\\\n __ASM ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) );\\\n return result;\\\n}' \
|
|
||||||
tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mult_nt_t_s8.c
|
|
||||||
|
|
||||||
echo "Finished patching CMSIS"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a header file containing an array with the first 10 images from the
|
# Create a header file containing an array with the first 10 images from the
|
||||||
# CIFAR10 test dataset.
|
# CIFAR10 test dataset.
|
||||||
patch_cifar10_dataset() {
|
patch_cifar10_dataset() {
|
||||||
@ -252,8 +193,6 @@ download_and_extract() {
|
|||||||
patch_kissfft ${dir}
|
patch_kissfft ${dir}
|
||||||
elif [[ ${action} == "patch_cifar10_dataset" ]]; then
|
elif [[ ${action} == "patch_cifar10_dataset" ]]; then
|
||||||
patch_cifar10_dataset ${dir}
|
patch_cifar10_dataset ${dir}
|
||||||
elif [[ ${action} == "patch_cmsis" ]]; then
|
|
||||||
patch_cmsis ${dir}
|
|
||||||
elif [[ ${action} == "build_embarc_mli" ]]; then
|
elif [[ ${action} == "build_embarc_mli" ]]; then
|
||||||
if [[ "${action_param1}" == *.tcf ]]; then
|
if [[ "${action_param1}" == *.tcf ]]; then
|
||||||
cp ${action_param1} ${dir}/hw/arc.tcf
|
cp ${action_param1} ${dir}/hw/arc.tcf
|
||||||
|
@ -6,7 +6,7 @@ ifneq ($(filter cmsis-nn,$(ALL_TAGS)),)
|
|||||||
|
|
||||||
# Setup CMSIS-NN lib and add required header files to microlite lib INCLUDE
|
# Setup CMSIS-NN lib and add required header files to microlite lib INCLUDE
|
||||||
THIRD_PARTY_DOWNLOADS += \
|
THIRD_PARTY_DOWNLOADS += \
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
|
|
||||||
CMSIS_PATH := $(MAKEFILE_DIR)/downloads/cmsis/
|
CMSIS_PATH := $(MAKEFILE_DIR)/downloads/cmsis/
|
||||||
|
|
||||||
@ -89,9 +89,7 @@ ifneq ($(filter cmsis-nn,$(ALL_TAGS)),)
|
|||||||
|
|
||||||
# Cherry-picked list of headers that are needed to compile the CMSIS-NN
|
# Cherry-picked list of headers that are needed to compile the CMSIS-NN
|
||||||
# optimized kernels. We don't include all the possible CMSIS headers because
|
# optimized kernels. We don't include all the possible CMSIS headers because
|
||||||
# of their large number. See the RFC document for more details:
|
# of their large number.
|
||||||
# https://docs.google.com/document/d/14GRxeVEgSKgKBKAijO7oxnI49nLoTYBFQmPok-rG0cw
|
|
||||||
# Note: If you add a .h here, you must update patch_cmsis() in download_and_extract.sh as well.
|
|
||||||
THIRD_PARTY_CC_HDRS += \
|
THIRD_PARTY_CC_HDRS += \
|
||||||
$(CMSIS_PATH)CMSIS/Core/Include/cmsis_compiler.h \
|
$(CMSIS_PATH)CMSIS/Core/Include/cmsis_compiler.h \
|
||||||
$(CMSIS_PATH)CMSIS/DSP/Include/arm_common_tables.h \
|
$(CMSIS_PATH)CMSIS/DSP/Include/arm_common_tables.h \
|
||||||
|
@ -28,7 +28,7 @@ ifneq ($(filter ethos-u,$(ALL_TAGS)),)
|
|||||||
|
|
||||||
# Currently there is a dependency to CMSIS-NN
|
# Currently there is a dependency to CMSIS-NN
|
||||||
THIRD_PARTY_DOWNLOADS += \
|
THIRD_PARTY_DOWNLOADS += \
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
ifeq ($(CMSIS_PATH),)
|
ifeq ($(CMSIS_PATH),)
|
||||||
CMSIS_PATH = $(MAKEFILE_DIR)/downloads/cmsis/
|
CMSIS_PATH = $(MAKEFILE_DIR)/downloads/cmsis/
|
||||||
endif
|
endif
|
||||||
|
@ -10,7 +10,7 @@ APOLLO3_SDK := $(MAKEFILE_DIR)/downloads/$(AM_SDK_DEST)
|
|||||||
GCC_ARM := $(MAKEFILE_DIR)/downloads/gcc_embedded/
|
GCC_ARM := $(MAKEFILE_DIR)/downloads/gcc_embedded/
|
||||||
|
|
||||||
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
$(eval $(call add_third_party_download,$(AM_SDK_URL),$(AM_SDK_MD5),$(AM_SDK_DEST),patch_am_sdk))
|
$(eval $(call add_third_party_download,$(AM_SDK_URL),$(AM_SDK_MD5),$(AM_SDK_DEST),patch_am_sdk))
|
||||||
|
|
||||||
ifeq ($(findstring sparkfun,$(TARGET)), sparkfun)
|
ifeq ($(findstring sparkfun,$(TARGET)), sparkfun)
|
||||||
|
@ -3,7 +3,7 @@ TARGET_ARCH := cortex-m3
|
|||||||
TARGET_TOOLCHAIN_PREFIX := arm-none-eabi-
|
TARGET_TOOLCHAIN_PREFIX := arm-none-eabi-
|
||||||
|
|
||||||
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
$(eval $(call add_third_party_download,$(STM32_BARE_LIB_URL),$(STM32_BARE_LIB_MD5),stm32_bare_lib,))
|
$(eval $(call add_third_party_download,$(STM32_BARE_LIB_URL),$(STM32_BARE_LIB_MD5),stm32_bare_lib,))
|
||||||
|
|
||||||
PLATFORM_FLAGS = \
|
PLATFORM_FLAGS = \
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Settings for mbed platforms.
|
# Settings for mbed platforms.
|
||||||
ifeq ($(TARGET), mbed)
|
ifeq ($(TARGET), mbed)
|
||||||
TARGET_ARCH := cortex-m4
|
TARGET_ARCH := cortex-m4
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
$(eval $(call add_third_party_download,$(CUST_CMSIS_URL),$(CUST_CMSIS_MD5),CMSIS_ext,))
|
$(eval $(call add_third_party_download,$(CUST_CMSIS_URL),$(CUST_CMSIS_MD5),CMSIS_ext,))
|
||||||
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
||||||
endif
|
endif
|
||||||
|
@ -6,7 +6,7 @@ TARGET_TOOLCHAIN_PREFIX := arm-none-eabi-
|
|||||||
TARGET_TOOLCHAIN_ROOT := $(TENSORFLOW_ROOT)$(MAKEFILE_DIR)/downloads/gcc_embedded/bin/
|
TARGET_TOOLCHAIN_ROOT := $(TENSORFLOW_ROOT)$(MAKEFILE_DIR)/downloads/gcc_embedded/bin/
|
||||||
|
|
||||||
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
|
||||||
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,patch_cmsis))
|
$(eval $(call add_third_party_download,$(CMSIS_URL),$(CMSIS_MD5),cmsis,))
|
||||||
$(eval $(call add_third_party_download,$(STM32_BARE_LIB_URL),$(STM32_BARE_LIB_MD5),stm32_bare_lib,))
|
$(eval $(call add_third_party_download,$(STM32_BARE_LIB_URL),$(STM32_BARE_LIB_MD5),stm32_bare_lib,))
|
||||||
|
|
||||||
# TODO(b/161478030) : change - Wno - vla to - Wvla and remove - Wno-shadow once
|
# TODO(b/161478030) : change - Wno - vla to - Wvla and remove - Wno-shadow once
|
||||||
|
Loading…
Reference in New Issue
Block a user