STMicroelectronics / stm32ai-modelzoo

AI Model Zoo for STM32 devices
Other
236 stars 64 forks source link

command "stm32ai generate" error #30

Closed ManuZhu closed 2 months ago

ManuZhu commented 2 months ago

The error occurs when I try to run the code generated for model squeezenetv1.1_xxx_tfs_int8.tflite. The command I used to generate code is stm32ai generate -m squeezenetv1.1_128_tfs_int8.tflite -O ram And I follow the guide "How to run locally a c-model" in the X-CUBE-AI Documentation to get the executable. When I run the elf, it returns an assertion failed which like this.

Assertion failed: (((ai_size)(ai_array_get_byte_size(((ai_array_format)(((ai_array)(p_tensor_scratch->data))->format)), (((ai_array)(p_tensor_scratch->data))->size)))) == scratch_size), function ai_layer_check_scratch_size, file layers.c, line 289.

To figure it out, I observe the intermediate output per layer following the guide "Platform Observer API" in the X-CUBE-AI Documentation. And I find out that stm32ai generates the wrong size for the scratch data of one Conv2D layer.

image-2 截屏2024-04-08 11 46 37

The correct shape should be (1, 63, 63, 64), but the generated scratch size is (1, 3, 63, 64). Since the stm32ai is a blackbox, I cannot move on to find the real problem. b.t.w. I first find this problem when I run the command stm32ai validate -m squeezenetv1.1_128_tfs_int8.tflite -O ram.

LFOSTM commented 2 months ago

Hello, I do not reproduce the issue using the developer cloud (release 8.1). Seems not to be a model zoo issue. Can you post the issue here : https://community.st.com/t5/stm32-mcus-machine-learning-ai/bd-p/stm32-mcu-machine-learning-ai-forum. Maybe precise the device you are using. Thanks, Laurent