Skip to content

Experimental C++ API update - #29142

Merged
edgchen1 merged 4 commits into
mainfrom
edgchen1/experimental_c_api_update
Jun 22, 2026
Merged

Experimental C++ API update#29142
edgchen1 merged 4 commits into
mainfrom
edgchen1/experimental_c_api_update

Conversation

@edgchen1

Copy link
Copy Markdown
Contributor

Description

  • Split out C++ code into separate C++ experimental header onnxruntime_experimental_cxx_api.h. This can also contain other auxiliary experimental API-related C++ code.
  • Add throwing C++ experimental function accessors. The Get_X_FnOrThrow() variant throws an exception if the experimental API is unavailable in the build.

Motivation and Context

Improve experimental API ergonomics for C++.

edgchen1 and others added 4 commits June 16, 2026 20:23
Move the C++ accessor wrappers out of the experimental C header into a new C++ companion header (onnxruntime_experimental_cxx_api.h), keeping onnxruntime_experimental_c_api.h pure C. Add a throwing accessor variant (Get_..._FnOrThrow) alongside the existing nullable accessor; it throws Ort::Exception (ORT_NOT_IMPLEMENTED) when the experimental function is unavailable.

Split the mechanical, X-macro-generated per-function plumbing into _fns.h detail headers so each public header stays focused on its curated, hand-written surface. Enforce that the detail headers are only included through their public header via a scoped ORT_INCLUDING_* guard macro that triggers a #error otherwise.

Register the new headers in cmake, update the design doc, and update the tests to use the new headers and the throwing accessor.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Inline the experimental C typedef/name-constant macro pass and C++ nullable/FnOrThrow accessor passes into the public headers. Keep explicit section comments for auxiliary/custom code in each header.

Remove obsolete split detail headers and their installation entries from cmake. Update Experimental_C_API.md to document the restored two-header model and inline X-macro expansion approach.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@edgchen1
edgchen1 requested a review from jambayk June 17, 2026 19:23
@GopalakrishnanN
GopalakrishnanN self-requested a review June 17, 2026 19:35
Comment thread docs/design/Experimental_C_API.md

@yuslepukhin yuslepukhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@edgchen1
edgchen1 merged commit 8c856fb into main Jun 22, 2026
87 of 88 checks passed
@edgchen1
edgchen1 deleted the edgchen1/experimental_c_api_update branch June 22, 2026 20:57
GopalakrishnanN pushed a commit that referenced this pull request Jun 22, 2026
Bring in #29142 (experimental C++ API split). Move Ort::Experimental::EpContextConfig into onnxruntime_experimental_cxx_api.h and redesign per review: drop the OrtApi* ctor param (use Ort::GetApi()), add a from-OrtSessionOptions ctor, and add throwing GetReadFunc()/GetWriteFunc() members. Simplify ep_factory.cc (try/catch at the C boundary) and the tests to use the wrapper.
tianleiwu pushed a commit that referenced this pull request Jun 23, 2026
### Description
<!-- Describe your changes. -->

- Split out C++ code into separate C++ experimental header
`onnxruntime_experimental_cxx_api.h`. This can also contain other
auxiliary experimental API-related C++ code.
- Add throwing C++ experimental function accessors. The
`Get_X_FnOrThrow()` variant throws an exception if the experimental API
is unavailable in the build.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Improve experimental API ergonomics for C++.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants