Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

ESP-NN

Component Registry CI

The library contains optimised NN (Neural Network) functions for various Espressif chips.

  • Supported platforms:

    • TensorFlow Lite Micro (TFLite Micro). Repo can be found here
  • Supported ESP chips include:

    • ESP32-S3 (Assembly versions optimised to benefit from vector instructions of ESP32-S3)
    • ESP32-P4 (Optimised using PIE/QACC SIMD instructions)
    • ESP32-S31 (Optimised using PIE/QACC SIMD instructions, shares ESP32-P4 kernels)
    • ESP32 (Generic optimisations)
    • ESP32-C3 (Generic optimisations)

Performance

Kernel Performance

Speedup of the optimized s8 kernels over the portable ANSI C ones (cycles, ANSI C / optimized):

KernelShapeESP32-S3ESP32-P4ESP32-S31
Convolution 1x1input 10x10, filter 64x1x1x6414.247.006.24
Convolution 1x1input 8x8, filter 16x1x1x168.013.512.94
Depthwise conv 5x5input 12x12, filter 8x5x5x44.491.941.75
Fully connectedlength 271, 3 outputs5.325.015.11
Elementwise multiply1615 elements3.511.601.82
Max pooling 3x3input 16x16x167.8319.9412.65
Average pooling 3x3input 16x16x163.623.593.95

All kernels and shapes, with cycle counts and the setup per chip, are in docs/performance.md.

Model-Level Performance

  • Person Detection (Visual Wake Words, INT8 quantized, from esp-tflite-micro)

    • Numbers are time (ms) for invoke() call, using internal memory
    ChipCPU Freqwithout ESP-NNwith ESP-NN
    ESP32-P4360MHz1395ms73ms
    ESP32-S31320MHz1669ms72ms
    ESP32-S3240MHz2300ms54ms
    ESP32240MHz4084ms380ms
    ESP32-C3160MHz3355ms426ms
  • MobileNetV3 Small (INT8 quantized, 224x224x3, 1000 classes)

    ChipCPU Freqwithout ESP-NNwith ESP-NNwith ESP-NN, dual core
    ESP32-P4400MHz10980ms388ms253ms
    ESP32-S3240MHz26679ms729ms690ms
  • YOLO11n (INT8 quantized, 192x192x3, 80 classes, object detection)

    ChipCPU Freqwithout ESP-NNwith ESP-NNwith ESP-NN, dual core
    ESP32-P4400MHz52240ms620ms417ms
    ESP32-S3240MHz130753ms1253ms1053ms

Note:

  • The above is time taken for execution of the invoke() call
  • SPIRAM used for TensorArena.
  • Person detection on ESP32-S3 with internal RAM: 47ms
  • MobileNetV3 and YOLO11n were measured with the mobilenet_v3 and yolo_test_app examples in esp-tflite-micro, with no profiler attached; ESP32-P4 with 200MHz HEX PSRAM, ESP32-S3 with 80MHz OCT PSRAM and a 64KB data cache
  • The dual core column is with esp_nn_dual_core_enable() called once at startup, which lets the heavier kernels split their work across both cores
  • Without ESP-NN is esp-tflite-micro with esp-nn turned off, so it runs the TFLite Micro reference kernels. Turn off "Use ESP-NN optimized kernels" in idf.py menuconfig (under ESP TFLite-Micro), or set CONFIG_ESP_TFLITE_MICRO_USE_ESP_NN=n in sdkconfig.

Configuration

  • To configure, please use idf.py menuconfig and under ESP-NN select NN_OPTIMIZATIONS

  • There are two options presented:

    • Optimized versions
    • ANSI C
  • Default selection is for Optimized versions. For ESP32-S3, ESP32-P4 and ESP32-S31, assembly versions are automatically selected, whereas for other chips (viz., ESP32, ESP32-C3), generic optimisations are selected.

  • For debugging purposes, you may want to select ANSI C reference versions.

ESP32-P4: PIE Kernels in Several Tasks

  • ESP-IDF v5.x release tags (up to v5.4.4 and v5.5.5) do not save the PIE register q3 when they switch tasks.
  • So on ESP32-P4, two tasks on the same core that both run PIE code can corrupt each other's results. For example, two TFLite Micro interpreters, or ESP-NN and ESP-DSP.
  • ESP-IDF v6.0 and later save q3. So do the next v5.3, v5.4 and v5.5 releases.
  • On an older v5.x release, run the PIE kernels from one task per core.

Scratch Buffers

Some kernels need a scratch buffer that the caller owns. Size it with esp_nn_get_<op>_scratch_size() and pass it with esp_nn_set_<op>_scratch_buf() before the call. The getters also build on Linux, so tools can compute the sizes ahead of time.

For more details, including how to build the getters on Linux for a target, see docs/scratch_buffers.md.

Contributing

If you encounter an issue with ESP-NN, or wish to submit a feature request, please use the Issues section on the Github.

For general questions related to this library, please use the esp32.com forum.

Please check CONTRIBUTING.md for further information if you'd like to contribute to ESP-NN.

Copyrights and License

All original source code in this repository is Copyright (C) 2020-2026 Espressif Systems. This source code is licensed under the Apache License 2.0 as described in the file LICENSE.

关于 About

Optimised Neural Network functions for Espressif chipsets

语言 Languages

C63.4%
Assembly34.3%
Python1.6%
CMake0.5%
Shell0.2%
Makefile0.1%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
151
Total Commits
峰值: 40次/周
Less
More

核心贡献者 Contributors