Contrib ops
Contents
The contrib ops domain contains ops that are built in to the runtime by default. Only selected operators are added as contrib ops to avoid increasing the binary size of the core runtime package. When possible, custom operators should be used.
Contrib Op List
The contrib operator schemas are documented in the ONNX Runtime repository.
Adding Contrib ops
The custom op’s schema and shape inference function should be added in contrib_defs.cc using ONNX_CONTRIB_OPERATOR_SCHEMA. Example: Inverse op
A new operator should have complete reference implementation tests and shape inference tests.
Reference implementation python tests should be added in onnxruntime/test/python/contrib_ops. E.g., aten_op_tests.py
Shape inference C++ tests should be added in onnxruntime/test/contrib_ops. E.g., trilu_shape_inference_test.cc
The operator kernel should be implemented using Compute function under contrib namespace in onnxruntime/contrib_ops/cpu/ for CPU and onnxruntime/contrib_ops/cuda/ for CUDA.
The kernel should be registered in cpu_contrib_kernels.cc for CPU and cuda_contrib_kernels.cc for CUDA.
Now you should be able to build and install ONNX Runtime to start using your custom op.
Contrib Op Tests
Tests should be added in onnxruntime/test/contrib_ops/. For example:
For documentation questions, please file an issue.