Skip to main content
Associate
Jan 21, 2026 11:25 AM UTC
Solved

Encoder only transformer on STM32

I am trying to deploy encoder only transformer model on STM32 by converting pytorch model to onnx format first and then using STM toolchain (STM32 CubeAI). However, I am constantly getting this error when I analyzed the model:

TOOL ERROR: cannot reshape array of size 0 into shape ()

 

I tried to debug my model but couldn't find any issue in it. Any guidance will be appreciated.

 

Thank you.

Julian E.
Julian E.Best answer
ST Technical Moderator
Feb 3, 2026 4:07 PM UTC

Hi @MK06,

 

We support some layers required for transformers models, but not all. This depends on how your model is made.

Can you make sure that your model uses only support onnx nodes: ONNX toolbox support

 

You can also look at this:

https://www.youtube.com/watch?v=q_T6aDoQrgA 

 

The NPU was developed for Convolutions and is not really adapted for transformers. We do support some layers being part of transformers model, and we are working on future product to improve our solutions regarding LSTM/RNN and transformers.

 

have a good day,

Julian

​In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

3 replies

Explorer
Feb 2, 2026 12:31 PM UTC

Which type of chip are you using? I'm also deploying the transformer model on the STM32 microcontroller recently.

MK06Author
Associate
Feb 2, 2026 12:48 PM UTC

Currently working with STM32U575ZIT6Q 

Julian E.
Julian E.Best answer
ST Technical Moderator
Feb 3, 2026 4:07 PM UTC

Hi @MK06,

 

We support some layers required for transformers models, but not all. This depends on how your model is made.

Can you make sure that your model uses only support onnx nodes: ONNX toolbox support

 

You can also look at this:

https://www.youtube.com/watch?v=q_T6aDoQrgA 

 

The NPU was developed for Convolutions and is not really adapted for transformers. We do support some layers being part of transformers model, and we are working on future product to improve our solutions regarding LSTM/RNN and transformers.

 

have a good day,

Julian

​In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.