Use SDRAM to store model_tflite[]


I use the dual core 160 pin microcontroller Arduino Portenta to make TensorFlowLite/Micro models. Recently I found out about an extra 8 MB of SDRAM on the board. I have managed to use the SDRAM to load the 320x320 Grayscale Camera Buffer when using models, draft code here.




I would like to put the entire TensorflowMicro model_tflite array into the 8 MB SDRAM, the board normally only has 1 MB of RAM for each core, so using SDRAM would be a fair improvement.

When using SDRAM for the camera frame buffer I was just changing one pointer for another so it was not that hard.

#include <SDRAM.h>


uint8_t *sdram_frame_buffer;

// in the setup

  mySDRAM.begin(SDRAM_START_ADDRESS);   // for camera 320x320

  sdram_frame_buffer = (uint8_t *)mySDRAM.malloc(320 * 320 * sizeof(uint8_t));

// in the main loop
   int myCamResult =  myCam.grab(sdram_frame_buffer); // myCamResult should be zero 

but for TFLITE I need to work with an array, and that is a bit different when calling the array. Anyone got any suggestions to get me started?

Here is the basic TFLITE code.

const unsigned char model_tflite[] = { ... }

unsigned int model_tflite_len = 3048;

// which is then called using

   model = tflite::GetModel(model_tflite); 

// I have tried passing the array as a pointer (which works in some situations)
// but doesn't seem to work here
// Not really sure what the GetModel method does with the array.



using TFLITE tutorial here

More info posted on the Arduino Fourm Portenta - Usage of SDRAM.h library - #3 by jerteach - Portenta - Arduino Forum