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

Fix None shape error when one input to ConcatV2 has a shape. #2135

Merged
merged 7 commits into from
Apr 12, 2023

Conversation

klasma
Copy link
Contributor

@klasma klasma commented Mar 14, 2023

I tried to convert a network where one of the inputs to a concatenation along dimension -1 had shape None. The other input did however have a shape. The conversion failed because the code only looked att the shape of the first input to determine what positive axis value to use in the concatenation. If the order of the inputs had been reversed, the conversion would have worked.

I have now changed the code to look at the shapes of both input nodes. With the new code, I can convert the network. I have also verified that the resulting onnx-file works.

Let me know if you would like me to change or add something.

I tried to convert a network where one of the inputs to a concatenation
along dimension -1 had shape None. The other input did however have a
shape. The conversion failed because the code only looked att the shape of
the first input to determine what positive axis value to use in the
concatenation. If the order of the inputs had been reversed, the conversion
would have worked.

I have now changed the code to look at the shapes of both input nodes. With
the new code, I can convert the network. I have also verified that the
resulting onnx-file works.

Signed-off-by: Klas Magnusson <[email protected]>
@klasma klasma force-pushed the fix-none-shape-concatenation branch from 87fc6eb to 314e8f1 Compare March 14, 2023 11:40
@fatcat-z
Copy link
Collaborator

fatcat-z commented Mar 17, 2023

Thanks for your contributions!

@klasma ,
Could you please add a unit test in test_backend.py to cover this scenario?

fatcat-z and others added 5 commits March 24, 2023 08:44
…ape.

In the test, a tensor with none shape is created by applying the slice
operator to another tensor. The slice size is obtained by adding two
tensors and therefore the size of the sliced tensor cannot be inferred and
is set to None. A tensor with a known shape is then concatenated to the
tensor with none shape along the -1 axis. Previously, it was not possible
to convert a network with this structure, but I fixed that bug in my
previous commit. The problem occurred only when the first input had none
shape and when the concatenation axis was -1.

Signed-off-by: Klas Magnusson <[email protected]>
@klasma
Copy link
Contributor Author

klasma commented Apr 12, 2023

@fatcat-z

Sorry for the delay. I had to do some additional debugging in order to reproduce the problem in a test.

Now I have added a test for this scenario to test_backend.py.

In the test, a tensor with none shape is created by applying the slice operator to another tensor. The slice size is obtained by adding two tensors and therefore the shape of the sliced tensor cannot be inferred and is set to None. A tensor with a known shape is then concatenated to the tensor with none shape along the -1 axis. This is the node structure that caused problems in the network that I was trying to convert.

Let me know if you have any questions or if there is something else that I should do.

@fatcat-z fatcat-z enabled auto-merge (squash) April 12, 2023 15:38
Copy link
Collaborator

@fatcat-z fatcat-z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution!

@fatcat-z fatcat-z merged commit aaaea95 into onnx:main Apr 12, 2023
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

Successfully merging this pull request may close these issues.

2 participants