You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to load a feature pyramid network on top of a resnet model into onnx-go. The FPN uses an onnx Resize operator because it needs to upsample the feature maps. The Resize operator has an input (roi) that are optional.
I'm using torch. When exporting a torch Resize operator to onnx the roi parameter is not used (only used for tf_crop_and_resize coordinate transformation mode). But the torch onnx export uses a constant value of an empty tensor. It has [0] as dims and no float_data or raw_data. Since this parameter isn't used at all the value should not matter.
The bug
When loading an onnx model in onnx-go it crashes because "No data found".
funcmain() {
// Create a backend receiverbackend:=gorgonnx.NewGraph()
// Create a model and set the execution backendmodel:=onnx.NewModel(backend)
// read the onnx modelb, err:=os.ReadFile("model.onnx")
iferr!=nil {
log.Fatal("error reading file ", err)
}
// Decode it into the modelerr=model.UnmarshalBinary(b)
iferr!=nil {
log.Fatal("error loading model ", err)
}
}
Output:
2022/11/16 16:35:11 error loading model No data found
Why this happens
The onnx::Resize operator takes %9 and %10 as an input. These are of type Float(0) and dont have any data. These tensors cannot be read properly by onnx-go.
I think this can be solved by adding a check for dimensionality of the tensor to generateConsOptsFromFloat64Tensor and alike. If it is zero then an empty gorgonia tensor should be created.
I do have some time to work on this (work project) if this solution is acceptable.
The text was updated successfully, but these errors were encountered:
Context
I'm trying to load a feature pyramid network on top of a resnet model into onnx-go. The FPN uses an onnx Resize operator because it needs to upsample the feature maps. The Resize operator has an input (
roi
) that are optional.I'm using torch. When exporting a torch Resize operator to onnx the
roi
parameter is not used (only used fortf_crop_and_resize
coordinate transformation mode). But the torch onnx export uses a constant value of an empty tensor. It has [0] as dims and no float_data or raw_data. Since this parameter isn't used at all the value should not matter.The bug
When loading an onnx model in onnx-go it crashes because "No data found".
To generate the onnx I'm using this.
Output
To load it I'm using
Output:
Why this happens
The
onnx::Resize
operator takes%9
and%10
as an input. These are of typeFloat(0)
and dont have any data. These tensors cannot be read properly by onnx-go.The error happens here: https://github.com/owulveryck/onnx-go/blob/master/internal/onnx/ir/tensor.go#L113
Solution
I think this can be solved by adding a check for dimensionality of the tensor to
generateConsOptsFromFloat64Tensor
and alike. If it is zero then an empty gorgonia tensor should be created.I do have some time to work on this (work project) if this solution is acceptable.
The text was updated successfully, but these errors were encountered: