espressif/esp-nn
소개
Optimised Neural Network functions for Espressif chipsets
시스템 및 인프라측정된 스타 증가
- in 24h
- +2
- in 7 days
- +5
- in 15 days
- +7
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalESP-NN
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 (conv and depthwise on the MAC16 unit with
CONFIG_NN_ESP32_MAC16, generic optimisations elsewhere) - ESP32-C3 (Generic optimisations)
Performance
Kernel Performance
Speedup of the optimized s8 kernels over the portable ANSI C ones (cycles, ANSI C / optimized):
| Kernel | Shape | ESP32-S3 | ESP32-P4 | ESP32-S31 |
|---|---|---|---|---|
| Convolution 1x1 | input 10x10, filter 64x1x1x64 | 38.33 | 29.85 | 30.47 |
| Convolution 1x1 | input 8x8, filter 16x1x1x16 | 17.86 | 19.41 | 20.31 |
| Depthwise conv 3x3 | input 18x18, filter 1x3x3x16 | 13.18 | 29.56 | 29.39 |
| Depthwise conv 5x5 | input 12x12, filter 8x5x5x4 | 4.91 | 1.81 | 1.79 |
| Fully connected | length 271, 3 outputs | 10.97 | 5.01 | 5.11 |
| Elementwise add | 1615 elements, TFLite parameters | 4.63 | 7.52 | 7.56 |
| Elementwise multiply | 1615 elements | 17.39 | 7.73 | 7.86 |
| Channel broadcast multiply | 49 positions x 576 channels | 14.08 | 7.74 | 7.97 |
| Max pooling 3x3 | input 16x16x16 | 40.96 | 31.93 | 32.35 |
| Average pooling 3x3 | input 16x16x16 | 3.62 | 3.59 | 3.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
Chip CPU Freq without ESP-NN with ESP-NN ESP32-P4 360MHz 1395ms 73ms ESP32-S31 320MHz 1669ms 72ms ESP32-S3 240MHz 2300ms 54ms ESP32 240MHz 4084ms 380ms ESP32-C3 160MHz 3355ms 426ms - Numbers are time (ms) for
MobileNetV3 Small (INT8 quantized, 224x224x3, 1000 classes)
Chip CPU Freq without ESP-NN with ESP-NN with ESP-NN, dual core ESP32-P4 400MHz 10898ms 155ms 132ms ESP32-S3 240MHz 26620ms 329ms 260ms YOLO11n (INT8 quantized, 192x192x3, 80 classes, object detection)
Chip CPU Freq without ESP-NN with ESP-NN with ESP-NN, dual core ESP32-P4 400MHz 51180ms 318ms 254ms ESP32-S3 240MHz 130655ms 722ms 568ms
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_v3andyolo_test_appexamples 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 corecolumn is withesp_nn_dual_core_enable()called once at startup, which lets the heavier kernels split their work across both cores Without ESP-NNis esp-tflite-micro with esp-nn turned off, so it runs the TFLite Micro reference kernels. Turn off "Use ESP-NN optimized kernels" inidf.py menuconfig(underESP TFLite-Micro), or setCONFIG_ESP_TFLITE_MICRO_USE_ESP_NN=ninsdkconfig.
Configuration
To configure, please use
idf.py menuconfigand underESP-NNselectNN_OPTIMIZATIONSThere 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 Creference 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.
관련 프로젝트 살펴보기
불러오는 중…