ThanatosShinji / onnx-tool

A parser, editor and profiler tool for ONNX models.
https://pypi.org/project/onnx-tool/
MIT License
383 stars 51 forks source link

BUG about shape_infer() #58

Closed Like2021 closed 9 months ago

Like2021 commented 9 months ago

I think nodes like or can be used without shape_infer?


File "/home/xxxx/anaconda3/envs/onnx/lib/python3.8/site-packages/onnx_tool/node.py", line 158, in value_infer
  raise NotImplementedError(f'this Node {self.op_type}-{self.name} has no value_infer')
NotImplementedError: this Node Or-/Or has no value_infer
ThanatosShinji commented 9 months ago

Do you mean without value_infer?

ThanatosShinji commented 9 months ago

I think the real problem here is your model with Or operator is not supported.

Like2021 commented 9 months ago

Thanks for your answer.

I guess that or operator is not supported. Could you teach me how to manually support or skip the or operator?

I tried to skip this operator in the code, but this will affect the shape infer of subsequent operators. I am confused about this and don't know how to solve it. https://github.com/ThanatosShinji/onnx-tool/blob/f06228c4edce44bc33025db9b1bbcbd018173d9f/onnx_tool/graph.py#L823

like:


          node = self.nodemap[key]
          itensors = []
          # skip or
          if node.op_type == "Or":
              break
          for input in node.input:
              itensors.append(self.tensormap[input])
          otensors = []
          for output in node.output:
              otensors.append(self.tensormap[output])
ThanatosShinji commented 9 months ago

I've added this operator to the main branch. you can check out this branch to use.

Like2021 commented 9 months ago

Thanks for your quick reply!