microsoft / microsoft/onnxruntime
expand fails when leading shape value is -1
@RandySheriffH is already working on this.
Since Mar 21, 2021.
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 179
Description
Describe the bug
I am currently implementing an ONNX serializer of EBMs (explainable boosting machines). One of the needed operations is expand. The shape of the input tensors is [None, 1] and I need to expand them to [None, 3]
For example, given this input tensor:
[[0.1], [1.2], [11], [4.2]]
I expect this output tensor:
[
[0.1, 0.1, 0.1],
[1.2, 1.2, 1.2],
[11, 11, 11],
[4.2, 4.2, 4.2]
]
When I set the shape input parameter to a tensor [-1, 3], onnx runtime fails with this error:
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Non-zero status code returned while running Expand node. Name:'' Status Message: invalid expand shape
However, if I set it for to [4, 3], this works with the example input. Since the first dimension of my tensor is the batch size, I cannot fix the value in the input shape parameter.
Is this a bug in onnx-runtime, or should I use the operator in another way?
Urgency
None
System information
- ubuntu 18.04:
- ONNX Runtime installed from binary (pypi):
- ONNX Runtime version: 1.6.0
- Python version: 3.6.9
- Visual Studio version (if applicable):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version: None
- GPU model and memory: None
To Reproduce
sess = rt.InferenceSession('expand.onnx')
pred_onx = sess.run(None, {
'i': [
[0.1],
[1.2],
[11],
[4.2],
]
})
print(pred_onx)
Expected behavior
the result should be:
[
[0.1, 0.1, 0.1],
[1.2, 1.2, 1.2],
[11, 11, 11],
[4.2, 4.2, 4.2]
]
Screenshots
Not applicable
Additional context
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.