cancel
Showing results for 
Search instead for 
Did you mean: 

Error in "ram" optimization of STM32CubeAI

ManuZhu
Associate II

The error occurs in both Mac m1 and windows. When I use "stm32ai validate/generate" command, I find that "-O ram" outputs totally strange results. 

Let's use fdmobilenet_0.25_224_tfs_int8.tflite from stm32ai-modelzoo as an example. 

"stm32ai validate -O time/balanced fdmobilenet_0.25_224_tfs_int8.tflite" outputs as below
截屏2024-04-09 20.38.08.png

The "X-cross #1" here is 100% which is perfect, but for "stm32ai validate -O ram fdmobilenet_0.25_224_tfs_int8.tflite", something strange happens.

截屏2024-04-09 20.44.03.png

The "X-cross #1" is 10% and the accuracy of c-model is 0% meaning that the model can hardly do what the developers want to do. 

Note that this happens in about 30% models for image classification in stm32ai-modelzoo as I tested.

To get a rough reason for this problem, I observer the intermediate output per layer between "-O ram" and "-O time/balanced". I find that, for only fdmobilenet_0.25_224_tfs_int8.tflite, the difference first happened in a "conv2D + maxpool" layer. In "-O ram", it is fused as one c-layer but split as two layers in "-O time/balanced".

截屏2024-04-09 20.54.39.png

 

 

截屏2024-04-09 20.55.19.png

 

 

I guess the problem may arise in the quantization and dequantization of the fusion operator since I find repeated "128" and "255" of "uint8" in the output of "-O ram".

Because this part of the code is black box, internal developers are needed to ultimately solve the problem. I would be more than happy to be a part of this process

1 ACCEPTED SOLUTION

Accepted Solutions
jean-michel.d
ST Employee

Hello ManuZhu,

Thanks to share this experimentation. I suppose that you use X-CUBE-Ai 8.1. I have effectively reproduced your issue with the "-O ram" option and this model. This issue has been normaly fixed in the last release: X-CUBE-AI 9.0. Can you check on your side? 

 

br,

Jean-Michel

View solution in original post

2 REPLIES 2
jean-michel.d
ST Employee

Hello ManuZhu,

Thanks to share this experimentation. I suppose that you use X-CUBE-Ai 8.1. I have effectively reproduced your issue with the "-O ram" option and this model. This issue has been normaly fixed in the last release: X-CUBE-AI 9.0. Can you check on your side? 

 

br,

Jean-Michel

Hello Jean-Michel,

Thanks to your reply. I have checked on my side and find that everything goes right.

I'm curious if you could share why this problem occurs in X-CUBE-Ai 8.1