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:
- 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
andConcat
operations that might differ from the standard ONNX graph representation.
- Modify the Code
- Replace the
Expand
operation with arepeat
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]}
)
- Test with a Simplified Model
- Create a simplified version of your model to test the changes before applying them to the full model.
- Enable Verbose Logging
- Set the environment variable
HAILO_SDK_LOG_LEVEL=DEBUG
to get more detailed logs for debugging.