tflite-micro/tensorflow/lite/micro/kernels/cmsis_nn
Esun Kim bc0e8c658b
Re-enable 3D x 2D BatchMatMul dimension collapse for adj_x=true (#3599)
* Re-enable 3D x 2D BatchMatMul dimension collapse for adj_x=true

* Code style
2026-07-08 15:32:05 +00:00
..
add.cc
batch_matmul.cc Re-enable 3D x 2D BatchMatMul dimension collapse for adj_x=true (#3599) 2026-07-08 15:32:05 +00:00
conv.cc Ensure int64 accumulation for bias-less 16x8 ops in TFLM kernels (#3598) 2026-06-16 23:58:19 +00:00
depthwise_conv.cc Removed batch_size assert in depthwise_conv (#3562) 2026-05-27 16:41:22 +00:00
fully_connected.cc Additional const-tensor checks (CMSIS_NN) (#3229) 2025-10-17 10:02:30 -07:00
maximum_minimum.cc Fixed rank support in pad and min/max (#3563) 2026-05-27 16:41:17 +00:00
mul.cc
pad.cc Fixed rank support in pad and min/max (#3563) 2026-05-27 16:41:17 +00:00
pooling.cc Fix cmsis-nn pooling (#3584) 2026-06-01 16:24:20 +00:00
README.md [Doc] Fix typos (#3446) 2026-02-11 17:18:49 +00:00
softmax.cc
svdf.cc Additional const-tensor checks (CMSIS_NN) (#3229) 2025-10-17 10:02:30 -07:00
transpose.cc Add support for CMSIS-NN int8 transpose and padding operators (#2757) 2025-03-20 22:27:29 +00:00
transpose_conv.cc Update CMSIS-NN Transpose conv function call (#2760) 2024-11-12 22:34:09 +00:00
unidirectional_sequence_lstm.cc Update CMSIS-NN download (#3607) 2026-06-24 04:03:35 +00:00

General Info

CMSIS-NN is a library containing kernel optimizations for Arm(R) Cortex(R)-M processors. To use CMSIS-NN optimized kernels instead of reference kernels, add OPTIMIZED_KERNEL_DIR=cmsis_nn to the make command line. See examples below.

For more information about the optimizations, check out CMSIS-NN documentation,

Specifying path to CMSIS-NN

By default CMSIS-NN is built by code that is downloaded to the TFLM tree. It is also possible to build CMSIS-NN code from an external path by specifying CMSIS_PATH=<../path> and CMSIS_NN_PATH=<../path>. Note that both CMSIS_PATH and CMSIS_NN_PATH is needed since CMSIS-NN has a dependency to CMSIS-Core. As a third option CMSIS-NN can be provided manually as an external library. The examples below will illustrate this.

Specifying path to Cortex_DFP

The Cortex_DFP path used can be specified using an additional flag CORTEX_DFP_PATH=<path/to>cmsis/Cortex_DFP. Default is the Cortex_DFP contained in the downloaded CMSIS version.

Example - FVP based on Arm Corstone-300 software.

In this example, the kernel conv unit test is built. For more information about this specific target, check out the Corstone-300 readme.

Downloaded CMSIS-NN code is built:

make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn TARGET=cortex_m_corstone_300 TARGET_ARCH=cortex-m55 kernel_conv_test

External CMSIS-NN code is built:

make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn CMSIS_PATH=<external/path/to/cmsis/> CMSIS_NN_PATH=<external/path/to/cmsis-nn/>  TARGET=cortex_m_corstone_300 TARGET_ARCH=cortex-m55 kernel_conv_test

External CMSIS-NN library is linked in:

make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn CMSIS_NN_LIBS=<path/to/cmsis-nn.a> CMSIS_PATH=<path/to/cmsis/> TARGET=cortex_m_corstone_300 TARGET_ARCH=cortex-m55 kernel_conv_test

Please note that performance and/or size might be affected when using an external CMSIS-NN library as different compiler options may have been used.

Also note that if specifying CMSIS_NN_LIBS but not CMSIS_PATH and or CMSIS_NN_PATH, headers and system/startup code from the default downloaded path of CMSIS would be used. So CMSIS_NN_LIBS, CMSIS_NN_PATH and CMSIS_PATH should have the same base path and if not there will be a build error.

Build for speed or size

It is possible to build for speed or size. The size option may be required for a large model on an embedded system with limited memory. Where applicable, building for size would result in higher latency paired with a smaller scratch buffer, whereas building for speed would result in lower latency with a larger scratch buffer. Currently only transpose conv supports this. See examples below.

Example - building a static library with CMSIS-NN optimized kernels

More info on the target used in this example: https://github.com/tensorflow/tflite-micro/blob/main/tensorflow/lite/micro/cortex_m_generic/README.md

Building for speed (default): Note that speed is default so if leaving out OPTIMIZE_KERNELS_FOR completely that will be the default.

make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m55 OPTIMIZED_KERNEL_DIR=cmsis_nn OPTIMIZE_KERNELS_FOR=KERNELS_OPTIMIZED_FOR_SPEED microlite

Building for size:

make -f tensorflow/lite/micro/tools/make/Makefile TARGET=cortex_m_generic TARGET_ARCH=cortex-m55 OPTIMIZED_KERNEL_DIR=cmsis_nn OPTIMIZE_KERNELS_FOR=KERNELS_OPTIMIZED_FOR_SIZE microlite