What’s the right approach to obtaining the max heap usage of an impulse? I am running a keyword spotting demo with an EON compiled model, and using EIDSP_TRACK_ALLOCATIONS I see that the Impulse reports using peak ram of ~24k; however the actual number seems to be ~45k (anything less and the edge impulse library errors out). My guess is memory alignment is causing extra usage not accounted for, but even then the number seems too inflated. Is there any other dynamic allocations happening that aren’t accounted for by EIDSP_TRACK_ALLOCATIONS?
On a related note I’ve seen mention in the forums that static allocation is an option, but no specifics on how to enable it; can you tell me how to enable it?
Hi @tennies, track allocations applies only to the DSP code, the neural network allocations are made in trained_model_compiled.cpp: see the constexpr int kTensorArenaSize definition for the neural network scratch area size. These are not used together though, DSP memory is free’d, then NN memory is allocated (by default). Typically with keyword spotting models I’m expecting the NN code to take less than 45K though (the estimations in the Studio should be pretty accurate, as they are tracked using a Cortex-M emulator on the fly). What are the numbers you see in the code?
Jan, EI_CLASSIFIER_TFLITE_ARENA_SIZE is about 13k. I think the size inflation I’m seeing is due to the compiler toolchain’s implementation of dynamic memory allocation, but I wanted to make sure I wasn’t missing anything on the edge impulse side of things. Thanks for the informative response.