onnxruntime
0f300140 - Experimental C API support (#28746)

Commit
124 days ago
Experimental C API support (#28746) ### Description This pull request introduces a mechanism for exposing experimental C API functions in ONNX Runtime. The new system enables the addition, iteration, and eventual promotion of experimental APIs without impacting the stable ABI, using a name-based function pointer lookup and a generated header for type safety and ergonomics. The changes include documentation, build integration, header generation, implementation, and test coverage for the new experimental API flow. **Experimental C API Framework** * Added a design doc (`Experimental_C_API.md`) detailing the motivation, design decisions, and usage patterns for the experimental C API mechanism. * Introduced a central declaration file (`onnxruntime_experimental_c_api.inc`) using X-macros to define experimental API functions and their lifecycle rules. The X-macro signature uses `ORT_EXPERIMENTAL_API(VER, RET, NAME, ...)` ordering (return type before name) to match the convention used by `ORT_API_T` in the stable API. * Added a generated consumer header (`onnxruntime_experimental_c_api.h`) that provides C typedefs, name constants, and C++ typed accessors for experimental functions. Experimental function names follow the pattern `<TargetStruct>_<Name>_SinceV<APIVersion>` to unambiguously convey availability and avoid collision. * Updated the stable C API struct (`OrtApi` in `onnxruntime_c_api.h`) to include a single function pointer, `GetExperimentalFunction`, for name-based experimental function lookup. The `OrtExperimentalFnPtr` generic function pointer type (rather than `void*`) is used as the return type to avoid undefined behavior when casting between function pointers. * Integrated the new headers into the build system so they are installed and available to consumers. **Implementation and Test Coverage** * Implemented the runtime support for experimental API lookup and function registration (`experimental_c_api.cc`), including a test-only function (`OrtApi_ExperimentalApiTest`) to exercise the mechanism end-to-end. * Registered the new experimental API entry point in the exported API table (`onnxruntime_c_api.cc`). * Added a unit test source file for experimental API coverage. ### Motivation and Context Enable support for experimental C APIs. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Author
Parents
Loading