ClientRunner.translate_onnx_model() failed in Expand-Concat layer

Hey @masaru.ueki ,

Welcome to the Hailo Community!

It seems the error is caused by a mismatch between the broadcasted shape of the Expand layer and the expected output shape, as well as compatibility issues with how the Hailo SDK handles Concat operations. To fix this, you can try the following:

  1. Understand the Error
  • The Expand layer requires the constant value shape to be broadcastable to the target output shape.
  • The reported shape [1, 768, 576] doesn’t match your model’s expected shape [1, 576, 768].
  • The Hailo SDK has specific requirements for Expand and Concat operations that might differ from the standard ONNX graph representation.
  1. Modify the Code
  • Replace the Expand operation with a repeat function to explicitly replicate the data:
expanded = unsqueezed.repeat(1, 576, 1)
  • When exporting the model to ONNX, set parameters for better Hailo compatibility:
torch.onnx.export(
    model, 
    dummy_input, 
    onnx_path,
    export_params=True,
    opset_version=13,
    do_constant_folding=True,
    input_names=["input.1"],
    dynamic_axes={"input.1": {0: "batch_size"}}
)
  • Update the end_node_names to ['/Unsqueeze'] when parsing the model:
end_node_names = ['/Unsqueeze']
hn, npz = runner.translate_onnx_model(
    onnx_path, 
    onnx_model_name,
    start_node_names=['input.1'],
    end_node_names=end_node_names,
    net_input_shapes={'input.1': [1, 577, 768]}
)
  1. Test with a Simplified Model
  • Create a simplified version of your model to test the changes before applying them to the full model.
  1. Enable Verbose Logging
  • Set the environment variable HAILO_SDK_LOG_LEVEL=DEBUG to get more detailed logs for debugging.