ARM C++ Inferencing : ERR: Out of memory, can't allocate matrix_ptrs

Hello.

I am trying to inference the audio recognition C++ model in an ARM microprocessor (in a Xilionx Zynq SoC).

I managed to adapt the ei_ functions and to compile the model.
I put raw features in the input_buf[] in the main.cpp given here.
Yet, when I run the inference, I get the message “ERR: Out of memory, can’t allocate matrix_ptrs”

I narrowed down the issue to the classifier function itself : res = run_classifier(&signal, &result, false);

In the ei_run_classifier.h file, it means the following condition is true (lines 294-298) :

if (matrix_ptrs[ix]->buffer == nullptr) {
ei_printf(“ERR: Out of memory, can’t allocate matrix_ptrs[%lu]\n”, ix);
delete[] matrix_ptrs;
return EI_IMPULSE_ALLOC_FAILED;
}

(I verified that it is not the other conditions leading to the similar message)

I have actually no idea how to fix that. Does it mean the compilation, eventhough there is no error, failed ? Or do you have any other advice ?

Thank you in advance !

Hi @bmulliez

Compilation is ok, the error is at runtime because there’s not enough heap memory to allocate matrix_ptrs , check your linker file and increase the area dedicated to the heap.

regards,
fv

1 Like

Thanks a lot, it works perfectly. I am able to run a inference once with hard-coded features.

Now I want to use it continously. I am using one core of my Zynq for the inference (in a while-(1) loop) and the other one to acquire audio data. The audio data recored are placed in a shared DDR memory and flags allow both core to synchronize writing and reading steps.

For writing, here is the procedure (assume a few acquisitions are already done):
1- move (with memmove) data from the shared DDR base address to base_addr+1600
2- fill the 1600 first addresses of the shared DDR with new samples (in reverse order so that the older is at addr 1599 and the newer one is @0.
3- raise a flag for the other core to know a new buffer can be processed.

It seems to be ok.
The problem is I can’t figure out how I can modify the get_signal_data function to directly read the DDR. I coded the synchronization scheme once the audio acquisition core raises the “new data ready” flag. But what else ? I am not sure I really get how the get_signal_data function actually works and what the roles of out_ptr and offset are and how they are set…

Any help on that ?

Thank you in advance.

If I manage to have a fully functionnal project on the Zynq (ona Zybo board), I’ll share my project for the community.

Hi @bmulliez ,

I suggest you to check our SDK documentation here: Structs | Edge Impulse API and SDKs Documentation

If you need some examples, you can check different implementation for different targets and sensors in our github repo:
Camera example
https://github.com/edgeimpulse/firmware-avh-inference/blob/17e09f53b71f56c9adef786d0d6dbd187e2405b0/App/src/main.cpp#L191

Audio example:

regards,
fv