Reshaping error
When attempting to execute the following command:
tract -O --pass analyse network.onnx -i 1,3,224,224 dump
I encountered an error with the following details:
[2024-03-27T16:07:02.965373196Z ERROR tract] Error at stage "analyse"
Caused by: 0: ModelBuildingError 1: Failed analyse for node #104 "Reshape_40" Reshape 2: Infering facts 3: Applying rule GivenRule { (inputs[0].shape, inputs[1]) } 4: Reshaping [Val(1), Val(197), Val(576)] to [Val(1), Val(197), Val(3), Val(3), Val(65)] 5: Invalid
I initially suspected that the issue might be related to dynamic dimensions. To investigate further, I attempted to address it by modifying the ONNX file using the provided Python script:
import onnx
on = onnx.load("network.onnx")
for tensor in on.graph.input:
for dim_proto in tensor.type.tensor_type.shape.dim:
print("dim_proto:",dim_proto)
if dim_proto.HasField("dim_param"): # and dim_proto.dim_param == 'batch_size':
dim_proto.Clear()
dim_proto.dim_value = 1 # fixed batch size
for tensor in on.graph.output:
for dim_proto in tensor.type.tensor_type.shape.dim:
if dim_proto.HasField("dim_param"):
dim_proto.Clear()
dim_proto.dim_value = 1 # fixed batch size
onnx.save(on, "output.onnx")
However, despite applying these modifications, the error persisted.
To reproduce the error, onnx file is attached. network.onnx file
Would appreciate any insights or guidance on resolving this issue.
Hello !
As far as I can tell this Reshape is invalid. 1,197,576 can not be reshaped as 1,197,3,3,65 : 3365 = 585.
The 3,3,65 shape is hard-coded as a constant of the model. So... is your input specification compatible with the model ? is there an actual bug in tract, hapenning before that reshape leading to a incorrect shape (the 1,197, 576) ? or is the model just broken ?