oramasearch / onnx-go

onnx-go gives the ability to import a pre-trained neural network within Go without being linked to a framework or library.
https://blog.owulveryck.info/2019/04/03/from-a-project-to-a-product-the-state-of-onnx-go.html
MIT License
704 stars 72 forks source link

Handle operators with no input (eg Constant) #131

Closed owulveryck closed 5 years ago

owulveryck commented 5 years ago

Is your feature request related to a problem? Please describe. The #116 raises an error because some operators, such as Constant do not have any input

Describe the solution you'd like While decoding the graph in the core package, if an operator does not have any input, create a dummy node that will hold the backend of the current operator (same type, same shape). It is the responsibility of the backend to reuse the data of the node to spare some memory.

Describe alternatives you've considered For the constant operator, the operator could be turned into an initializer; but the problem would remain for other operators such as RandomUniform and RandomNormal

Additional context cf Issue 2274 in the core onnx project.

owulveryck commented 5 years ago

branch #131 will follow the implementation

owulveryck commented 5 years ago

By now, the branch contains a basic implementation and a test. The implementation is creating a new ValueInfoProto when a node with zero input is detected while parsing.

@mattn maybe you can use this branch and merge your PR in it to see if it works?

owulveryck commented 5 years ago

All fixed and merged