onnxruntime/include
Christian Bourjau 6dd4e4801a
Allow custom operator functions to safely propagate errors through the C-API (#16479)
### Description
This PR implements a backward-compatible way to define custom operators
with fallible compute functions. The C++ API templated gained an
optional `Fallible` argument. Closes #14287

### Motivation and Context
#14287 contains more context. The gist is that the current C-API defines
compute operations of custom operators as functions returning `void`
rather than an `OrtStatusPtr`. Currently, errors are often propagated
across the C-ABI using C++ exceptions. That is very unsafe and undefined
behavior. Moreover, it is difficult for languages other than C++ to use
this approach even if they wanted to. A C-compliant sound and safe way
to propagate errors allows for non-C++ fallible custom operators.

### An example in action
https://github.com/cbourjau/ort-custom-op/pull/6/files is a
demonstration of how this PR can be used to write safe and fallible
custom operators in Rust.
2023-06-28 08:16:32 -07:00
..
onnxruntime/core Allow custom operator functions to safely propagate errors through the C-API (#16479) 2023-06-28 08:16:32 -07:00