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
717 stars 71 forks source link

onnx: operator Shape not implemented #219

Open ShowyQuasar88 opened 2 months ago

ShowyQuasar88 commented 2 months ago

I encountered a problem when reading an ONNX model and performing inference. I used gorgonnx as the backend and put it into the model for creation. Then, I performed setInput on the model. A total of three tensors are required, but when executing, an error is reported saying "Operator Shape not implemented". If I'm not mistaken, the Shape operator should have been implemented. But why is this error still reported? Here is my code `// Create a backend receiver backend := gorgonnx.NewGraph() // Create a model and set the execution backend model := onnx.NewModel(backend)

f, err := os.ReadFile("onnx/model1.onnx")
if err != nil {
    log.Fatalf("【ERROR】read .onnx file error[%v]", err)
}

if err = model.UnmarshalBinary(f); err != nil {
    log.Fatalf("【ERROR】model unmarshal to binary error[%v]", err)
}

model.SetInput(0, inputs["input_ids"])
model.SetInput(1, inputs["token_type_ids"])
model.SetInput(2, inputs["attention_mask"])

err = backend.Run()
if err != nil {
    log.Fatalf("【ERROR】backend run error[%v]", err)
}`

Very simple, but i really dont know why this error occured 2024/09/12 16:10:05 【ERROR】backend run error[onnx: operator Shape not implemented ()]