diff --git a/tensorflow/lite/micro/tools/rpi0_pip_package/build_pip_package.sh b/tensorflow/lite/micro/tools/rpi0_pip_package/build_pip_package.sh index 883f6c6a82b..c04c779de65 100755 --- a/tensorflow/lite/micro/tools/rpi0_pip_package/build_pip_package.sh +++ b/tensorflow/lite/micro/tools/rpi0_pip_package/build_pip_package.sh @@ -21,7 +21,7 @@ TF_DIR=$ROOT_DIR/tensorflow TFLITE_DIR=$TF_DIR/lite TFLM_DIR=$TFLITE_DIR/micro -export PACKAGE_VERSION=1.0.0 +export PACKAGE_VERSION=1.1.0 PYTHON=python3.7 BUILD_DIR=/tmp/tflite_micro_runtime_build GIT_HASH=`git rev-parse HEAD` diff --git a/tensorflow/lite/micro/tools/rpi0_pip_package/install_tflite_micro.sh b/tensorflow/lite/micro/tools/rpi0_pip_package/install_tflite_micro.sh index 4168dd8ba86..3b7cadc5c9b 100755 --- a/tensorflow/lite/micro/tools/rpi0_pip_package/install_tflite_micro.sh +++ b/tensorflow/lite/micro/tools/rpi0_pip_package/install_tflite_micro.sh @@ -16,5 +16,6 @@ $TFLM_DIR/tools/make/flatbuffers_download.sh $TFLM_DIR/tools/make/downloads $TFLM_DIR/tools/make/ruy_download.sh $TFLM_DIR/tools/make/downloads $TFLM_DIR/tools/make/ext_libs/cmsis_download.sh $TFLM_DIR/tools/make/downloads +python3 $SCRIPT_DIR/patch_cmsis.py diff --git a/tensorflow/lite/micro/tools/rpi0_pip_package/patch_cmsis.py b/tensorflow/lite/micro/tools/rpi0_pip_package/patch_cmsis.py new file mode 100644 index 00000000000..946a3786a3e --- /dev/null +++ b/tensorflow/lite/micro/tools/rpi0_pip_package/patch_cmsis.py @@ -0,0 +1,24 @@ +import os +import sys + +curdir = os.path.dirname(os.path.abspath(__file__)) +cmsis_arm_math_types_h_path = f'{curdir}/../make/downloads/cmsis/CMSIS/DSP/Include/arm_math_types.h' + + +with open(cmsis_arm_math_types_h_path, 'r') as fp: + data = fp.read() + +if '#define memset __builtin_memset' in data: + sys.exit() + + +# Ensure the builtin memset and memcpy +# are used. This greatly reduce the overhead of the kernels. +patch_data = '#define _ARM_MATH_TYPES_H_\n\n' +patch_data += '#define memset __builtin_memset\n' +patch_data += '#define memcpy __builtin_memcpy\n\n' + +data = data.replace('#define _ARM_MATH_TYPES_H_', patch_data) + +with open(cmsis_arm_math_types_h_path, 'w') as fp: + fp.write(data) \ No newline at end of file