Skip to main content
Visitor II
April 30, 2025
Question

Error analyzing ONNX model with GRU layer in STM32Cube.AI v2.0.0

  • April 30, 2025
  • 1 reply
  • 472 views

Hello ST Community/Support,

I am encountering an issue when trying to analyze an ONNX model containing a GRU layer using STM32Cube.AI.

  • Tool Version: STM32Cube.AI v2.0.0-20049 .
  • Model Type: A neural network model with a GRU layer followed by a Dense (fully connected) layer.
  • Model Format: ONNX, exported from PyTorch.
  • Error Occurs: During the "Analyzing Network" phase in STM32Cube.AI.
  • Target MCU: STM32H7 series.

The specific error messages I receive in the Output window are:

TOOL ERROR: operands could not be broadcast together with shapes (1024,) (512,).

I understand that GRU layers are complex operations. It seems that Cube.AI's internal analysis or decomposition of the GRU layer is encountering a shape mismatch during an attempted element-wise operation (broadcasting).

Could you please help me understand the cause of this error? Does STM32Cube.AI v2.0.0 have specific limitations regarding GRU layers or the broadcasting of operands within complex operations like those in GRU? Is there a recommended way to structure or export ONNX models with GRU for Cube.AI to be able to process them correctly?

I can provide the ONNX model file (model.onnx) if needed for debugging.

Thank you for your assistance.

1 reply

SlothGrill
ST Employee
May 6, 2025

Hello Kiki,

As you said, GRU is quite complex, and we are still trying to reach for the support of as many gru configs as possible.

Here you can find the known limitations that applies for GRU layers when providing an ONNX model: ONNX toolbox support

However, it looks like your model falls in a bug of stedgeai reported recently: STEdgeAI does not manage to properly import ONNX-GRU layers with the linear_before_reset attribute set.

This bug is currently under fix on the development side.

 

Sorry for the inconvenience.

Best regards.