Skip to content

Custom operator with multiple input/output types #13861

Discussion options

You must be logged in to vote

Hi @netaz,

If your custom op has 1 input and 1 output that can be of various tensor types, then you can use ONNXTensorElementDataType::ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED to indicate that the input (or output) can potentially be of any type defined in the ONNTensorElementDataType enum

Example:

struct MyCustomOp: Ort::CustomOpBase<MyCustomOp, MyCustomKernel> {
  // ...

  size_t GetInputTypeCount() const { return 1; };  // One input only
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;  // Can be f32, f16, uint8, etc.
  };

  size_t GetOutputTypeCount() const { return 1; };  // One output only
  ONNXTensorElementData…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@netaz
Comment options

@abhishek27m1992github
Comment options

Answer selected by netaz
Comment options

You must be logged in to vote
2 replies
@adrianlizarraga
Comment options

@minrui-hust
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime
4 participants