From 206e5bbdb409bff2ef6d9f71a74d64f5d504b76c Mon Sep 17 00:00:00 2001 From: Fredrik Knutsson Date: Tue, 25 Jun 2019 09:46:23 +0200 Subject: [PATCH] Adding instructions on how to run CMSIS-NN opt kernels using mbed Change-Id: I31812627f95de1f8dea5704d5880cc1ffcd132cc --- tensorflow/lite/experimental/micro/README.md | 39 +++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tensorflow/lite/experimental/micro/README.md b/tensorflow/lite/experimental/micro/README.md index b8ed89d552c..102d1a00aa2 100644 --- a/tensorflow/lite/experimental/micro/README.md +++ b/tensorflow/lite/experimental/micro/README.md @@ -366,17 +366,46 @@ optimizations and link it with the microlite lib. To utilize the CMSIS-NN optimized kernels, choose your target, e.g. Bluepill, and build with: -make -f tensorflow/lite/experimental/micro/tools/make/Makefile TAGS=cmsis-nn -TARGET=bluepill test +``` +make -f tensorflow/lite/experimental/micro/tools/make/Makefile TAGS=cmsis-nn TARGET=bluepill test +``` That will build the microlite lib including CMSIS-NN optimized kernels based on the version downloaded by 'download_dependencies.sh', so make sure you have run this script. If you want to utilize another version of CMSIS, clone it to a custom location run the following command: -make -f tensorflow/lite/experimental/micro/tools/make/Makefile -CMSIS_PATH= TAGS=cmsis-nn TARGET=bluepill test (--- Under -development, it will build, but test will fail ---) +``` +make -f tensorflow/lite/experimental/micro/tools/make/Makefile CMSIS_PATH= TAGS=cmsis-nn TARGET=bluepill test +``` + +To test the optimized kernel(s) on your target platform using mbed (depthwise +conv in this example), follow these steps: + +1. Clone CMSIS to a custom location () url: + https://github.com/ARM-software/CMSIS_5.git Make sure you're on the + development branch. +2. Generate the project for depthwise conv mbed test: +``` +make -f tensorflow/lite/experimental/micro/tools/make/Makefile TAGS=cmsis-nn CMSIS_PATH= generate_depthwise_conv_test_mbed_project +``` +3. Go to the generated mbed folder: +``` +cd tensorflow/lite/experimental/micro/tools/make/gen/linux_x86_64/prj/depthwise_conv_test/mbed +``` +4. Follow the steps in README_MBED.md to setup the environment. Or simply do: + ``` +mbed config root . +mbed deploy +python -c 'import fileinput, glob; +for filename in glob.glob("mbed-os/tools/profiles/*.json"): + for line in fileinput.input(filename, inplace=True): + print(line.replace("\"-std=gnu++98\"","\"-std=gnu++11\", \"-fpermissive\""))' +``` +7. Compile and flash. The 'auto' flag requires your target to be plugged in. +``` +mbed compile -m auto -t GCC_ARM -f --source . --source /CMSIS/NN/Include --source /CMSIS/NN/Source/ConvolutionFunctions --source /CMSIS/DSP/Include --source /CMSIS/Core/Include -j8 +``` ## Goals