cmsis-nn -> cmsis_nn

This commit is contained in:
Advait Jain 2021-01-11 16:08:35 -08:00
parent 5035c862a9
commit 7548f94800
20 changed files with 31 additions and 35 deletions

View File

@ -31,18 +31,18 @@ Building with arm-gcc
```
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m7 microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m7 OPTIMIZED_KERNEL_DIR=cmsis-nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m7 OPTIMIZED_KERNEL_DIR=cmsis_nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4 OPTIMIZED_KERNEL_DIR=cmsis-nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4+fp OPTIMIZED_KERNEL_DIR=cmsis-nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4 OPTIMIZED_KERNEL_DIR=cmsis_nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4+fp OPTIMIZED_KERNEL_DIR=cmsis_nn microlite
```
Building with armclang
```
make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=armclang TARGET=cortex_m_generic TARGET_ARCH=cortex-m55 microlite
make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=armclang TARGET=cortex_m_generic TARGET_ARCH=cortex-m55 OPTIMIZED_KERNEL_DIR=cmsis-nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=armclang TARGET=cortex_m_generic TARGET_ARCH=cortex-m55+nofp OPTIMIZED_KERNEL_DIR=cmsis-nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=armclang TARGET=cortex_m_generic TARGET_ARCH=cortex-m55 OPTIMIZED_KERNEL_DIR=cmsis_nn microlite
make -f tensorflow/lite/micro/tools/make/Makefile TOOLCHAIN=armclang TARGET=cortex_m_generic TARGET_ARCH=cortex-m55+nofp OPTIMIZED_KERNEL_DIR=cmsis_nn microlite
```
The Tensorflow Lite Micro makefiles download a specific version of the arm-gcc
@ -55,11 +55,11 @@ option to the Makefile:
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4+fp TARGET_TOOLCHAIN_ROOT=/path/to/arm-gcc/ microlite
```
Similarly, `OPTIMIZED_KERNEL_DIR=cmsis-nn` downloads a specific version of CMSIS to
Similarly, `OPTIMIZED_KERNEL_DIR=cmsis_nn` downloads a specific version of CMSIS to
tensorflow/lite/micro/tools/make/downloads/cmsis. While this is the only version
that is regularly tested, you can use your own version of CMSIS as well by
providing `CMSIS_PATH` to the Makefile:
```
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4+fp OPTIMIZED_KERNEL_DIR=cmsis-nn CMSIS_PATH=/path/to/own/cmsis microlite
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m4+fp OPTIMIZED_KERNEL_DIR=cmsis_nn CMSIS_PATH=/path/to/own/cmsis microlite
```

View File

@ -266,7 +266,7 @@ The following command will download the required dependencies and then compile a
binary for the SparkFun Edge:
```
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=sparkfun_edge TAGS="cmsis-nn" micro_speech_bin
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=sparkfun_edge TAGS="cmsis_nn" micro_speech_bin
```
The binary will be created in the following location:

View File

@ -1,6 +1,6 @@
# Info
To use CMSIS-NN optimized kernels instead of reference kernel add TAGS=cmsis-nn
To use CMSIS-NN optimized kernels instead of reference kernel add TAGS=cmsis_nn
to the make line. Some micro architectures have optimizations (M4 or higher),
others don't. The kernels that doesn't have optimization for a certain micro
architecture fallback to use TFLu reference kernels.
@ -14,7 +14,7 @@ more details, please read
A simple way to compile a binary with CMSIS-NN optimizations.
```
make -f tensorflow/lite/micro/tools/make/Makefile TAGS=cmsis-nn \
make -f tensorflow/lite/micro/tools/make/Makefile TAGS=cmsis_nn \
TARGET=sparkfun_edge person_detection_int8_bin
```
@ -24,7 +24,7 @@ Using mbed you'll be able to compile for the many different targets supported by
mbed. Here's an example on how to do that. Start by generating an mbed project.
```
make -f tensorflow/lite/micro/tools/make/Makefile TAGS=cmsis-nn \
make -f tensorflow/lite/micro/tools/make/Makefile TAGS=cmsis_nn \
generate_person_detection_mbed_project
```

View File

@ -134,21 +134,21 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
RuntimeShape input_shape = GetTensorShape(input);
RuntimeShape output_shape = GetTensorShape(output);
// Initialize cmsis-nn input dimensions
// Initialize cmsis_nn input dimensions
cmsis_nn_dims input_dims;
input_dims.n = MatchingDim(input_shape, 0, output_shape, 0);
input_dims.h = input->dims->data[1];
input_dims.w = input->dims->data[2];
input_dims.c = input_shape.Dims(3);
// Initialize cmsis-nn filter dimensions
// Initialize cmsis_nn filter dimensions
cmsis_nn_dims filter_dims;
filter_dims.n = output_shape.Dims(3);
filter_dims.h = filter->dims->data[1];
filter_dims.w = filter->dims->data[2];
filter_dims.c = input_dims.c;
// Initialize cmsis-nn output dimensions
// Initialize cmsis_nn output dimensions
cmsis_nn_dims output_dims;
output_dims.n = input_dims.n;
output_dims.h = output->dims->data[1];
@ -177,7 +177,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
data->output_zero_point = output->params.zero_point;
if (input->type == kTfLiteInt8) {
// Initialize cmsis-nn convolution parameters
// Initialize cmsis_nn convolution parameters
cmsis_nn_conv_params conv_params;
conv_params.input_offset = -input->params.zero_point;
conv_params.output_offset = output->params.zero_point;
@ -255,7 +255,7 @@ TfLiteStatus EvalQuantizedPerChannel(
// implementation when dilation is supported in the optimized implementation
// by CMSIS-NN.
if (conv_params.dilation.h == 1 && conv_params.dilation.w == 1) {
// Initialize cmsis-nn convolution parameters
// Initialize cmsis_nn convolution parameters
conv_params.input_offset = -data.input_zero_point;
conv_params.output_offset = data.output_zero_point;
conv_params.stride.h = params->stride_height;
@ -265,7 +265,7 @@ TfLiteStatus EvalQuantizedPerChannel(
conv_params.activation.min = data.output_activation_min;
conv_params.activation.max = data.output_activation_max;
// Initialize cmsis-nn per channel quantization parameters
// Initialize cmsis_nn per channel quantization parameters
cmsis_nn_per_channel_quant_params quant_params;
quant_params.multiplier =
const_cast<int32_t*>(data.per_channel_output_multiplier);
@ -288,7 +288,7 @@ TfLiteStatus EvalQuantizedPerChannel(
TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_depth);
}
// Initialize cmsis-nn dimensions
// Initialize cmsis_nn dimensions
// Input
cmsis_nn_dims input_dims;
input_dims.n = batch_size;
@ -317,14 +317,14 @@ TfLiteStatus EvalQuantizedPerChannel(
output_dims.w = output_shape.Dims(2);
output_dims.c = output_depth;
// Initialize cmsis-nn context
// Initialize cmsis_nn context
cmsis_nn_context ctx;
ctx.buf = nullptr;
ctx.size = 0;
if (data.buffer_idx > -1) {
ctx.buf = context->GetScratchBuffer(context, data.buffer_idx);
// Note: ctx.size is currently not used in cmsis-nn.
// Note: ctx.size is currently not used in cmsis_nn.
// The buffer should be allocated in the Prepare function through
// arm_convolve_wrapper_s8_get_buffer_size
}

View File

@ -71,7 +71,7 @@ TfLiteRegistration Register_FULLY_CONNECTED();
// part of the build. As a result, we use defined(ARDUINO) as proxy for the
// CMSIS kernels for this one special case.
// Returns a TfLiteRegistration struct for cmsis-nn kernel variant that only
// Returns a TfLiteRegistration struct for cmsis_nn kernel variant that only
// supports int8.
TfLiteRegistration Register_FULLY_CONNECTED_INT8();

View File

@ -27,7 +27,7 @@ pwd
echo "Starting to run micro tests at `date`"
make -f tensorflow/lite/micro/tools/make/Makefile clean_downloads DISABLE_DOWNLOADS=true
make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis-nn clean DISABLE_DOWNLOADS=true
make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn clean DISABLE_DOWNLOADS=true
if [ -d tensorflow/lite/micro/tools/make/downloads ]; then
echo "ERROR: Downloads directory should not exist, but it does."
exit 1
@ -80,5 +80,4 @@ tensorflow/lite/micro/tools/ci_build/test_arduino.sh
echo "Running cortex_m_generic tests at `date`"
tensorflow/lite/micro/tools/ci_build/test_cortex_m_generic.sh
echo "Finished all micro tests at `date`"

View File

@ -28,7 +28,7 @@ source tensorflow/lite/micro/tools/ci_build/helper_functions.sh
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
TARGET=arduino
OPTIMIZED_KERNEL_DIR=cmsis-nn
OPTIMIZED_KERNEL_DIR=cmsis_nn
# TODO(b/143715361): parallel builds do not work with generated files right now.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile \

View File

@ -25,7 +25,7 @@ cd "${ROOT_DIR}"
source tensorflow/lite/micro/tools/ci_build/helper_functions.sh
TARGET=cortex_m_generic
OPTIMIZED_KERNEL_DIR=cmsis-nn
OPTIMIZED_KERNEL_DIR=cmsis_nn
# TODO(b/143715361): downloading first to allow for parallel builds.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=${OPTIMIZED_KERNEL_DIR} TARGET=${TARGET} TARGET_ARCH=cortex-m4 third_party_downloads

View File

@ -33,4 +33,4 @@ readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} build
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} OPTIMIZED_KERNEL_DIR=cmsis-nn build
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TARGET=${TARGET} OPTIMIZED_KERNEL_DIR=cmsis_nn build

View File

@ -19,7 +19,7 @@
set -e
TARGET=stm32f4
OPTIMIZED_KERNEL_DIR=cmsis-nn
OPTIMIZED_KERNEL_DIR=cmsis_nn
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR=${SCRIPT_DIR}/../../../../..
cd "${ROOT_DIR}"

View File

@ -25,6 +25,7 @@ MAKEFILE_DIR := tensorflow/lite/micro/tools/make
# make -f tensorflow/lite/micro/tools/make/Makefile PARSE_THIRD_PARTY=true TARGET=apollo3evb generate_hello_world_make_project
PARSE_THIRD_PARTY :=
# Pull in some convenience functions.
include $(MAKEFILE_DIR)/helper_functions.inc
@ -101,15 +102,11 @@ MICROLITE_LIBS := -lm
#
# We apply the following transformations (via the tr command):
# 1. Convert to uppercase (TARGET=xtensa -> -DXTENSA)
# 2. (Temporarily) Replace dash with underscore (OPTIMIZED_KERNEL_DIR=cmsis-nn -> -DCMSIS_NN)
#
# Transformation 2 is needed because CMSIS-NN is not a valid macro names.
ADDITIONAL_DEFINES := -D$(shell echo $(TARGET) | tr [a-z] [A-Z])
ifneq ($(OPTIMIZED_KERNEL_DIR),)
# TODO(b/168824958): remove dash->underscore transformation once the cmsis-nn
# directory has been renamed.
ADDITIONAL_DEFINES += -D$(shell echo $(OPTIMIZED_KERNEL_DIR) | tr [a-z] [A-Z] | tr - _)
ADDITIONAL_DEFINES += -D$(shell echo $(OPTIMIZED_KERNEL_DIR) | tr [a-z] [A-Z])
endif
ifneq ($(CO_PROCESSOR),)

View File

@ -45,7 +45,7 @@ THIRD_PARTY_CC_HDRS += \
$(CMSIS_PATH)/CMSIS/DSP/Include/dsp/utils.h
# We add -I$(CMSIS_PATH) to enable the code in the TFLM repo (mostly in the
# tensorflow/lite/micro/kernels/cmsis-nn) to use include paths relative to
# tensorflow/lite/micro/kernels/cmsis_nn) to use include paths relative to
# the CMSIS code-base.
#
# The CMSIS code itself uses includes such as #include "arm_math.h" and so

View File

@ -26,7 +26,7 @@ else
MICROLITE_LIBS += $(ETHOSU_DRIVER_LIBS)
endif
# Currently there is a dependency to CMSIS even without OPTIMIZED_KERNEL_DIR=cmsis-nn.
# Currently there is a dependency to CMSIS even without OPTIMIZED_KERNEL_DIR=cmsis_nn.
CMSIS_DEFAULT_DOWNLOAD_PATH := $(MAKEFILE_DIR)/downloads/cmsis
CMSIS_PATH := $(CMSIS_DEFAULT_DOWNLOAD_PATH)
ifeq ($(CMSIS_PATH), $(CMSIS_DEFAULT_DOWNLOAD_PATH))