Onnxruntime: Does custom_op_library support dynamic input of CustomOp?

Created on 3 Sep 2020  Â·  8Comments  Â·  Source: microsoft/onnxruntime

I have followed the instruction of AddingCustomOp.md to add my CustomOp, but my CustomOp has dynamic input, which is the number and type of input is uncertained. It can have two or three input, and the type of input could be int or float.

I use the first scheme of AddingCustomOp.md, which is "Using the custom op API in the C/C++ APIs (onnxruntime_c_api.h)", but I run into problems quickly. This scheme doesn't seem to support dynamic input. Because the running process is this:

  1. Get information of CustomOp, including the input numbers and types, output numbers and types
  2. Create CustomOp
  3. Load onnx model, and Verify the information of CustomOp(graph.cc: InferAndVerifyTypeMatch)
  4. Compute CustomOp

BUT I can only specify One type or count of input, just like the code below.

  size_t GetInputTypeCount() const { return 2; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };

  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };

HOW can I support dynamic input of CustomOp by custom_op_library?

C++ custom ops enhancement

All 8 comments

@lewisword Yeah, the current custom ops are fairly simple and don't support dynamic inputs. It would require a more complex API, and at a certain point it's better to just add the op using the internal interfaces to get every feature.

But nothing is impossible if this is what people want. It's just not possible currently.

@RyanUnderhill
I need to implement a new relu op (onnx does not have this op), which supports float16 and float32 inputs, but I found that it cannot be done through the onnxruntime C/C++ custom interface, because an error will be reported if the custom_op name is the same.

1

sincerely thanks.

I have the same requirement. When can this function be supported

I have the same problem, When can this function be added

nothing is impossible if this is what people want, a ha ha.
people do want this!

Need this feature +1

Need multiple input types,for example float or float16。

Please view SliceCustomOp as know-how.

Was this page helpful?
0 / 5 - 0 ratings