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

about GatherElements operator #59

Closed
Like2021 opened this issue Dec 14, 2023 · 3 comments
Closed

about GatherElements operator #59

Like2021 opened this issue Dec 14, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Like2021
Copy link

Thanks for your excellent open source work, I guess I've run into a new problem.

I have a GatherElements operator, like:

img_v3_0264_116fa3e0-8e59-43c7-b9c5-0cd23ad2530g

This operator has two inputs. The input shapes are 1×195 and 1×196 respectively.
When i use onnx_tool.share_infer(), I found that GatherElements node will call shape_infer directly, like:

class GatherElementsNode(Node):
    def shape_infer(self, intensors: List[Tensor], outtensors: List[Tensor]):
        outtensors[0].update_shape(intensors[0].get_shape())
        outtensors[0].update_dtype(intensors[0].dtype)

According to the code, it will directly default the output shape to be the same as the first Tensor of intensors, but for this GatherElements node, its Indices should be 1×195 input, then the output should be consistent with Indices, which is also 1×195, not 1×196.

The node attribute shape_calc will call the function shape_infer if it is False,

def shape_infer(self, inputs: {} = None):
    ...
    if node.shape_calc:
        node.value_infer(itensors, otensors)
    else:
        node.shape_infer(itensors, otensors)

so I guess shape_calc about GatherElements should be True?

Could you give some tips for this situation?

@ThanatosShinji
Copy link
Owner

It seems like a bug of GatherElements. The output shape should be outtensors[0].update_shape(intensors[1].get_shape()). Is your graph with tensor shapes (in your posted image) generated by onnx_tool?

@ThanatosShinji ThanatosShinji added the bug Something isn't working label Dec 14, 2023
@ThanatosShinji ThanatosShinji self-assigned this Dec 14, 2023
@ThanatosShinji
Copy link
Owner

I've fixed the bug of GatherElements in this commit 1d170c7.
Thanks for your feedback!

@Like2021
Copy link
Author

No, it is not generated by onnx_tool.

It seems like a bug of GatherElements. The output shape should be outtensors[0].update_shape(intensors[1].get_shape()). Is your graph with tensor shapes (in your posted image) generated by onnx_tool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants