Unable to compile a model

I have an ONNX model that causes mx_nc to report “the model must have a uniform batch dimension throughout the entire model” error. However, the model already have batch size=1 for all layers. How to fix that?

The model is developed internally and I’m not authorized to share it. Steps to diagnose the issue locally will be highly appreciated.

Hi there!

The “non-uniform batch dimension” error typically means one of two things:

  1. There could be data organization or pre/post-processing layers in the ONNX graph that need to be cropped. Try using the --autocrop flag and refer to this tutorial, and see if that was the cause.
  2. Your model might have Attention / Transformer layers, such as in YOLO v10/11/26 or ViT, and in this case you’ll need to enable the relevant Compiler Extension.
    • When the compiler isn’t using these extensions, it looks at the ONNX nodes of the layer individually, so it appears that the batch dim is being manipulated, when really it’s just a verbose expansion of a single layer. Extensions detect these structures and tell the rest of the compiler “this group of weird ONNX nodes is actually just one layer”. Sometimes the detection patterns can overlap with each other, so that’s why they need to be enabled with mx_nc’s --extensions argument.
    • The Extension library is growing with each new SDK. If your model is based on an existing open-source model, please share a link to it and we can see if an Extension for it could be possible.

Let us know if these help or if you have more questions!