Question/Issue:I’ve trained a small classifier model (project id: 744624). My board is s3-n16-r8, and it is enough to run this model.But I encount the ERR:Failed to allocate persistent buffer of size 576, does not fit in tensor arena and reached EI_MAX_OVERFLOW_BUFFER_COUNT
all along the way when deploued by the Arduino IDE 2.3.6.I have tried to add #define EI_CLASSIFIER_TENSOR_ARENA_SIZE (500*1024)
and #define EI_MAX_OVERFLOW_BUFFER_COUNT 30
, but the same.At the end, #define EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 0//(1 change to 0)
in ei_classifier_config.h
,and then run successfully.I want to know why the first method didnot work.THANK YOU very much.
Hi, @2309653 !
TLDR:
-
use non-EON model
-
modify the
kTensorArenaSize
and /orEI_MAX_OVERFLOW_BUFFER_COUNT
intflite-model/tflite_learn_**_compiled.cpp
. You MUST modify it in that model file, simply adding defines to main.cpp or Arduino sketch will not work. The exact number would require some trial and error / guesswork.
Longer explanation (to let you know why switching offEI_CLASSIFIER_TFLITE_ENABLE_ESP_NN
works, but would give you much slower inference):
So, the issue here is that ESP32-S3 uses optimized assembly kernels for certain NN operations, specifically Conv and DepthConv. These optimized kernels require additional buffer allocation.
HOWEVER during our deployment we don’t account for that, as we use regular tflite kernels. ESP32-S3 optimized kernels can only run on ESP32-S3, as they have chip specific assembly code, that simply won’t compile on x86 or aarch64 system.
Therefore, the necessary arena size is quite a bit larger for ESP32-S3. We have overflow buffers to account for that, and we already increased the overflow buffer number for S3, but for some models its not enough. I checked the docs and it looks like there is QEMU simulator for ESP32S3 QEMU Emulator - ESP32-S3 - — ESP-IDF Programming Guide v5.5 documentation.