forked from tensorflow/tflite-micro
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for patching cmsis lib to use builtin memcpy and memset
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tensorflow/lite/micro/tools/rpi0_pip_package/patch_cmsis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |