Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Where" Op Is Not Implemented #1080

Closed
GuanLuo opened this issue May 22, 2019 · 7 comments
Closed

"Where" Op Is Not Implemented #1080

GuanLuo opened this issue May 22, 2019 · 7 comments
Assignees

Comments

@GuanLuo
Copy link

GuanLuo commented May 22, 2019

Hi all, I created a model containing "Where" operator but failed to load it via Onnx Runtime C API:

Could not find an implementation for the node Where(9)

However, the version matrix says it supports Onnx opset version 10.

The Python script to generate the model:

import onnx
onnx_input_str = onnx.helper.make_tensor_value_info("INPUT0", onnx.TensorProto.STRING, [1])
onnx_input_int = onnx.helper.make_tensor_value_info("INPUT1", onnx.TensorProto.INT32, [1])
onnx_flag = onnx.helper.make_tensor_value_info("READY", onnx.TensorProto.INT32, [1])
onnx_output = onnx.helper.make_tensor_value_info("OUTPUT", onnx.TensorProto.STRING, [1])

internal_input = onnx.helper.make_node("Cast", ["INPUT0"], ["_INPUT"], to=onnx.TensorProto.INT32)
add = onnx.helper.make_node("Add", ["_INPUT", "INPUT1"], ["add"])
zeros = onnx.helper.make_node("Sub", ["READY", "READY"], ["zeros"])
equal = onnx.helper.make_node("Equal", ["READY", "zeros"], ["equal"])
where = onnx.helper.make_node("Where", ["equal", "zeros", "add"], ["CAST"])
cast = onnx.helper.make_node("Cast", ["CAST"], ["OUTPUT"], to=onnx.TensorProto.STRING)

onnx_nodes = [internal_input, add, zeros, equal, where, cast]
onnx_inputs = [onnx_input_str, onnx_input_int, onnx_flag]
onnx_outputs = [onnx_output]

graph_proto = onnx.helper.make_graph(onnx_nodes, "conditional_and_cast", onnx_inputs, onnx_outputs)
model_def = onnx.helper.make_model(graph_proto)
onnx.save(model_def, "model.onnx")
@skottmckay
Copy link
Contributor

Could not find an implementation for the node Where(9)

This suggests you model has opset set to 9. What version of ONNX are you using?

@GuanLuo
Copy link
Author

GuanLuo commented May 22, 2019

@skottmckay The onnx version is '1.4.1', and it is using opset 9 as you said (versioning doc). So it is not backward capatible?

@skottmckay
Copy link
Contributor

Sorry - I thought Where was new in opset 10. What version of onnxruntime are you using as our implementation of Where was added a few months ago (and is valid for opset 9).

https://github.com/microsoft/onnxruntime/blob/master/onnxruntime/core/providers/cpu/tensor/where_op.cc

@skottmckay skottmckay self-assigned this May 22, 2019
@faxu faxu added the bug label May 22, 2019
@GuanLuo
Copy link
Author

GuanLuo commented May 22, 2019

I am using Onnx Runtime 0.4.0 built from source. Now I looked at the where_op.cc at branch rel-0.4.0 and I noticed that the types int32_t and bool is commented out, so I suppose that "where" op is implemented in Onnx Runtime but it is limited to certain data types?

@skottmckay
Copy link
Contributor

The current implementation does limit the supported types, I believe to try and keep the overall binary size small. Support for int32_t was enabled last week though, so if you pulled the latest master it would be in that.

31cbb5d#diff-3276925863124d4b46cb2f4e29e49b9f

@GuanLuo
Copy link
Author

GuanLuo commented May 22, 2019

I see. I wonder if there is a option / mode that I can enable to build the library with full Onnx support? Right now it seems to be inconvenient as I need to do something similar to 31cbb5d and to rebuild to support some data types.

@GuanLuo
Copy link
Author

GuanLuo commented May 28, 2019

Opened a new issue #1122 for the feature requested in followup comment.

@GuanLuo GuanLuo closed this as completed May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants