cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: by using float32 as input and output data with CubeAI

SandroS
Associate

Hi 

I have a really simple Neural Network (Keras) with 3 float32 inputs and 3 float32 outputs. 
Size: 2.2KB RAM 16kBFlash and 1600MACC, really small network, in my opinion it should not be a problem at all to run that.

For testing i wanted to try the simplest way possible to run that Network on a STML4 MCU.
I used CubeMX, integraded the Model and created and built an example Project by using a "ApplicationTemplate".
All went prefect. 

so know i have an example Project where everything is generated. especially a file called "app_x_cube-ai.c".
There is a init function called: "MX_X_CUBE_AI_Init()" and a RunAI function called " MX_X_CUBE_AI_Process", looking like this 

void MX_X_CUBE_AI_Process(void)
{
    /* USER CODE BEGIN 6 */
  int res = -1;
 
  printf("TEMPLATE - run - main loop\r\n");
 
  if (network) {
 
  /* 1 - acquire and pre-process input data */
  res = acquire_and_process_data(data_ins);
  /* 2 - process the data - call inference engine */
  if (res == 0)
res = ai_run();
  /* 3- post-process the predictions */
  if (res == 0)
res = post_process(data_outs);
  }
 
  if (res) {
    ai_error err = {AI_ERROR_INVALID_STATE, AI_ERROR_CODE_NETWORK};
    ai_log_err(err, "Process has FAILED");
  }
    /* USER CODE END 6 */
}
 
As i can see i need to complete the code on two positions, i neet to accquire the input data (Testinput), and read out the output data. And this is exactly where i have huge problems with. I tried it to run like this. 

/* USER CODE BEGIN 2 */
int acquire_and_process_data(ai_i8* data[])
{
 
static ai_float f32DataInt[]  = {0.72912163, -0.4422069, 0.8137491}; //Testinput
data[0] = AI_HANDLE_PTR(f32DataInt);
return 0;
}
 
int post_process(ai_i8* data[])
{
static ai_float f32DataOut[3];
memcpy(f32DataOut, data[0], 12u);
return 0;
}
/* USER CODE END 2 */

I have set a breakpoint to have a look at output data "f32DataOut". it is always wrong. 
I am pretty shure my input data is also not processed correctly. 

Has anyone an idea what i could do ? 
is datatype processed correctly, did i miss something ? 
any hint would be great. 

I attached the complete "app_x-cube-ai.c" File. Everything else is generated in CubeMx
Thanks in advance

 

0 REPLIES 0