Add OrtExternalResourceImporter API for D3D12 shared resource import by nieubank · Pull Request #26828 · microsoft/onnxruntime

@nieubank

Introduces the OrtExternalResourceImporter API enabling execution providers
to import D3D12 shared resources and timeline fences for zero-copy GPU-to-GPU
data sharing with ORT inference.

Public API additions:
- OrtExternalResourceImporter capability object
- OrtExternalMemoryHandle for imported D3D12 allocations
- OrtExternalSemaphoreHandle for imported D3D12 timeline fences
- SessionGetEpDeviceForOutputs to query output EP device placement
- RunOptions_SetSyncStream to associate sync stream for async execution

EP Plugin API:
- OrtExternalResourceImporterImpl interface for EP implementations
- OrtEpFactory::CreateExternalResourceImporterForDevice extension

Design:
- No GPU virtual addresses in public API
- EP-agnostic design allows any EP to implement import
- Capability discovery with explicit ORT_NOT_IMPLEMENTED
- Follows existing patterns (Allocator, DataTransfer, SyncStream)

Includes example_plugin_ep mock implementation and autoep tests.

skottmckay

@nieubank

- Deleted the sync_stream member from OrtRunOptions structure.
- Removed the RunOptions_SetSyncStream API and its implementation.
- Updated related C++ API and example implementations to reflect the removal of sync stream functionality.
- Adjusted tests to remove references to RunOptions_SetSyncStream.
- Introduced new structures for external memory and semaphore handles to improve resource management.
- Ensured backward compatibility by checking EP version support for external resource import.

@nieubank nieubank marked this pull request as ready for review

December 19, 2025 23:04

skottmckay

@nieubank

yuslepukhin

yuslepukhin

@nieubank

- Added `ep_interop_api.h` to define the Interop API for external resource importers.
- Implemented functions for creating and managing external resource importers, including memory and semaphore import capabilities.
- Updated `onnxruntime_c_api.cc` to integrate the new Interop API, replacing previous external resource importer implementations.
- Modified `ort_apis.h` to declare the new Interop API functions.
- Refactored tests in `test_external_resource_importer.cc` to utilize the new Interop API for external resource importer operations.
Resolved API conflicts by placing KernelInfo APIs before Interop APIs

yuslepukhin

- Return ORT_NOT_IMPLEMENTED status instead of nullptr when EP doesn't support external resource import
- Rename ep_interop_api.{cc,h} to interop_api.{cc,h} to match the generic OrtInteropApi naming
- Update documentation to reflect the new error handling behavior
…eExternalResourceImporterForDevice

Capability discovery APIs should return success with nullptr output when a feature
is unsupported, rather than an error status. This allows simple "if (out != nullptr)"
checks without needing to distinguish ORT_NOT_IMPLEMENTED from real errors.

- Update tests to assert status is nullptr and skip when importer is nullptr

skottmckay

skottmckay

skottmckay

skottmckay

@nieubank

github-advanced-security[bot]

@nieubank

@nieubank

@nieubank

skottmckay

alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request

Jan 20, 2026

nieubank added a commit that referenced this pull request

Jan 20, 2026
The OrtExternalResourceImporter types added in #26828 were wrapped in a Doxygen group block, but this section of the file is already within an existing Global group scope (opened at line 289, closed at end of file). This caused Doxygen to fail with:

  error: Refusing to add group Global to itself

Remove the redundant group markers since the new types correctly inherit the existing Global group context. Verified locally with Doxygen 1.16.1.

nieubank added a commit that referenced this pull request

Jan 20, 2026
Fixes multiple Doxygen errors introduced by recent API additions that
cause the nightly documentation build to fail with WARN_AS_ERROR=YES.

Root causes by PR:

PR #26828 (c54be3c - OrtExternalResourceImporter API for D3D12):
- Incorrect \param names for ORT_CLASS_RELEASE macros: the macro
  expands to use 'input' as the parameter name, but docs used
  'importer' and 'handle'

PR #26927 (1ed8fd9 - Control flow kernels API):
- Used ::CreateLoopKernel() and ::CreateScanKernel() syntax which
  Doxygen cannot resolve as links

PR #26971 (3874516 - CreateEnvWithOptions API):
- Used ::SetSessionLogSeverityLevel() and ::RunOptionsSetRunLogSeverityLevel()
  syntax which Doxygen cannot resolve
- Used <ep_name> in documentation which Doxygen interprets as HTML tag
- Used incorrect \param[out] name 'out' instead of 'config_entries'

Fixes:
- Qualify method references with struct name (e.g., OrtApi::Method)
- Escape angle brackets as \<ep_name\>
- Use 'input' as param name for ORT_CLASS_RELEASE documentation
- Use actual param name 'config_entries' for GetEnvConfigEntries

Verified locally with Doxygen 1.9.8 (matches CI configuration).

yuslepukhin pushed a commit that referenced this pull request

Jan 21, 2026
# Fix Doxygen documentation build errors from recent PRs

Fixes multiple Doxygen errors introduced by recent API additions that
cause the nightly documentation build to fail (`WARN_AS_ERROR=YES`).

## Root Cause Analysis

| Error | File | Line | Introduced By | Commit | Fix |
|-------|------|------|---------------|--------|-----|
| Duplicate `\addtogroup Global` | onnxruntime_c_api.h | 973 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Remove redundant group
markers |
| Unresolved `::SetSessionLogSeverityLevel()` | onnxruntime_c_api.h |
1065 | PR #26971 - CreateEnvWithOptions API | 3874516 | Use
`OrtApi::SetSessionLogSeverityLevel` |
| Unresolved `::RunOptionsSetRunLogSeverityLevel()` |
onnxruntime_c_api.h | 1066 | PR #26971 - CreateEnvWithOptions API |
3874516 | Use `OrtApi::RunOptionsSetRunLogSeverityLevel` |
| `<ep_name>` interpreted as HTML | onnxruntime_c_api.h | 1119 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[in] importer` not found | onnxruntime_c_api.h | 7982 | PR
#26828 - OrtExternalResourceImporter API | c54be3c | Use `\param[in]
input` (macro expands to `input`) |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8025 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8091 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| Unresolved `::CreateLoopKernel()` | onnxruntime_ep_c_api.h | 667 | PR
#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateLoopKernel` |
| Unresolved `::CreateScanKernel()` | onnxruntime_ep_c_api.h | 710 | PR
#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateScanKernel` |
| `<ep_name>` interpreted as HTML | onnxruntime_ep_c_api.h | 1434 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[out] out` not found | onnxruntime_ep_c_api.h | 1440 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Use `\param[out]
config_entries` |

## Summary by PR

| PR | Issues |
|----|--------|
| **#26828** (c54be3c) - OrtExternalResourceImporter API for D3D12 |
Duplicate Doxygen group, incorrect `\param` names for
`ORT_CLASS_RELEASE` macros |
| **#26927** (1ed8fd9) - Control flow kernels API | `::Method()` syntax
unresolvable by Doxygen |
| **#26971** (3874516) - CreateEnvWithOptions API | `::Method()`
syntax, `<ep_name>` HTML interpretation, incorrect param name |

## Technical Details

### `ORT_CLASS_RELEASE` Macro Issue

The `ORT_CLASS_RELEASE(X)` macro at line 164 expands to:
```cpp
void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
```

The parameter is always named `input`, but the documentation in PR
#26828 used semantic names like `importer` and `handle`. Doxygen
validates `\param` names against actual parameter names in the expanded
code.

### Doxygen Link Resolution

Doxygen 1.9.8 cannot resolve `::MethodName()` as a link to a method. The
correct syntax is to qualify with the struct name: `OrtApi::MethodName`.

## Testing

Verified locally with Doxygen 1.9.8 (matches CI configuration).

tianleiwu pushed a commit that referenced this pull request

Jan 21, 2026
# Fix Doxygen documentation build errors from recent PRs

Fixes multiple Doxygen errors introduced by recent API additions that
cause the nightly documentation build to fail (`WARN_AS_ERROR=YES`).

## Root Cause Analysis

| Error | File | Line | Introduced By | Commit | Fix |
|-------|------|------|---------------|--------|-----|
| Duplicate `\addtogroup Global` | onnxruntime_c_api.h | 973 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Remove redundant group
markers |
| Unresolved `::SetSessionLogSeverityLevel()` | onnxruntime_c_api.h |
1065 | PR #26971 - CreateEnvWithOptions API | 3874516 | Use
`OrtApi::SetSessionLogSeverityLevel` |
| Unresolved `::RunOptionsSetRunLogSeverityLevel()` |
onnxruntime_c_api.h | 1066 | PR #26971 - CreateEnvWithOptions API |
3874516 | Use `OrtApi::RunOptionsSetRunLogSeverityLevel` |
| `<ep_name>` interpreted as HTML | onnxruntime_c_api.h | 1119 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[in] importer` not found | onnxruntime_c_api.h | 7982 | PR
#26828 - OrtExternalResourceImporter API | c54be3c | Use `\param[in]
input` (macro expands to `input`) |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8025 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8091 | PR #26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| Unresolved `::CreateLoopKernel()` | onnxruntime_ep_c_api.h | 667 | PR
#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateLoopKernel` |
| Unresolved `::CreateScanKernel()` | onnxruntime_ep_c_api.h | 710 | PR
#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateScanKernel` |
| `<ep_name>` interpreted as HTML | onnxruntime_ep_c_api.h | 1434 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[out] out` not found | onnxruntime_ep_c_api.h | 1440 | PR
#26971 - CreateEnvWithOptions API | 3874516 | Use `\param[out]
config_entries` |

## Summary by PR

| PR | Issues |
|----|--------|
| **#26828** (c54be3c) - OrtExternalResourceImporter API for D3D12 |
Duplicate Doxygen group, incorrect `\param` names for
`ORT_CLASS_RELEASE` macros |
| **#26927** (1ed8fd9) - Control flow kernels API | `::Method()` syntax
unresolvable by Doxygen |
| **#26971** (3874516) - CreateEnvWithOptions API | `::Method()`
syntax, `<ep_name>` HTML interpretation, incorrect param name |

## Technical Details

### `ORT_CLASS_RELEASE` Macro Issue

The `ORT_CLASS_RELEASE(X)` macro at line 164 expands to:
```cpp
void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
```

The parameter is always named `input`, but the documentation in PR
#26828 used semantic names like `importer` and `handle`. Doxygen
validates `\param` names against actual parameter names in the expanded
code.

### Doxygen Link Resolution

Doxygen 1.9.8 cannot resolve `::MethodName()` as a link to a method. The
correct syntax is to qualify with the struct name: `OrtApi::MethodName`.

## Testing

Verified locally with Doxygen 1.9.8 (matches CI configuration).

(cherry picked from commit 39f966e)

alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request

Jan 27, 2026

alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request

Jan 27, 2026
…ft#27083)

# Fix Doxygen documentation build errors from recent PRs

Fixes multiple Doxygen errors introduced by recent API additions that
cause the nightly documentation build to fail (`WARN_AS_ERROR=YES`).

## Root Cause Analysis

| Error | File | Line | Introduced By | Commit | Fix |
|-------|------|------|---------------|--------|-----|
| Duplicate `\addtogroup Global` | onnxruntime_c_api.h | 973 | PR microsoft#26828
- OrtExternalResourceImporter API | c54be3c | Remove redundant group
markers |
| Unresolved `::SetSessionLogSeverityLevel()` | onnxruntime_c_api.h |
1065 | PR microsoft#26971 - CreateEnvWithOptions API | 3874516 | Use
`OrtApi::SetSessionLogSeverityLevel` |
| Unresolved `::RunOptionsSetRunLogSeverityLevel()` |
onnxruntime_c_api.h | 1066 | PR microsoft#26971 - CreateEnvWithOptions API |
3874516 | Use `OrtApi::RunOptionsSetRunLogSeverityLevel` |
| `<ep_name>` interpreted as HTML | onnxruntime_c_api.h | 1119 | PR
microsoft#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[in] importer` not found | onnxruntime_c_api.h | 7982 | PR
microsoft#26828 - OrtExternalResourceImporter API | c54be3c | Use `\param[in]
input` (macro expands to `input`) |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8025 | PR microsoft#26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| `\param[in] handle` not found | onnxruntime_c_api.h | 8091 | PR microsoft#26828
- OrtExternalResourceImporter API | c54be3c | Use `\param[in] input` |
| Unresolved `::CreateLoopKernel()` | onnxruntime_ep_c_api.h | 667 | PR
microsoft#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateLoopKernel` |
| Unresolved `::CreateScanKernel()` | onnxruntime_ep_c_api.h | 710 | PR
microsoft#26927 - Control flow kernels API | 1ed8fd9 | Use
`OrtEpApi::CreateScanKernel` |
| `<ep_name>` interpreted as HTML | onnxruntime_ep_c_api.h | 1434 | PR
microsoft#26971 - CreateEnvWithOptions API | 3874516 | Escape as `\<ep_name\>` |
| `\param[out] out` not found | onnxruntime_ep_c_api.h | 1440 | PR
microsoft#26971 - CreateEnvWithOptions API | 3874516 | Use `\param[out]
config_entries` |

## Summary by PR

| PR | Issues |
|----|--------|
| **microsoft#26828** (c54be3c) - OrtExternalResourceImporter API for D3D12 |
Duplicate Doxygen group, incorrect `\param` names for
`ORT_CLASS_RELEASE` macros |
| **microsoft#26927** (1ed8fd9) - Control flow kernels API | `::Method()` syntax
unresolvable by Doxygen |
| **microsoft#26971** (3874516) - CreateEnvWithOptions API | `::Method()`
syntax, `<ep_name>` HTML interpretation, incorrect param name |

## Technical Details

### `ORT_CLASS_RELEASE` Macro Issue

The `ORT_CLASS_RELEASE(X)` macro at line 164 expands to:
```cpp
void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
```

The parameter is always named `input`, but the documentation in PR
microsoft#26828 used semantic names like `importer` and `handle`. Doxygen
validates `\param` names against actual parameter names in the expanded
code.

### Doxygen Link Resolution

Doxygen 1.9.8 cannot resolve `::MethodName()` as a link to a method. The
correct syntax is to qualify with the struct name: `OrtApi::MethodName`.

## Testing

Verified locally with Doxygen 1.9.8 (matches CI configuration).

This was referenced

Feb 9, 2026

This was referenced

Feb 23, 2026