Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reshaping error #1366

Open
mammadmaheri7 opened this issue Mar 27, 2024 · 1 comment
Open

Reshaping error #1366

mammadmaheri7 opened this issue Mar 27, 2024 · 1 comment

Comments

@mammadmaheri7
Copy link

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.

@kali
Copy link
Collaborator

kali commented Apr 25, 2024

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants