ONNX Runtime
Loading...
Searching...
No Matches
onnxruntime_ep_c_api.h
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4// Do not include this file directly. Please include "onnxruntime_c_api.h" instead.
5
6#if defined(__DOXYGEN__)
7// When running a Doxygen build, include onnxruntime_c_api.h. Doxygen expects header files to be self-contained.
8#include "onnxruntime_c_api.h"
9#else
10// In normal usage, do not include onnxruntime_c_api.h. This file is explicitly included in onnxruntime_c_api.h.
11#endif
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
20ORT_RUNTIME_CLASS(Ep);
21ORT_RUNTIME_CLASS(EpFactory);
22ORT_RUNTIME_CLASS(EpGraphSupportInfo);
23ORT_RUNTIME_CLASS(MemoryDevice); // opaque class to wrap onnxruntime::OrtDevice
24ORT_RUNTIME_CLASS(NodeComputeContext);
25
26ORT_RUNTIME_CLASS(DataTransferImpl);
27ORT_RUNTIME_CLASS(SyncNotificationImpl);
28ORT_RUNTIME_CLASS(SyncStreamImpl);
29
30ORT_RUNTIME_CLASS(ExternalResourceImporterImpl);
31
32ORT_RUNTIME_CLASS(OpSchema);
33ORT_RUNTIME_CLASS(OpSchemaTypeConstraint);
34ORT_RUNTIME_CLASS(ProfilingEventsContainer);
35ORT_RUNTIME_CLASS(ProfilingEvent); // Based on the Trace Event Format's "complete event"
37
66
93
94// Opaque types for kernel-based EPs
95ORT_RUNTIME_CLASS(KernelRegistry);
96ORT_RUNTIME_CLASS(KernelDefBuilder);
97ORT_RUNTIME_CLASS(KernelDef);
98ORT_RUNTIME_CLASS(DataType); // combination of ONNXType (e.g., Tensor, Map, Sequence) and ONNXTensorElementDataType
99ORT_RUNTIME_CLASS(SharedPrePackedWeightCache);
100
107
117 ORT_API_T(void, Release, _In_ OrtDataTransferImpl* this_ptr);
118
128 ORT_API_T(bool, CanCopy, _In_ const OrtDataTransferImpl* this_ptr,
129 _In_ const OrtMemoryDevice* src_memory_device, _In_ const OrtMemoryDevice* dst_memory_device);
130
147 ORT_API2_STATUS(CopyTensors, _In_ OrtDataTransferImpl* this_ptr,
148 _In_reads_(num_tensors) const OrtValue** src_tensors,
149 _In_reads_(num_tensors) OrtValue** dst_tensors,
150 _In_reads_(num_tensors) OrtSyncStream** streams,
151 _In_ size_t num_tensors);
152};
153
160
170 ORT_API_T(void, Release, _In_ OrtSyncNotificationImpl* this_ptr);
171
178 ORT_API2_STATUS(Activate, _In_ OrtSyncNotificationImpl* this_ptr);
179
187 ORT_API2_STATUS(WaitOnDevice, _In_ OrtSyncNotificationImpl* this_ptr, _In_ OrtSyncStream* consumer_stream);
188
195 ORT_API2_STATUS(WaitOnHost, _In_ OrtSyncNotificationImpl* this_ptr);
196};
197
206
216 ORT_API_T(void, Release, _In_ OrtSyncStreamImpl* this_ptr);
217
227 ORT_API_T(void*, GetHandle, _In_ OrtSyncStreamImpl* this_ptr);
228
236 ORT_API2_STATUS(CreateNotification, _In_ OrtSyncStreamImpl* this_ptr,
237 _Outptr_ OrtSyncNotificationImpl** notification);
238
247 ORT_API2_STATUS(Flush, _In_ OrtSyncStreamImpl* this_ptr);
248
258 ORT_API2_STATUS(OnSessionRunEnd, _In_ OrtSyncStreamImpl* this_ptr);
259};
260
271
272 // Memory operations (stream-independent)
273
282 ORT_API_T(bool, CanImportMemory,
283 _In_ const OrtExternalResourceImporterImpl* this_ptr,
285
299 ORT_API2_STATUS(ImportMemory,
300 _In_ OrtExternalResourceImporterImpl* this_ptr,
301 _In_ const OrtExternalMemoryDescriptor* desc,
302 _Outptr_ OrtExternalMemoryHandle** out_handle);
303
313 ORT_API_T(void, ReleaseMemory,
314 _In_ OrtExternalResourceImporterImpl* this_ptr,
316
330 ORT_API2_STATUS(CreateTensorFromMemory,
331 _In_ OrtExternalResourceImporterImpl* this_ptr,
332 _In_ const OrtExternalMemoryHandle* mem_handle,
333 _In_ const OrtExternalTensorDescriptor* tensor_desc,
334 _Outptr_ OrtValue** out_tensor);
335
336 // Semaphore operations (require stream)
337
346 ORT_API_T(bool, CanImportSemaphore,
347 _In_ const OrtExternalResourceImporterImpl* this_ptr,
349
363 ORT_API2_STATUS(ImportSemaphore,
364 _In_ OrtExternalResourceImporterImpl* this_ptr,
365 _In_ const OrtExternalSemaphoreDescriptor* desc,
366 _Outptr_ OrtExternalSemaphoreHandle** out_handle);
367
377 ORT_API_T(void, ReleaseSemaphore,
378 _In_ OrtExternalResourceImporterImpl* this_ptr,
380
395 ORT_API2_STATUS(WaitSemaphore,
396 _In_ OrtExternalResourceImporterImpl* this_ptr,
397 _In_ OrtExternalSemaphoreHandle* handle,
398 _In_ OrtSyncStream* stream,
399 _In_ uint64_t value);
400
415 ORT_API2_STATUS(SignalSemaphore,
416 _In_ OrtExternalResourceImporterImpl* this_ptr,
417 _In_ OrtExternalSemaphoreHandle* handle,
418 _In_ OrtSyncStream* stream,
419 _In_ uint64_t value);
420
421 // Release the capability object itself
422
432 ORT_API_T(void, Release, _In_ OrtExternalResourceImporterImpl* this_ptr);
433};
434
439typedef enum OrtProfilingEventCategory {
440 OrtProfilingEventCategory_SESSION = 0,
441 OrtProfilingEventCategory_NODE = 1,
442 OrtProfilingEventCategory_KERNEL = 2,
443 OrtProfilingEventCategory_API = 3,
444} OrtProfilingEventCategory;
445
446struct OrtEpProfilerImpl;
448
480
492 ORT_API_T(void, Release, _In_ OrtEpProfilerImpl* this_ptr);
493
517 ORT_API2_STATUS(StartProfiling, _In_ OrtEpProfilerImpl* this_ptr, _In_ int64_t ep_profiling_start_offset_ns);
518
561 ORT_API2_STATUS(StartEvent, _In_ OrtEpProfilerImpl* this_ptr, _In_ uint64_t ort_event_correlation_id);
562
607 ORT_API2_STATUS(StopEvent, _In_ OrtEpProfilerImpl* this_ptr, _In_ uint64_t ort_event_correlation_id,
608 _In_ const OrtProfilingEvent* ort_event);
609
629 ORT_API2_STATUS(EndProfiling, _In_ OrtEpProfilerImpl* this_ptr,
630 _In_ OrtProfilingEventsContainer* events_container);
631};
632
635
636struct OrtNodeComputeInfo;
638
655
667
668 // const OrtNode* fused_node_schema;
669};
670
685
698 OrtStatus*(ORT_API_CALL* CreateState)(_In_ OrtNodeComputeInfo* this_ptr,
699 _In_ OrtNodeComputeContext* compute_context,
700 _Outptr_ void** compute_state);
701
711 OrtStatus*(ORT_API_CALL* Compute)(_In_ OrtNodeComputeInfo* this_ptr, _In_ void* compute_state,
712 _In_ OrtKernelContext* kernel_context);
713
720 void(ORT_API_CALL* ReleaseState)(_In_ OrtNodeComputeInfo* this_ptr, _Frees_ptr_opt_ void* compute_state);
721};
722
723struct OrtKernelImpl;
724typedef struct OrtKernelImpl OrtKernelImpl;
725
732 uint32_t flags;
733
745 ORT_API2_STATUS(Compute, _In_ OrtKernelImpl* this_ptr, _In_ OrtKernelContext* context);
746
755 ORT_API_T(void, Release, _In_ OrtKernelImpl* this_ptr);
756
809 ORT_API2_STATUS(PrePackWeight, _In_ OrtKernelImpl* this_ptr, _In_ const OrtValue* tensor,
810 _In_ int input_index, _Inout_ OrtAllocator* allocator,
811 _In_opt_ OrtSharedPrePackedWeightCache* prepacked_weight_cache, _Out_ bool* is_packed);
812
847 ORT_API2_STATUS(SetSharedPrePackedWeight, _In_ OrtKernelImpl* this_ptr,
848 _In_reads_(num_buffers) const void* const* buffer_data_ptrs,
849 _In_reads_(num_buffers) const size_t* buffer_data_sizes,
850 _In_ size_t num_buffers, _In_ int input_index);
851};
852
866typedef OrtStatus*(ORT_API_CALL* OrtKernelCreateFunc)(_In_ void* kernel_create_func_state,
867 _In_ const OrtKernelInfo* info,
868 _Outptr_result_maybenull_ OrtKernelImpl** kernel_out);
869
872
879
886 ORT_API_T(void, Release, _In_ OrtLoopKernelHelper* this_ptr);
887
907 ORT_API2_STATUS(ConcatOutput, _In_ OrtLoopKernelHelper* this_ptr, _In_opt_ void* stream_handle,
908 _In_reads_(num_per_iteration_outputs) const OrtValue* const* per_iteration_outputs,
909 _In_ size_t num_per_iteration_outputs, _Out_writes_bytes_all_(output_size_in_bytes) void* output,
910 _In_ size_t output_size_in_bytes);
911};
912
915
922
929 ORT_API_T(void, Release, _In_ OrtScanKernelHelper* this_ptr);
930
948 ORT_API2_STATUS(Transpose, _In_ OrtScanKernelHelper* this_ptr,
949 _In_reads_(num_permutation_elems) const size_t* permutation, _In_ size_t num_permutation_elems,
950 _In_ const OrtValue* input, _In_opt_ OrtSyncStream* stream, _Inout_ OrtValue* output);
951};
952
961typedef enum OrtResourceCountKind {
962 OrtResourceCountKind_None = 0,
963 OrtResourceCountKind_TotalBytes = 1,
964} OrtResourceCountKind;
965
979typedef struct OrtResourceCount {
980 uint32_t kind;
981 uint32_t reserved;
983 union {
984 uint64_t total_bytes;
985 uint64_t reserved_words[6];
987
988#ifdef __cplusplus
990 OrtResourceCount() noexcept : kind{OrtResourceCountKind_None}, reserved{0}, value{} {}
991
993 static OrtResourceCount None() noexcept {
994 return OrtResourceCount{};
995 }
996
998 static OrtResourceCount FromTotalBytes(uint64_t bytes) noexcept {
999 OrtResourceCount rc{};
1000 rc.kind = OrtResourceCountKind_TotalBytes;
1001 rc.value.total_bytes = bytes;
1002 return rc;
1003 }
1004
1006 uint64_t AsTotalBytes() const noexcept {
1007 return value.total_bytes;
1008 }
1009#endif
1011
1012#ifdef __cplusplus
1013static_assert(sizeof(OrtResourceCount) == 56, "OrtResourceCount size must not change to maintain ABI stability");
1014#endif
1015
1021struct OrtEpApi {
1035 ORT_API2_STATUS(CreateEpDevice, _In_ OrtEpFactory* ep_factory,
1036 _In_ const OrtHardwareDevice* hardware_device,
1037 _In_opt_ const OrtKeyValuePairs* ep_metadata,
1038 _In_opt_ const OrtKeyValuePairs* ep_options,
1039 _Out_ OrtEpDevice** ep_device);
1040
1041 ORT_CLASS_RELEASE(EpDevice);
1042
1060 ORT_API2_STATUS(EpGraphSupportInfo_AddNodesToFuse, _In_ OrtEpGraphSupportInfo* graph_support_info,
1061 _In_reads_(num_nodes) const OrtNode* const* nodes, _In_ size_t num_nodes,
1062 _In_opt_ const OrtNodeFusionOptions* node_fusion_options);
1063
1073 ORT_API2_STATUS(EpGraphSupportInfo_AddSingleNode, _In_ OrtEpGraphSupportInfo* graph_support_info,
1074 _In_ const OrtNode* node);
1075
1087 ORT_API_T(const char*, NodeComputeContext_NodeName, _In_ const OrtNodeComputeContext* context);
1088
1111 ORT_API2_STATUS(EpDevice_AddAllocatorInfo, _In_ OrtEpDevice* ep_device,
1112 _In_ const OrtMemoryInfo* allocator_memory_info);
1113
1124 ORT_API_T(const OrtMemoryDevice*, MemoryInfo_GetMemoryDevice, _In_ const OrtMemoryInfo* memory_info);
1125
1133 ORT_API_T(const OrtMemoryDevice*, Value_GetMemoryDevice, _In_ const OrtValue* value);
1134
1146 ORT_API_T(bool, MemoryDevice_AreEqual, _In_ const OrtMemoryDevice* a, _In_ const OrtMemoryDevice* b);
1147
1156
1165
1177 ORT_API_T(uint32_t, MemoryDevice_GetVendorId, _In_ const OrtMemoryDevice* memory_device);
1178
1186 ORT_API_T(uint32_t, MemoryDevice_GetDeviceId, _In_ const OrtMemoryDevice* memory_device);
1187
1199 ORT_API_T(const OrtSyncStreamImpl*, SyncStream_GetImpl, _In_ const OrtSyncStream* stream);
1200
1208 ORT_API_T(uint64_t, SyncStream_GetSyncId, _In_ const OrtSyncStream* stream);
1209
1220 ORT_API_T(uint64_t, GetSyncIdForLastWaitOnSyncStream,
1221 _In_ const OrtSyncStream* producer_stream, _In_ const OrtSyncStream* consumer_stream);
1222
1241 ORT_API2_STATUS(CreateHardwareDevice, _In_ OrtHardwareDeviceType type,
1242 _In_ uint32_t vendor_id,
1243 _In_ uint32_t device_id,
1244 _In_ const char* vendor_name,
1245 _In_opt_ const OrtKeyValuePairs* metadata,
1246 _Out_ OrtHardwareDevice** hardware_device);
1247
1248 ORT_CLASS_RELEASE(HardwareDevice);
1249
1262 ORT_API2_STATUS(CreateKernelRegistry, _Outptr_ OrtKernelRegistry** kernel_registry);
1263
1264 ORT_CLASS_RELEASE(KernelRegistry);
1265
1279 ORT_API2_STATUS(KernelRegistry_AddKernel, _In_ OrtKernelRegistry* kernel_registry,
1280 _In_ const OrtKernelDef* kernel_def, _In_ OrtKernelCreateFunc kernel_create_func,
1281 _In_ void* kernel_create_func_state);
1282
1292 ORT_API2_STATUS(CreateKernelDefBuilder, _Outptr_ OrtKernelDefBuilder** kernel_def_builder_out);
1293
1294 ORT_CLASS_RELEASE(KernelDefBuilder);
1295
1305 ORT_API2_STATUS(KernelDefBuilder_SetOperatorType, _In_ OrtKernelDefBuilder* kernel_def_builder,
1306 _In_ const char* op_type);
1307
1317 ORT_API2_STATUS(KernelDefBuilder_SetDomain, _In_ OrtKernelDefBuilder* kernel_def_builder, _In_ const char* domain);
1318
1331 ORT_API2_STATUS(KernelDefBuilder_SetSinceVersion, _In_ OrtKernelDefBuilder* kernel_def_builder,
1332 _In_ int since_version_start, _In_ int since_version_end);
1333
1343 ORT_API2_STATUS(KernelDefBuilder_SetExecutionProvider, _In_ OrtKernelDefBuilder* kernel_def_builder,
1344 _In_ const char* ep_name);
1345
1356 ORT_API2_STATUS(KernelDefBuilder_SetInputMemType, _In_ OrtKernelDefBuilder* kernel_def_builder,
1357 _In_ size_t input_index, _In_ OrtMemType mem_type);
1358
1369 ORT_API2_STATUS(KernelDefBuilder_SetOutputMemType, _In_ OrtKernelDefBuilder* kernel_def_builder,
1370 _In_ size_t output_index, _In_ OrtMemType mem_type);
1371
1384 ORT_API2_STATUS(KernelDefBuilder_AddTypeConstraint, _In_ OrtKernelDefBuilder* kernel_def_builder,
1385 _In_ const char* arg_name, _In_reads_(num_types) const OrtDataType* const* types,
1386 _In_ size_t num_types);
1387
1403 ORT_API2_STATUS(KernelDefBuilder_AddInputOutputAliases, _In_ OrtKernelDefBuilder* kernel_def_builder,
1404 _In_reads_(num_io_indices) int const* input_indices,
1405 _In_reads_(num_io_indices) int const* output_indices,
1406 _In_ size_t num_io_indices);
1407
1423 ORT_API2_STATUS(KernelDefBuilder_AddInputOutputMutableAliases, _In_ OrtKernelDefBuilder* kernel_def_builder,
1424 _In_reads_(num_io_indices) int const* input_indices,
1425 _In_reads_(num_io_indices) int const* output_indices,
1426 _In_ size_t num_io_indices);
1427
1437 ORT_API2_STATUS(KernelDefBuilder_Build, _In_ OrtKernelDefBuilder* kernel_def_builder,
1438 _Outptr_ OrtKernelDef** kernel_def_out);
1439
1440 ORT_CLASS_RELEASE(KernelDef);
1441
1449 ORT_API_T(const char*, KernelDef_GetOperatorType, _In_ const OrtKernelDef* kernel_def);
1450
1458 ORT_API_T(const char*, KernelDef_GetDomain, _In_ const OrtKernelDef* kernel_def);
1459
1470 ORT_API2_STATUS(KernelDef_GetSinceVersion, _In_ const OrtKernelDef* kernel_def,
1471 _Out_ int* start_version, _Out_ int* end_version);
1472
1480 ORT_API_T(const char*, KernelDef_GetExecutionProvider, _In_ const OrtKernelDef* kernel_def);
1481
1492 ORT_API2_STATUS(KernelDef_GetInputMemType, _In_ const OrtKernelDef* kernel_def,
1493 _In_ size_t input_index, _Out_ OrtMemType* mem_type);
1494
1505 ORT_API2_STATUS(KernelDef_GetOutputMemType, _In_ const OrtKernelDef* kernel_def,
1506 _In_ size_t output_index, _Out_ OrtMemType* mem_type);
1507
1517 ORT_API2_STATUS(GetTensorDataType, _In_ ONNXTensorElementDataType elem_type,
1518 _Outptr_ const OrtDataType** out);
1519
1535 ORT_API2_STATUS(EpGraphSupportInfo_LookUpKernel, _In_ OrtEpGraphSupportInfo* graph_support_info,
1536 _In_ const OrtNode* node, _Outptr_result_maybenull_ const OrtKernelDef** out_kernel_def);
1537
1563 _In_ OrtSharedPrePackedWeightCache* prepacked_weight_cache,
1564 _In_reads_(num_buffers) void** buffer_data_ptrs, _In_reads_(num_buffers) size_t* buffer_data_sizes,
1565 _In_ size_t num_buffers);
1566
1577 ORT_API2_STATUS(KernelInfo_GetEp, _In_ const OrtKernelInfo* info, _Outptr_ const OrtEp** ep);
1578
1596 _In_ uint32_t reasons_bitmask,
1597 _In_ int32_t error_code,
1598 _In_opt_z_ const char* notes);
1599
1628 ORT_API2_STATUS(CreateIfKernel, _In_ const OrtKernelInfo* kernel_info, _Outptr_ OrtKernelImpl** kernel_out);
1629
1664 ORT_API2_STATUS(CreateLoopKernel, _In_ const OrtKernelInfo* kernel_info, _In_ OrtLoopKernelHelper* helper,
1665 _Outptr_ OrtKernelImpl** kernel_out);
1666
1696 ORT_API2_STATUS(CreateScanKernel, _In_ const OrtKernelInfo* kernel_info, _In_ OrtScanKernelHelper* helper,
1697 _Outptr_ OrtKernelImpl** kernel_out);
1698
1699 ORT_CLASS_RELEASE(KernelImpl);
1700
1716 ORT_API2_STATUS(GetEnvConfigEntries, _Outptr_ OrtKeyValuePairs** config_entries);
1717
1737 ORT_API2_STATUS(GetOpSchema, _In_ const char* name, _In_ int max_inclusive_version,
1738 _In_ const char* domain, _Outptr_result_maybenull_ OrtOpSchema** out_schema);
1739
1740 ORT_CLASS_RELEASE(OpSchema);
1741
1759 ORT_API2_STATUS(OpSchema_GetSinceVersion, _In_ const OrtOpSchema* schema, _Out_ int* out);
1760
1770 ORT_API2_STATUS(OpSchema_GetNumInputs, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
1771
1783 ORT_API2_STATUS(OpSchema_GetInputName, _In_ const OrtOpSchema* schema, _In_ size_t index,
1784 _Outptr_ const char** out);
1785
1803 ORT_API2_STATUS(OpSchema_GetInputTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
1804 _Outptr_result_maybenull_ const OrtOpSchemaTypeConstraint** out);
1805
1815 ORT_API2_STATUS(OpSchema_GetNumOutputs, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
1816
1828 ORT_API2_STATUS(OpSchema_GetOutputName, _In_ const OrtOpSchema* schema, _In_ size_t index,
1829 _Outptr_ const char** out);
1830
1849 ORT_API2_STATUS(OpSchema_GetOutputTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
1850 _Outptr_result_maybenull_ const OrtOpSchemaTypeConstraint** out);
1851
1861 ORT_API2_STATUS(OpSchema_GetTypeConstraintCount, _In_ const OrtOpSchema* schema, _Out_ size_t* out);
1862
1884 ORT_API2_STATUS(OpSchema_GetTypeConstraint, _In_ const OrtOpSchema* schema, _In_ size_t index,
1885 _Outptr_ const OrtOpSchemaTypeConstraint** out);
1886
1897 ORT_API2_STATUS(OpSchemaTypeConstraint_GetTypeParamName, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
1898 _Outptr_ const char** out);
1899
1915 ORT_API2_STATUS(OpSchemaTypeConstraint_GetAllowedTypes, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
1916 _Outptr_ const char* const** out_types, _Out_ size_t* num_types);
1917
1931 ORT_API2_STATUS(OpSchemaTypeConstraint_GetInputIndices, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
1932 _Outptr_ const size_t** out_indices, _Out_ size_t* count);
1933
1947 ORT_API2_STATUS(OpSchemaTypeConstraint_GetOutputIndices, _In_ const OrtOpSchemaTypeConstraint* type_constraint,
1948 _Outptr_ const size_t** out_indices, _Out_ size_t* count);
1949
1977 ORT_API2_STATUS(CreateProfilingEvent,
1978 _In_ OrtProfilingEventCategory category,
1979 _In_ int32_t process_id,
1980 _In_ int32_t thread_id,
1981 _In_ const char* event_name,
1982 _In_ int64_t timestamp_us,
1983 _In_ int64_t duration_us,
1984 _In_reads_(num_args) const char* const* arg_keys,
1985 _In_reads_(num_args) const char* const* arg_values,
1986 _In_ size_t num_args,
1987 _Outptr_ OrtProfilingEvent** out);
1988
1993 ORT_CLASS_RELEASE(ProfilingEvent);
1994
2004 ORT_API2_STATUS(ProfilingEvent_GetCategory, _In_ const OrtProfilingEvent* event,
2005 _Out_ OrtProfilingEventCategory* out);
2006
2017 ORT_API2_STATUS(ProfilingEvent_GetName, _In_ const OrtProfilingEvent* event,
2018 _Outptr_ const char** out);
2019
2030 ORT_API2_STATUS(ProfilingEvent_GetTimestampUs, _In_ const OrtProfilingEvent* event,
2031 _Out_ int64_t* out);
2032
2042 ORT_API2_STATUS(ProfilingEvent_GetDurationUs, _In_ const OrtProfilingEvent* event,
2043 _Out_ int64_t* out);
2044
2058 ORT_API2_STATUS(ProfilingEvent_GetArgValue, _In_ const OrtProfilingEvent* event, _In_ const char* key,
2059 _Outptr_result_maybenull_ const char** out);
2060
2077 ORT_API2_STATUS(ProfilingEventsContainer_AddEvents, _In_ OrtProfilingEventsContainer* events_container,
2078 _In_reads_(num_events) const OrtProfilingEvent* const* events,
2079 _In_ size_t num_events);
2080};
2081
2090typedef enum OrtEpDataLayout {
2091 OrtEpDataLayout_NCHW = 0,
2092 OrtEpDataLayout_NHWC,
2093
2094 OrtEpDataLayout_Default = OrtEpDataLayout_NCHW,
2095} OrtEpDataLayout;
2096
2105typedef enum OrtGraphCaptureNodeAssignmentPolicy {
2107 OrtGraphCaptureNodeAssignmentPolicy_ALL_NODES_ON_EP = 0,
2108
2111 OrtGraphCaptureNodeAssignmentPolicy_ALLOW_CPU_FOR_SHAPES = 1,
2112} OrtGraphCaptureNodeAssignmentPolicy;
2113
2118struct OrtEp {
2127
2137 ORT_API_T(const char*, GetName, _In_ const OrtEp* this_ptr);
2138
2155 ORT_API2_STATUS(GetCapability, _In_ OrtEp* this_ptr, _In_ const OrtGraph* graph,
2156 _Inout_ OrtEpGraphSupportInfo* graph_support_info);
2157
2198 ORT_API2_STATUS(Compile, _In_ OrtEp* this_ptr, _In_ const OrtGraph** graphs,
2199 _In_ const OrtNode** fused_nodes, _In_ size_t count,
2200 _Out_writes_all_(count) OrtNodeComputeInfo** node_compute_infos,
2201 _Out_writes_(count) OrtNode** ep_context_nodes);
2202
2214 ORT_API_T(void, ReleaseNodeComputeInfos, _In_ OrtEp* this_ptr,
2215 OrtNodeComputeInfo** node_compute_infos,
2216 _In_ size_t num_node_compute_infos);
2217
2230 ORT_API2_STATUS(GetPreferredDataLayout, _In_ OrtEp* this_ptr, _Out_ OrtEpDataLayout* preferred_data_layout);
2231
2254 ORT_API2_STATUS(ShouldConvertDataLayoutForOp, _In_ OrtEp* this_ptr,
2255 _In_z_ const char* domain, _In_z_ const char* op_type,
2256 _In_ OrtEpDataLayout target_data_layout,
2257 _Outptr_ int* should_convert);
2258
2275 ORT_API2_STATUS(SetDynamicOptions, _In_ OrtEp* this_ptr,
2276 _In_reads_(num_options) const char* const* option_keys,
2277 _In_reads_(num_options) const char* const* option_values,
2278 _In_ size_t num_options);
2279
2293 ORT_API2_STATUS(OnRunStart, _In_ OrtEp* this_ptr, _In_ const OrtRunOptions* run_options);
2294
2310 ORT_API2_STATUS(OnRunEnd, _In_ OrtEp* this_ptr, _In_ const OrtRunOptions* run_options, _In_ bool sync_stream);
2311
2327 ORT_API2_STATUS(CreateAllocator, _In_ OrtEp* this_ptr,
2328 _In_ const OrtMemoryInfo* memory_info,
2329 _Outptr_result_maybenull_ OrtAllocator** allocator);
2330
2347 ORT_API2_STATUS(CreateSyncStreamForDevice, _In_ OrtEp* this_ptr,
2348 _In_ const OrtMemoryDevice* memory_device,
2349 _Outptr_ OrtSyncStreamImpl** stream);
2350
2366 ORT_API_T(const char*, GetCompiledModelCompatibilityInfo, _In_ OrtEp* this_ptr,
2367 _In_ const OrtGraph* graph);
2368
2382 ORT_API2_STATUS(GetKernelRegistry, _In_ OrtEp* this_ptr,
2383 _Outptr_result_maybenull_ const OrtKernelRegistry** kernel_registry);
2384
2397 ORT_API2_STATUS(IsConcurrentRunSupported, _In_ OrtEp* this_ptr, _Outptr_ bool* is_supported);
2398
2412 ORT_API2_STATUS(Sync, _In_ OrtEp* this_ptr);
2413
2435 ORT_API2_STATUS(CreateProfiler, _In_ OrtEp* this_ptr,
2436 _Outptr_result_maybenull_ OrtEpProfilerImpl** profiler);
2437
2477 ORT_API_T(bool, IsGraphCaptureEnabled, _In_ const OrtEp* this_ptr);
2478
2497 ORT_API_T(bool, IsGraphCaptured, _In_ const OrtEp* this_ptr, _In_ int graph_annotation_id);
2498
2515 ORT_API2_STATUS(ReplayGraph, _In_ OrtEp* this_ptr, _In_ int graph_annotation_id);
2516
2530 ORT_API_T(OrtGraphCaptureNodeAssignmentPolicy, GetGraphCaptureNodeAssignmentPolicy,
2531 _In_ const OrtEp* this_ptr);
2532
2553 ORT_API2_STATUS(GetAvailableResource, _In_ const OrtEp* this_ptr, _Out_ OrtResourceCount* available);
2554
2569 ORT_API2_STATUS(OnSessionInitializationEnd, _In_ OrtEp* this_ptr);
2570
2591 ORT_API2_STATUS(ReleaseCapturedGraph, _In_ OrtEp* this_ptr, _In_ int graph_annotation_id);
2592};
2593
2613typedef OrtStatus* (*CreateEpApiFactoriesFn)(_In_ const char* registered_name, _In_ const OrtApiBase* ort_api_base,
2614 _In_ const OrtLogger* default_logger,
2615 _Inout_ OrtEpFactory** factories, _In_ size_t max_factories,
2616 _Out_ size_t* num_factories);
2617
2628typedef OrtStatus* (*ReleaseEpApiFactoryFn)(_In_ OrtEpFactory* factory);
2629
2643
2653 ORT_API_T(const char*, GetName, const OrtEpFactory* this_ptr);
2654
2664 ORT_API_T(const char*, GetVendor, const OrtEpFactory* this_ptr); // return EP vendor
2665
2683 ORT_API2_STATUS(GetSupportedDevices, _In_ OrtEpFactory* this_ptr,
2684 _In_reads_(num_devices) const OrtHardwareDevice* const* devices,
2685 _In_ size_t num_devices,
2686 _Inout_ OrtEpDevice** ep_devices,
2687 _In_ size_t max_ep_devices,
2688 _Out_ size_t* num_ep_devices);
2689
2714 ORT_API2_STATUS(CreateEp, _In_ OrtEpFactory* this_ptr,
2715 _In_reads_(num_devices) const OrtHardwareDevice* const* devices,
2716 _In_reads_(num_devices) const OrtKeyValuePairs* const* ep_metadata_pairs,
2717 _In_ size_t num_devices,
2718 _In_ const OrtSessionOptions* session_options,
2719 _In_ const OrtLogger* logger, _Outptr_ OrtEp** ep);
2720
2728 ORT_API_T(void, ReleaseEp, OrtEpFactory* this_ptr, struct OrtEp* ep);
2729
2739 ORT_API_T(uint32_t, GetVendorId, const OrtEpFactory* this_ptr);
2740
2753 ORT_API_T(const char*, GetVersion, _In_ const OrtEpFactory* this_ptr);
2754
2774 ORT_API2_STATUS(ValidateCompiledModelCompatibilityInfo, _In_ OrtEpFactory* this_ptr,
2775 _In_reads_(num_devices) const OrtHardwareDevice* const* devices,
2776 _In_ size_t num_devices,
2777 _In_ const char* compatibility_info,
2778 _Out_ OrtCompiledModelCompatibility* model_compatibility);
2779
2794 ORT_API2_STATUS(CreateAllocator, _In_ OrtEpFactory* this_ptr,
2795 _In_ const OrtMemoryInfo* memory_info,
2796 _In_opt_ const OrtKeyValuePairs* allocator_options,
2797 _Outptr_result_maybenull_ OrtAllocator** allocator);
2798
2803 ORT_API_T(void, ReleaseAllocator, _In_ OrtEpFactory* this_ptr, _In_ OrtAllocator* allocator);
2804
2817 ORT_API2_STATUS(CreateDataTransfer, _In_ OrtEpFactory* this_ptr,
2818 _Outptr_result_maybenull_ OrtDataTransferImpl** data_transfer);
2819
2827 ORT_API_T(bool, IsStreamAware, _In_ const OrtEpFactory* this_ptr);
2828
2843 ORT_API2_STATUS(CreateSyncStreamForDevice, _In_ OrtEpFactory* this_ptr,
2844 _In_ const OrtMemoryDevice* memory_device,
2845 _In_opt_ const OrtKeyValuePairs* stream_options,
2846 _Outptr_ OrtSyncStreamImpl** stream);
2847
2868 ORT_API2_STATUS(GetHardwareDeviceIncompatibilityDetails, _In_ OrtEpFactory* this_ptr,
2869 _In_ const OrtHardwareDevice* hw,
2871
2894 ORT_API2_STATUS(CreateExternalResourceImporterForDevice, _In_ OrtEpFactory* this_ptr,
2895 _In_ const OrtEpDevice* ep_device,
2896 _Outptr_result_maybenull_ OrtExternalResourceImporterImpl** out_importer);
2897
2907 ORT_API2_STATUS(GetNumCustomOpDomains, _In_ OrtEpFactory* this_ptr, _Out_ size_t* num_domains);
2908
2954 ORT_API2_STATUS(GetCustomOpDomains, _In_ OrtEpFactory* this_ptr,
2955 _Out_writes_all_(num_domains) OrtCustomOpDomain** domains, _In_ size_t num_domains);
2956
2985 ORT_API2_STATUS(InitGraphicsInterop, _In_ OrtEpFactory* this_ptr,
2986 _In_ const OrtEpDevice* ep_device,
2987 _In_ const OrtGraphicsInteropConfig* config);
2988
3004 ORT_API2_STATUS(DeinitGraphicsInterop, _In_ OrtEpFactory* this_ptr,
3005 _In_ const OrtEpDevice* ep_device);
3006};
3007
3008#ifdef __cplusplus
3009}
3010#endif
struct OrtMemoryInfo OrtMemoryInfo
Definition onnxruntime_c_api.h:308
struct OrtHardwareDevice OrtHardwareDevice
Definition onnxruntime_c_api.h:340
struct OrtKernelInfo OrtKernelInfo
Definition onnxruntime_c_api.h:484
struct OrtNode OrtNode
Definition onnxruntime_c_api.h:336
OrtMemoryInfoDeviceType
This mimics OrtDevice type constants so they can be returned in the API.
Definition onnxruntime_c_api.h:519
struct OrtMemoryDevice OrtMemoryDevice
Definition onnxruntime_ep_c_api.h:23
OrtExternalMemoryHandleType
External memory handle type for importing GPU resources.
Definition onnxruntime_c_api.h:1067
OrtCompiledModelCompatibility
Definition onnxruntime_c_api.h:1198
struct OrtNodeComputeContext OrtNodeComputeContext
Definition onnxruntime_ep_c_api.h:24
struct OrtCustomOpDomain OrtCustomOpDomain
Definition onnxruntime_c_api.h:319
OrtExternalSemaphoreType
External semaphore type for GPU synchronization.
Definition onnxruntime_c_api.h:1094
struct OrtOpSchema OrtOpSchema
Definition onnxruntime_ep_c_api.h:32
struct OrtEpGraphSupportInfo OrtEpGraphSupportInfo
Definition onnxruntime_ep_c_api.h:22
struct OrtProfilingEvent OrtProfilingEvent
Definition onnxruntime_ep_c_api.h:35
struct OrtKernelContext OrtKernelContext
Definition onnxruntime_c_api.h:486
struct OrtOpSchemaTypeConstraint OrtOpSchemaTypeConstraint
Definition onnxruntime_ep_c_api.h:33
struct OrtEpDevice OrtEpDevice
Definition onnxruntime_c_api.h:341
struct OrtRunOptions OrtRunOptions
Definition onnxruntime_c_api.h:312
OrtHardwareDeviceType
Definition onnxruntime_c_api.h:526
struct OrtGraph OrtGraph
Definition onnxruntime_c_api.h:337
struct OrtSyncStream OrtSyncStream
Definition onnxruntime_c_api.h:343
struct OrtSessionOptions OrtSessionOptions
Definition onnxruntime_c_api.h:318
OrtDeviceMemoryType
This matches OrtDevice::MemoryType values.
Definition onnxruntime_c_api.h:512
struct OrtValue OrtValue
Definition onnxruntime_c_api.h:311
struct OrtKeyValuePairs OrtKeyValuePairs
Definition onnxruntime_c_api.h:342
OrtMemType
Memory types for allocated memory, execution provider specific types should be extended in each provi...
Definition onnxruntime_c_api.h:500
struct OrtStatus OrtStatus
Definition onnxruntime_c_api.h:307
struct OrtDeviceEpIncompatibilityDetails OrtDeviceEpIncompatibilityDetails
Definition onnxruntime_c_api.h:348
struct OrtLogger OrtLogger
Definition onnxruntime_c_api.h:332
struct OrtProfilingEventsContainer OrtProfilingEventsContainer
Definition onnxruntime_ep_c_api.h:34
ONNXTensorElementDataType
Definition onnxruntime_c_api.h:191
Memory allocation interface.
Definition onnxruntime_c_api.h:364
The helper interface to get the right version of OrtApi.
Definition onnxruntime_c_api.h:935
Struct that an EP implements for IDataTransfer to copy between devices it uses and CPU.
Definition onnxruntime_ep_c_api.h:105
OrtStatus * CopyTensors(OrtDataTransferImpl *this_ptr, const OrtValue **src_tensors, OrtValue **dst_tensors, OrtSyncStream **streams, size_t num_tensors)
Copy tensors from src_tensors to dst_tensors using the provided streams.
bool(* CanCopy)(const OrtDataTransferImpl *this_ptr, const OrtMemoryDevice *src_memory_device, const OrtMemoryDevice *dst_memory_device)
Check if the implementation can copy between the source and destination memory devices.
Definition onnxruntime_ep_c_api.h:129
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:106
void(* Release)(OrtDataTransferImpl *this_ptr)
Release the OrtDataTransferImpl instance.
Definition onnxruntime_ep_c_api.h:117
The OrtEpApi struct provides functions that are relevant to the implementation of an execution provid...
Definition onnxruntime_ep_c_api.h:1021
OrtStatus * OpSchemaTypeConstraint_GetTypeParamName(const OrtOpSchemaTypeConstraint *type_constraint, const char **out)
Get the type parameter name of a type constraint (e.g., "T", "T1").
OrtStatus * OpSchema_GetOutputTypeConstraint(const OrtOpSchema *schema, size_t index, const OrtOpSchemaTypeConstraint **out)
Get the type constraint for the i-th output formal parameter from an operator schema.
const char *(* KernelDef_GetDomain)(const OrtKernelDef *kernel_def)
Returns the operator's domain from the kernel definition.
Definition onnxruntime_ep_c_api.h:1458
uint32_t(* MemoryDevice_GetVendorId)(const OrtMemoryDevice *memory_device)
Get the vendor ID from an OrtMemoryDevice instance.
Definition onnxruntime_ep_c_api.h:1177
uint64_t(* GetSyncIdForLastWaitOnSyncStream)(const OrtSyncStream *producer_stream, const OrtSyncStream *consumer_stream)
Get the sync ID for the last time the consumer_stream waited on the producer_stream.
Definition onnxruntime_ep_c_api.h:1221
OrtStatus * CreateHardwareDevice(OrtHardwareDeviceType type, uint32_t vendor_id, uint32_t device_id, const char *vendor_name, const OrtKeyValuePairs *metadata, OrtHardwareDevice **hardware_device)
Create an OrtHardwareDevice.
OrtMemoryInfoDeviceType(* MemoryDevice_GetDeviceType)(const OrtMemoryDevice *memory_device)
Get the OrtMemoryInfoDeviceType value from an OrtMemoryDevice instance.
Definition onnxruntime_ep_c_api.h:1155
OrtStatus * OpSchemaTypeConstraint_GetAllowedTypes(const OrtOpSchemaTypeConstraint *type_constraint, const char *const **out_types, size_t *num_types)
Get the allowed type strings for a type constraint.
const char *(* NodeComputeContext_NodeName)(const OrtNodeComputeContext *context)
Query a OrtNodeComputeContext for the name of the node that encapsulates the compiled/fused node.
Definition onnxruntime_ep_c_api.h:1087
OrtStatus * OpSchema_GetTypeConstraintCount(const OrtOpSchema *schema, size_t *out)
Get the number of unique type constraints in the operator schema.
OrtStatus * ProfilingEvent_GetDurationUs(const OrtProfilingEvent *event, int64_t *out)
Get the duration of a profiling event in microseconds.
OrtStatus * CreateIfKernel(const OrtKernelInfo *kernel_info, OrtKernelImpl **kernel_out)
Creates an OrtKernelImpl instance for an If operator.
bool(* MemoryDevice_AreEqual)(const OrtMemoryDevice *a, const OrtMemoryDevice *b)
Compare two OrtMemoryDevice instances for equality.
Definition onnxruntime_ep_c_api.h:1146
OrtStatus * ProfilingEvent_GetName(const OrtProfilingEvent *event, const char **out)
Get the event name of a profiling event.
const OrtMemoryDevice *(* MemoryInfo_GetMemoryDevice)(const OrtMemoryInfo *memory_info)
Get the OrtMemoryDevice from an OrtMemoryInfo instance.
Definition onnxruntime_ep_c_api.h:1124
OrtStatus * OpSchema_GetNumInputs(const OrtOpSchema *schema, size_t *out)
Get the number of inputs defined by the operator schema.
OrtStatus * KernelDefBuilder_AddInputOutputAliases(OrtKernelDefBuilder *kernel_def_builder, int const *input_indices, int const *output_indices, size_t num_io_indices)
Adds aliases for the given input and output pairs.
OrtStatus * KernelDefBuilder_SetExecutionProvider(OrtKernelDefBuilder *kernel_def_builder, const char *ep_name)
Sets the name of the kernel's intended execution provider.
OrtStatus * CreateKernelDefBuilder(OrtKernelDefBuilder **kernel_def_builder_out)
Creates a kernel definition builder used to create instances of OrtKernelDef.
OrtStatus * KernelRegistry_AddKernel(OrtKernelRegistry *kernel_registry, const OrtKernelDef *kernel_def, OrtKernelCreateFunc kernel_create_func, void *kernel_create_func_state)
Adds kernel creation information for a supported operator kernel to the given kernel registry.
const OrtSyncStreamImpl *(* SyncStream_GetImpl)(const OrtSyncStream *stream)
Get the OrtSyncStreamImpl associated with an OrtSyncStream instance.
Definition onnxruntime_ep_c_api.h:1199
OrtStatus * ProfilingEvent_GetArgValue(const OrtProfilingEvent *event, const char *key, const char **out)
Get the value of an event argument by its key.
OrtStatus * KernelDef_GetInputMemType(const OrtKernelDef *kernel_def, size_t input_index, OrtMemType *mem_type)
Gets the memory type for a kernel input.
OrtStatus * EpGraphSupportInfo_AddSingleNode(OrtEpGraphSupportInfo *graph_support_info, const OrtNode *node)
Specify a node that is supported by an OrtEp and should be run with a registered EP kernel.
OrtStatus * CreateLoopKernel(const OrtKernelInfo *kernel_info, OrtLoopKernelHelper *helper, OrtKernelImpl **kernel_out)
Creates an OrtKernelImpl instance for a Loop operator.
OrtStatus * CreateEpDevice(OrtEpFactory *ep_factory, const OrtHardwareDevice *hardware_device, const OrtKeyValuePairs *ep_metadata, const OrtKeyValuePairs *ep_options, OrtEpDevice **ep_device)
Create an OrtEpDevice for the EP and an OrtHardwareDevice.
OrtStatus * DeviceEpIncompatibilityDetails_SetDetails(OrtDeviceEpIncompatibilityDetails *details, uint32_t reasons_bitmask, int32_t error_code, const char *notes)
Set the details of an OrtDeviceEpIncompatibilityDetails instance.
OrtStatus * ProfilingEvent_GetCategory(const OrtProfilingEvent *event, OrtProfilingEventCategory *out)
Get the event category of a profiling event.
OrtStatus * OpSchema_GetNumOutputs(const OrtOpSchema *schema, size_t *out)
Get the number of outputs defined by the operator schema.
OrtStatus * KernelDefBuilder_AddInputOutputMutableAliases(OrtKernelDefBuilder *kernel_def_builder, int const *input_indices, int const *output_indices, size_t num_io_indices)
Adds mutable aliases for the given input and output pairs.
OrtStatus * CreateKernelRegistry(OrtKernelRegistry **kernel_registry)
Creates an empty kernel registry. A kernel registry contains kernel creation information for every op...
uint32_t(* MemoryDevice_GetDeviceId)(const OrtMemoryDevice *memory_device)
Get the device ID from an OrtMemoryDevice instance.
Definition onnxruntime_ep_c_api.h:1186
OrtStatus * OpSchema_GetInputName(const OrtOpSchema *schema, size_t index, const char **out)
Get the name of the i-th input formal parameter from an operator schema.
OrtDeviceMemoryType(* MemoryDevice_GetMemoryType)(const OrtMemoryDevice *memory_device)
Get the OrtDeviceMemoryType value from an OrtMemoryDevice instance.
Definition onnxruntime_ep_c_api.h:1164
OrtStatus * KernelDefBuilder_SetDomain(OrtKernelDefBuilder *kernel_def_builder, const char *domain)
Sets the kernel's domain.
OrtStatus * KernelDefBuilder_AddTypeConstraint(OrtKernelDefBuilder *kernel_def_builder, const char *arg_name, const OrtDataType *const *types, size_t num_types)
Adds type constraints for a kernel argument represented as a string (e.g., "T").
OrtStatus * EpGraphSupportInfo_AddNodesToFuse(OrtEpGraphSupportInfo *graph_support_info, const OrtNode *const *nodes, size_t num_nodes, const OrtNodeFusionOptions *node_fusion_options)
Specify nodes that are supported by an OrtEp and should be fused into one node.
OrtStatus * ProfilingEvent_GetTimestampUs(const OrtProfilingEvent *event, int64_t *out)
Get the start timestamp of a profiling event in microseconds.
OrtStatus * EpGraphSupportInfo_LookUpKernel(OrtEpGraphSupportInfo *graph_support_info, const OrtNode *node, const OrtKernelDef **out_kernel_def)
Gets the kernel definition for a given node, if any exists for the calling execution provider.
OrtStatus * GetTensorDataType(ONNXTensorElementDataType elem_type, const OrtDataType **out)
Gets the OrtDataType that represents the data type for a tensor of the given element type.
OrtStatus * KernelDefBuilder_SetOperatorType(OrtKernelDefBuilder *kernel_def_builder, const char *op_type)
Sets the kernel's operator type.
const char *(* KernelDef_GetOperatorType)(const OrtKernelDef *kernel_def)
Returns the operator type from the kernel definition.
Definition onnxruntime_ep_c_api.h:1449
OrtStatus * CreateProfilingEvent(OrtProfilingEventCategory category, int32_t process_id, int32_t thread_id, const char *event_name, int64_t timestamp_us, int64_t duration_us, const char *const *arg_keys, const char *const *arg_values, size_t num_args, OrtProfilingEvent **out)
Create a profiling event.
OrtStatus * KernelDefBuilder_SetOutputMemType(OrtKernelDefBuilder *kernel_def_builder, size_t output_index, OrtMemType mem_type)
Sets the memory type for a kernel output.
OrtStatus * CreateScanKernel(const OrtKernelInfo *kernel_info, OrtScanKernelHelper *helper, OrtKernelImpl **kernel_out)
Creates an OrtKernelImpl instance for a Scan operator. Does not support opset versions older than 9.
OrtStatus * OpSchema_GetInputTypeConstraint(const OrtOpSchema *schema, size_t index, const OrtOpSchemaTypeConstraint **out)
Get the type constraint for the i-th input formal parameter from an operator schema.
OrtStatus * KernelDefBuilder_Build(OrtKernelDefBuilder *kernel_def_builder, OrtKernelDef **kernel_def_out)
Creates a OrtKernelDef instance from the given kernel definition builder.
const OrtMemoryDevice *(* Value_GetMemoryDevice)(const OrtValue *value)
Get the OrtMemoryDevice from an OrtValue instance if it contains a Tensor.
Definition onnxruntime_ep_c_api.h:1133
OrtStatus * KernelDef_GetOutputMemType(const OrtKernelDef *kernel_def, size_t output_index, OrtMemType *mem_type)
Gets the memory type for a kernel output.
OrtStatus * KernelDef_GetSinceVersion(const OrtKernelDef *kernel_def, int *start_version, int *end_version)
Gets the kernel's opset version range that is supported.
OrtStatus * ProfilingEventsContainer_AddEvents(OrtProfilingEventsContainer *events_container, const OrtProfilingEvent *const *events, size_t num_events)
Add EP profiling events to an events container.
OrtStatus * GetEnvConfigEntries(OrtKeyValuePairs **config_entries)
Gets a new OrtKeyValuePairs instance containing a copy of all configuration entries set on the enviro...
OrtStatus * OpSchema_GetTypeConstraint(const OrtOpSchema *schema, size_t index, const OrtOpSchemaTypeConstraint **out)
Get the i-th type constraint from the operator schema.
OrtStatus * KernelDefBuilder_SetInputMemType(OrtKernelDefBuilder *kernel_def_builder, size_t input_index, OrtMemType mem_type)
Sets the memory type for a kernel input.
OrtStatus * OpSchemaTypeConstraint_GetInputIndices(const OrtOpSchemaTypeConstraint *type_constraint, const size_t **out_indices, size_t *count)
Get the input indices that use a type constraint.
const char *(* KernelDef_GetExecutionProvider)(const OrtKernelDef *kernel_def)
Returns the name of the kernel's intended execution provider.
Definition onnxruntime_ep_c_api.h:1480
OrtStatus * SharedPrePackedWeightCache_StoreWeightData(OrtSharedPrePackedWeightCache *prepacked_weight_cache, void **buffer_data_ptrs, size_t *buffer_data_sizes, size_t num_buffers)
Sets one or more data buffers that collectively hold the pre-packed data for a single shared weight.
OrtStatus * OpSchema_GetOutputName(const OrtOpSchema *schema, size_t index, const char **out)
Get the name of the i-th output formal parameter from an operator schema.
OrtStatus * KernelInfo_GetEp(const OrtKernelInfo *info, const OrtEp **ep)
Get the OrtEp instance to which the node is assigned from the OrtKernelInfo.
OrtStatus * OpSchemaTypeConstraint_GetOutputIndices(const OrtOpSchemaTypeConstraint *type_constraint, const size_t **out_indices, size_t *count)
Get the output indices that use a type constraint.
OrtStatus * GetOpSchema(const char *name, int max_inclusive_version, const char *domain, OrtOpSchema **out_schema)
Get an operator schema from the global schema registry.
OrtStatus * OpSchema_GetSinceVersion(const OrtOpSchema *schema, int *out)
Get the first ONNX opset version that introduced this operator schema.
OrtStatus * KernelDefBuilder_SetSinceVersion(OrtKernelDefBuilder *kernel_def_builder, int since_version_start, int since_version_end)
Sets the kernel's opset version range that is supported.
uint64_t(* SyncStream_GetSyncId)(const OrtSyncStream *stream)
Get the current sync ID for a stream.
Definition onnxruntime_ep_c_api.h:1208
OrtStatus * EpDevice_AddAllocatorInfo(OrtEpDevice *ep_device, const OrtMemoryInfo *allocator_memory_info)
Register an allocator with the OrtEpDevice.
The OrtEpFactory provides functions to create and manage execution providers.
Definition onnxruntime_ep_c_api.h:2634
OrtStatus * CreateEp(OrtEpFactory *this_ptr, const OrtHardwareDevice *const *devices, const OrtKeyValuePairs *const *ep_metadata_pairs, size_t num_devices, const OrtSessionOptions *session_options, const OrtLogger *logger, OrtEp **ep)
Function to create an OrtEp instance for use in a Session.
bool(* IsStreamAware)(const OrtEpFactory *this_ptr)
Check if execution providers created by the factory are stream aware.
Definition onnxruntime_ep_c_api.h:2827
uint32_t(* GetVendorId)(const OrtEpFactory *this_ptr)
Get the vendor id who owns the execution provider that the factory creates.
Definition onnxruntime_ep_c_api.h:2739
OrtStatus * GetSupportedDevices(OrtEpFactory *this_ptr, const OrtHardwareDevice *const *devices, size_t num_devices, OrtEpDevice **ep_devices, size_t max_ep_devices, size_t *num_ep_devices)
Get information from the execution provider about OrtHardwareDevice support.
OrtStatus * GetHardwareDeviceIncompatibilityDetails(OrtEpFactory *this_ptr, const OrtHardwareDevice *hw, OrtDeviceEpIncompatibilityDetails *details)
Check for known incompatibility reasons between a hardware device and this execution provider.
const char *(* GetVendor)(const OrtEpFactory *this_ptr)
Get the name of vendor who owns the execution provider that the factory creates.
Definition onnxruntime_ep_c_api.h:2664
OrtStatus * CreateExternalResourceImporterForDevice(OrtEpFactory *this_ptr, const OrtEpDevice *ep_device, OrtExternalResourceImporterImpl **out_importer)
Create an OrtExternalResourceImporterImpl for external resource import.
OrtStatus * CreateSyncStreamForDevice(OrtEpFactory *this_ptr, const OrtMemoryDevice *memory_device, const OrtKeyValuePairs *stream_options, OrtSyncStreamImpl **stream)
Create a synchronization stream for the given memory device.
OrtStatus * GetNumCustomOpDomains(OrtEpFactory *this_ptr, size_t *num_domains)
Returns the number of OrtCustomOpDomains that this factory provides.
OrtStatus * CreateDataTransfer(OrtEpFactory *this_ptr, OrtDataTransferImpl **data_transfer)
Create an OrtDataTransferImpl instance for the factory.
OrtStatus * ValidateCompiledModelCompatibilityInfo(OrtEpFactory *this_ptr, const OrtHardwareDevice *const *devices, size_t num_devices, const char *compatibility_info, OrtCompiledModelCompatibility *model_compatibility)
Validate the compatibility of a compiled model with the execution provider factory for one or more de...
OrtStatus * InitGraphicsInterop(OrtEpFactory *this_ptr, const OrtEpDevice *ep_device, const OrtGraphicsInteropConfig *config)
Initialize graphics interop for the EP factory.
OrtStatus * DeinitGraphicsInterop(OrtEpFactory *this_ptr, const OrtEpDevice *ep_device)
Deinitialize graphics interop for the EP factory.
const char *(* GetVersion)(const OrtEpFactory *this_ptr)
Get the version of the execution provider that the factory creates.
Definition onnxruntime_ep_c_api.h:2753
void(* ReleaseAllocator)(OrtEpFactory *this_ptr, OrtAllocator *allocator)
Release an OrtAllocator created by the factory.
Definition onnxruntime_ep_c_api.h:2803
uint32_t ort_version_supported
The ONNX Runtime version the execution provider was compiled with.
Definition onnxruntime_ep_c_api.h:2642
void(* ReleaseEp)(OrtEpFactory *this_ptr, struct OrtEp *ep)
Release the OrtEp instance.
Definition onnxruntime_ep_c_api.h:2728
OrtStatus * GetCustomOpDomains(OrtEpFactory *this_ptr, OrtCustomOpDomain **domains, size_t num_domains)
Gets the EP-specific OrtCustomOpDomains.
OrtStatus * CreateAllocator(OrtEpFactory *this_ptr, const OrtMemoryInfo *memory_info, const OrtKeyValuePairs *allocator_options, OrtAllocator **allocator)
Create an OrtAllocator that can be shared across sessions for the given OrtMemoryInfo.
const char *(* GetName)(const OrtEpFactory *this_ptr)
Get the name of the execution provider that the factory creates.
Definition onnxruntime_ep_c_api.h:2653
The OrtEp struct provides functions to implement for an execution provider.
Definition onnxruntime_ep_c_api.h:2118
void(* ReleaseNodeComputeInfos)(OrtEp *this_ptr, OrtNodeComputeInfo **node_compute_infos, size_t num_node_compute_infos)
Release OrtNodeComputeInfo instances.
Definition onnxruntime_ep_c_api.h:2216
OrtStatus * GetPreferredDataLayout(OrtEp *this_ptr, OrtEpDataLayout *preferred_data_layout)
Get the EP's preferred data layout.
const char *(* GetCompiledModelCompatibilityInfo)(OrtEp *this_ptr, const OrtGraph *graph)
Get a string with details about the EP stack used to produce a compiled model.
Definition onnxruntime_ep_c_api.h:2367
OrtStatus * CreateAllocator(OrtEp *this_ptr, const OrtMemoryInfo *memory_info, OrtAllocator **allocator)
Create an OrtAllocator for the given OrtMemoryInfo for an OrtSession.
OrtStatus * GetCapability(OrtEp *this_ptr, const OrtGraph *graph, OrtEpGraphSupportInfo *graph_support_info)
Get information about the nodes supported by the OrtEp instance.
OrtStatus * OnRunEnd(OrtEp *this_ptr, const OrtRunOptions *run_options, bool sync_stream)
Called by ORT to notify the EP of the end of a run.
OrtGraphCaptureNodeAssignmentPolicy(* GetGraphCaptureNodeAssignmentPolicy)(const OrtEp *this_ptr)
Get the node assignment validation policy for graph capture.
Definition onnxruntime_ep_c_api.h:2531
OrtStatus * CreateSyncStreamForDevice(OrtEp *this_ptr, const OrtMemoryDevice *memory_device, OrtSyncStreamImpl **stream)
Create a synchronization stream for the given memory device for an OrtSession.
OrtStatus * OnSessionInitializationEnd(OrtEp *this_ptr)
Called by ORT when session initialization is complete.
const char *(* GetName)(const OrtEp *this_ptr)
Get the execution provider name.
Definition onnxruntime_ep_c_api.h:2137
OrtStatus * SetDynamicOptions(OrtEp *this_ptr, const char *const *option_keys, const char *const *option_values, size_t num_options)
Set dynamic options on this EP.
bool(* IsGraphCaptured)(const OrtEp *this_ptr, int graph_annotation_id)
Indicate whether a graph has been captured and instantiated.
Definition onnxruntime_ep_c_api.h:2497
OrtStatus * Compile(OrtEp *this_ptr, const OrtGraph **graphs, const OrtNode **fused_nodes, size_t count, OrtNodeComputeInfo **node_compute_infos, OrtNode **ep_context_nodes)
Compile OrtGraph instances assigned to the OrtEp. Implementer must set a OrtNodeComputeInfo instance ...
OrtStatus * ReplayGraph(OrtEp *this_ptr, int graph_annotation_id)
Run the instantiated (captured) graph.
bool(* IsGraphCaptureEnabled)(const OrtEp *this_ptr)
Indicate whether the graph capturing mode (e.g., CUDA graph) is enabled for the provider.
Definition onnxruntime_ep_c_api.h:2477
OrtStatus * Sync(OrtEp *this_ptr)
Called by ORT to block until the device has completed all preceding requested tasks.
uint32_t ort_version_supported
The ONNX Runtime version the execution provider was compiled with.
Definition onnxruntime_ep_c_api.h:2126
OrtStatus * ShouldConvertDataLayoutForOp(OrtEp *this_ptr, const char *domain, const char *op_type, OrtEpDataLayout target_data_layout, int *should_convert)
Given an op with domain domain and type op_type, determine whether an associated node's data layout s...
OrtStatus * OnRunStart(OrtEp *this_ptr, const OrtRunOptions *run_options)
Called by ORT to notify the EP of the start of a run.
OrtStatus * GetKernelRegistry(OrtEp *this_ptr, const OrtKernelRegistry **kernel_registry)
Gets the execution provider's kernel registry, if any.
OrtStatus * IsConcurrentRunSupported(OrtEp *this_ptr, bool *is_supported)
Gets whether the execution provider supports concurrent run calls made on the session.
OrtStatus * ReleaseCapturedGraph(OrtEp *this_ptr, int graph_annotation_id)
Release a previously captured graph and its associated resources.
OrtStatus * CreateProfiler(OrtEp *this_ptr, OrtEpProfilerImpl **profiler)
Return a new profiler for the execution provider.
OrtStatus * GetAvailableResource(const OrtEp *this_ptr, OrtResourceCount *available)
Query the available device resource for partitioning budget.
Struct that an EP implements for profiling support.
Definition onnxruntime_ep_c_api.h:478
OrtStatus * StartEvent(OrtEpProfilerImpl *this_ptr, uint64_t ort_event_correlation_id)
Called when an ORT event (e.g., session initialization, node kernel execution, etc....
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:479
OrtStatus * StartProfiling(OrtEpProfilerImpl *this_ptr, int64_t ep_profiling_start_offset_ns)
Called when profiling starts.
void(* Release)(OrtEpProfilerImpl *this_ptr)
Release the OrtEpProfilerImpl instance.
Definition onnxruntime_ep_c_api.h:492
OrtStatus * EndProfiling(OrtEpProfilerImpl *this_ptr, OrtProfilingEventsContainer *events_container)
Called when profiling ends to collect the EP's new profiling events since the call to StartProfiling.
OrtStatus * StopEvent(OrtEpProfilerImpl *this_ptr, uint64_t ort_event_correlation_id, const OrtProfilingEvent *ort_event)
Called when a profiled ORT event (e.g., session initialization, node kernel execution,...
Descriptor for importing external memory.
Definition onnxruntime_c_api.h:1081
Base struct for imported external memory handles.
Definition onnxruntime_ep_c_api.h:54
const OrtEpDevice * ep_device
EP device that created this handle.
Definition onnxruntime_ep_c_api.h:56
void(* Release)(OrtExternalMemoryHandle *handle)
Release callback for this handle. EP sets this to its release function.
Definition onnxruntime_ep_c_api.h:64
OrtExternalMemoryDescriptor descriptor
External memory descriptor.
Definition onnxruntime_ep_c_api.h:57
uint32_t version
Must be ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:55
Struct that an EP implements for external resource import (memory + semaphore import).
Definition onnxruntime_ep_c_api.h:269
void(* ReleaseSemaphore)(OrtExternalResourceImporterImpl *this_ptr, OrtExternalSemaphoreHandle *handle)
Release an imported external semaphore handle.
Definition onnxruntime_ep_c_api.h:379
OrtStatus * ImportSemaphore(OrtExternalResourceImporterImpl *this_ptr, const OrtExternalSemaphoreDescriptor *desc, OrtExternalSemaphoreHandle **out_handle)
Import an external semaphore.
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:270
OrtStatus * SignalSemaphore(OrtExternalResourceImporterImpl *this_ptr, OrtExternalSemaphoreHandle *handle, OrtSyncStream *stream, uint64_t value)
Signal an external semaphore from the EP's stream.
OrtStatus * ImportMemory(OrtExternalResourceImporterImpl *this_ptr, const OrtExternalMemoryDescriptor *desc, OrtExternalMemoryHandle **out_handle)
Import external memory.
void(* Release)(OrtExternalResourceImporterImpl *this_ptr)
Release the OrtExternalResourceImporterImpl instance.
Definition onnxruntime_ep_c_api.h:432
OrtStatus * CreateTensorFromMemory(OrtExternalResourceImporterImpl *this_ptr, const OrtExternalMemoryHandle *mem_handle, const OrtExternalTensorDescriptor *tensor_desc, OrtValue **out_tensor)
Create a tensor backed by imported external memory.
void(* ReleaseMemory)(OrtExternalResourceImporterImpl *this_ptr, OrtExternalMemoryHandle *handle)
Release an imported external memory handle.
Definition onnxruntime_ep_c_api.h:315
bool(* CanImportMemory)(const OrtExternalResourceImporterImpl *this_ptr, OrtExternalMemoryHandleType handle_type)
Check if the implementation can import external memory of the given handle type.
Definition onnxruntime_ep_c_api.h:284
bool(* CanImportSemaphore)(const OrtExternalResourceImporterImpl *this_ptr, OrtExternalSemaphoreType type)
Check if the implementation can import external semaphores of the given type.
Definition onnxruntime_ep_c_api.h:348
OrtStatus * WaitSemaphore(OrtExternalResourceImporterImpl *this_ptr, OrtExternalSemaphoreHandle *handle, OrtSyncStream *stream, uint64_t value)
Wait on an external semaphore on the EP's stream.
Descriptor for importing external semaphores.
Definition onnxruntime_c_api.h:1107
Base struct for imported external semaphore handles.
Definition onnxruntime_ep_c_api.h:81
OrtExternalSemaphoreDescriptor descriptor
External semaphore descriptor.
Definition onnxruntime_ep_c_api.h:84
uint32_t version
Must be ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:82
void(* Release)(OrtExternalSemaphoreHandle *handle)
Release callback for this handle. EP sets this to its release function.
Definition onnxruntime_ep_c_api.h:91
const OrtEpDevice * ep_device
EP device that created this handle.
Definition onnxruntime_ep_c_api.h:83
Descriptor for creating a tensor from imported external memory.
Definition onnxruntime_c_api.h:1185
Configuration for initializing graphics interop on an EP factory.
Definition onnxruntime_c_api.h:1153
Contains functions that an OrtEp implements to specify the computation for an operator kernel.
Definition onnxruntime_ep_c_api.h:730
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:731
OrtStatus * Compute(OrtKernelImpl *this_ptr, OrtKernelContext *context)
Computation function called to execute the kernel on an EP.
OrtStatus * SetSharedPrePackedWeight(OrtKernelImpl *this_ptr, const void *const *buffer_data_ptrs, const size_t *buffer_data_sizes, size_t num_buffers, int input_index)
Optional function that receives data for a shared pre-packed weight from ORT.
OrtStatus * PrePackWeight(OrtKernelImpl *this_ptr, const OrtValue *tensor, int input_index, OrtAllocator *allocator, OrtSharedPrePackedWeightCache *prepacked_weight_cache, bool *is_packed)
Optional function to pre-pack a constant tensor (i.e., a weight) to the kernel's preferred data layou...
uint32_t flags
EP must initialize to 0. Used internally by ORT.
Definition onnxruntime_ep_c_api.h:732
void(* Release)(OrtKernelImpl *this_ptr)
Called by ORT to release the OrtKernelImpl instance and its resources.
Definition onnxruntime_ep_c_api.h:755
Contains helper functions for a Loop OrtKernelImpl created via OrtEpApi::CreateLoopKernel.
Definition onnxruntime_ep_c_api.h:877
void(* Release)(OrtLoopKernelHelper *this_ptr)
Called by ORT to release the OrtLoopKernelHelper instance and its resources.
Definition onnxruntime_ep_c_api.h:886
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:878
OrtStatus * ConcatOutput(OrtLoopKernelHelper *this_ptr, void *stream_handle, const OrtValue *const *per_iteration_outputs, size_t num_per_iteration_outputs, void *output, size_t output_size_in_bytes)
Helper function that concatenates OrtValue instances from each loop iteration into a single pre-alloc...
The OrtNodeComputeInfo struct provides functions that an OrtEp implements to specify the compute func...
Definition onnxruntime_ep_c_api.h:676
OrtStatus *(* Compute)(OrtNodeComputeInfo *this_ptr, void *compute_state, OrtKernelContext *kernel_context)
Computation function called to execute the fused node compiled by an OrtEp instance.
Definition onnxruntime_ep_c_api.h:711
uint32_t ort_version_supported
The ONNX Runtime version the OrtNodeComputeInfo was compiled with.
Definition onnxruntime_ep_c_api.h:684
OrtStatus *(* CreateState)(OrtNodeComputeInfo *this_ptr, OrtNodeComputeContext *compute_context, void **compute_state)
Creates an opaque compute state object that is then passed to the Compute() function during inference...
Definition onnxruntime_ep_c_api.h:698
void(* ReleaseState)(OrtNodeComputeInfo *this_ptr, void *compute_state)
Releases the compute state returned by CreateState().
Definition onnxruntime_ep_c_api.h:720
The OrtNodeFusionOptions struct specifies options for fusing nodes supported by an execution provider...
Definition onnxruntime_ep_c_api.h:646
uint32_t ort_version_supported
The ONNX Runtime version the OrtNodeFusionOptions was compiled with.
Definition onnxruntime_ep_c_api.h:654
bool drop_constant_initializers
If set to true, specify that the execution provider does not require ONNX Runtime to provide constant...
Definition onnxruntime_ep_c_api.h:666
ABI-stable tagged union representing a resource cost or budget.
Definition onnxruntime_ep_c_api.h:979
static OrtResourceCount FromTotalBytes(uint64_t bytes) noexcept
Definition onnxruntime_ep_c_api.h:998
static OrtResourceCount None() noexcept
Definition onnxruntime_ep_c_api.h:993
uint32_t kind
Definition onnxruntime_ep_c_api.h:980
uint64_t total_bytes
Definition onnxruntime_ep_c_api.h:984
uint32_t reserved
Definition onnxruntime_ep_c_api.h:981
uint64_t AsTotalBytes() const noexcept
Definition onnxruntime_ep_c_api.h:1006
uint64_t reserved_words[6]
Definition onnxruntime_ep_c_api.h:985
OrtResourceCount() noexcept
Definition onnxruntime_ep_c_api.h:990
union OrtResourceCount::@3 value
Contains helper functions for a Scan OrtKernelImpl created via OrtEpApi::CreateScanKernel.
Definition onnxruntime_ep_c_api.h:920
OrtStatus * Transpose(OrtScanKernelHelper *this_ptr, const size_t *permutation, size_t num_permutation_elems, const OrtValue *input, OrtSyncStream *stream, OrtValue *output)
Helper function that transposes an OrtValue instance during execution of a Scan kernel.
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:921
void(* Release)(OrtScanKernelHelper *this_ptr)
Called by ORT to release the OrtScanKernelHelper instance and its resources.
Definition onnxruntime_ep_c_api.h:929
Struct that an EP implements for Stream Notifications.
Definition onnxruntime_ep_c_api.h:158
OrtStatus * WaitOnDevice(OrtSyncNotificationImpl *this_ptr, OrtSyncStream *consumer_stream)
Wait for a device to device operation to complete.
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:159
OrtStatus * Activate(OrtSyncNotificationImpl *this_ptr)
Called by ORT to activate the notification.
OrtStatus * WaitOnHost(OrtSyncNotificationImpl *this_ptr)
Wait for a device to host operation to complete.
void(* Release)(OrtSyncNotificationImpl *this_ptr)
Release the OrtSyncNotificationImpl instance.
Definition onnxruntime_ep_c_api.h:170
Struct that an EP implements if it wishes to implement Stream support.
Definition onnxruntime_ep_c_api.h:204
void *(* GetHandle)(OrtSyncStreamImpl *this_ptr)
Get the handle of the stream.
Definition onnxruntime_ep_c_api.h:227
uint32_t ort_version_supported
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_ep_c_api.h:205
OrtStatus * Flush(OrtSyncStreamImpl *this_ptr)
Flush the stream.
OrtStatus * CreateNotification(OrtSyncStreamImpl *this_ptr, OrtSyncNotificationImpl **notification)
Create an OrtSyncNotificationImpl for the OrtSyncStreamImpl instance.
OrtStatus * OnSessionRunEnd(OrtSyncStreamImpl *this_ptr)
Notify the stream that a session run has ended.
void(* Release)(OrtSyncStreamImpl *this_ptr)
Release the OrtSyncStreamImpl instance.
Definition onnxruntime_ep_c_api.h:216