![]() |
ONNX Runtime
|
The OrtEpFactory provides functions to create and manage execution providers. More...
#include <onnxruntime_ep_c_api.h>
Public Member Functions | |
| 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 * | 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. | |
| 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 devices. | |
| 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. | |
| OrtStatus * | CreateDataTransfer (OrtEpFactory *this_ptr, OrtDataTransferImpl **data_transfer) |
| Create an OrtDataTransferImpl instance for the factory. | |
| 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 * | SetEnvironmentOptions (OrtEpFactory *this_ptr, const OrtKeyValuePairs *options) |
| Set environment options on this EP factory. | |
Public Attributes | |
| uint32_t | ort_version_supported |
| The ONNX Runtime version the execution provider was compiled with. | |
| const char *(* | GetName )(const OrtEpFactory *this_ptr) |
| Get the name of the execution provider that the factory creates. | |
| const char *(* | GetVendor )(const OrtEpFactory *this_ptr) |
| Get the name of vendor who owns the execution provider that the factory creates. | |
| void(* | ReleaseEp )(OrtEpFactory *this_ptr, struct OrtEp *ep) |
| Release the OrtEp instance. | |
| uint32_t(* | GetVendorId )(const OrtEpFactory *this_ptr) |
| Get the vendor id who owns the execution provider that the factory creates. | |
| const char *(* | GetVersion )(const OrtEpFactory *this_ptr) |
| Get the version of the execution provider that the factory creates. | |
| void(* | ReleaseAllocator )(OrtEpFactory *this_ptr, OrtAllocator *allocator) |
| Release an OrtAllocator created by the factory. | |
| bool(* | IsStreamAware )(const OrtEpFactory *this_ptr) |
| Check if execution providers created by the factory are stream aware. | |
The OrtEpFactory provides functions to create and manage execution providers.
| OrtStatus * OrtEpFactory::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.
The factory that creates the EP is responsible for providing the allocators required by the EP. The OrtMemoryInfo instance will match one of the values set in the OrtEpDevice using EpDevice_AddAllocatorInfo.
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | memory_info | The OrtMemoryInfo to create the allocator for. May be nullptr. |
| [in] | allocator_options | Optional key-value pairs for allocator options, can be nullptr. |
| [out] | allocator | The created OrtAllocator instance. Set to nullptr if the default CPU allocator is used. |
| OrtStatus * OrtEpFactory::CreateDataTransfer | ( | OrtEpFactory * | this_ptr, |
| OrtDataTransferImpl ** | data_transfer | ||
| ) |
Create an OrtDataTransferImpl instance for the factory.
This is used to create an IDataTransfer implementation that can be used to copy data between devices that the execution provider supports.
| [in] | this_ptr | The OrtEpFactory instance. |
| [out] | data_transfer | The created OrtDataTransferImpl instance. Set to nullptr if not required. |
| OrtStatus * OrtEpFactory::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.
ORT will call ReleaseEp to release the instance when it is no longer needed.
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | devices | The OrtHardwareDevice instances that the execution provider was selected to use. May be a subset of the OrtHardwareDevice instances that the execution provider's factory set as supported in the call to OrtEpFactory::GetSupportedDevices. |
| [in] | ep_metadata_pairs | Execution provider metadata that was provided to OrtEpApi::CreateEpDevice, for each device. |
| [in] | num_devices | The number of devices the execution provider was selected for. |
| [in] | session_options | The OrtSessionOptions instance that contains the configuration options for the session. This will include ep_options from GetSupportedDevices as well as any user provided overrides. Execution provider options will have been added with a prefix of 'ep.[ep name].'. The OrtSessionOptions instance will NOT be valid after this call and should not be stored for later use. |
| [in] | logger | The OrtLogger instance for the session that the execution provider should use for logging. |
| [out] | ep | The OrtEp instance created by the factory. |
| OrtStatus * OrtEpFactory::CreateSyncStreamForDevice | ( | OrtEpFactory * | this_ptr, |
| const OrtMemoryDevice * | memory_device, | ||
| const OrtKeyValuePairs * | stream_options, | ||
| OrtSyncStreamImpl ** | stream | ||
| ) |
Create a synchronization stream for the given memory device.
This is used to create a synchronization stream for the memory device that can be used for operations outside of a session.
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | memory_device | The OrtMemoryDevice to create the synchronization stream for. |
| [in] | stream_options | Options for stream creation. May be nullptr. |
| [out] | stream | The created OrtSyncStreamImpl instance. nullptr if the execution provider is not stream aware. |
| OrtStatus * OrtEpFactory::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.
| [in] | this_ptr | The OrtEpFactory instance. Non-const as the factory is passed through to the CreateEp call via the OrtEpDevice. |
| [in] | devices | The OrtHardwareDevice instances that are available. |
| [in] | num_devices | The number of OrtHardwareDevice instances. |
| [out] | ep_devices | OrtEpDevice instances for each OrtHardwareDevice that the EP can use. The implementation should call OrtEpApi::CreateEpDevice to create, and add the OrtEpDevice instances to this pre-allocated array. ORT will take ownership of the values returned. i.e. usage is ep_devices[0] = <ptr to OrtEpDevice created with OrtEpApi::CreateEpDevice>; |
| [in] | max_ep_devices | The maximum number of OrtEpDevices that can be added to ep_devices. Current default is 8. This can be increased if needed. |
| [out] | num_ep_devices | The number of EP devices added to ep_devices. |
device.| OrtStatus * OrtEpFactory::SetEnvironmentOptions | ( | OrtEpFactory * | this_ptr, |
| const OrtKeyValuePairs * | options | ||
| ) |
Set environment options on this EP factory.
Environment options can be set by ORT after calling the library's 'CreateEpFactories' function to create EP factories.
Supported options: "allow_virtual_devices": Allows EP factory to specify OrtEpDevice instances that use custom virtual OrtHardwareDevices, which can be created via OrtEpApi::CreateHardwareDevice().
A virtual OrtHardwareDevice does not represent actual hardware on the device, and is identified via the metadata entry "is_virtual" with a value of "1". Refer to onnxruntime_ep_device_ep_metadata_keys.h for well-known OrtHardwareDevice metadata keys.
Allowed values:
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | options | The configuration options. |
| OrtStatus * OrtEpFactory::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 devices.
Given a compatibility info string produced during model compilation, the EP factory should determine whether the compiled model is compatible with the EP factory when targeting the provided hardware devices. All devices provided must belong to the same execution provider instance that this factory creates.
The EP factory implementation should consider the set of devices (e.g., multi-adapter or multi-GPU scenarios) when evaluating compatibility and set model_compatibility accordingly.
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | devices | Array of OrtHardwareDevice pointers that the EP would run on. All must map to this EP. |
| [in] | num_devices | Number of entries in devices. |
| [in] | compatibility_info | The compatibility information string produced when the model was compiled. |
| [out] | model_compatibility | OrtCompiledModelCompatibility value describing the compatibility of the model with the EP. |
| const char *( * OrtEpFactory::GetName) (const OrtEpFactory *this_ptr) |
Get the name of the execution provider that the factory creates.
The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
| [in] | this_ptr | The OrtEpFactory instance. |
| const char *( * OrtEpFactory::GetVendor) (const OrtEpFactory *this_ptr) |
Get the name of vendor who owns the execution provider that the factory creates.
The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
| [in] | this_ptr | The OrtEpFactory instance. |
| uint32_t( * OrtEpFactory::GetVendorId) (const OrtEpFactory *this_ptr) |
Get the vendor id who owns the execution provider that the factory creates.
This is typically the PCI vendor ID. See https://pcisig.com/membership/member-companies
| [in] | this_ptr | The OrtEpFactory instance. |
| const char *( * OrtEpFactory::GetVersion) (const OrtEpFactory *this_ptr) |
Get the version of the execution provider that the factory creates.
The version string should adhere to the Semantic Versioning 2.0 specification (https://github.com/semver/semver/blob/v2.0.0/semver.md).
The returned string should be a null-terminated, UTF-8 encoded string. ORT will copy it.
| [in] | this_ptr | The OrtEpFactory instance. |
| bool( * OrtEpFactory::IsStreamAware) (const OrtEpFactory *this_ptr) |
Check if execution providers created by the factory are stream aware.
| [in] | this_ptr | The OrtEpFactory instance. |
| uint32_t OrtEpFactory::ort_version_supported |
The ONNX Runtime version the execution provider was compiled with.
Implementation should set to ORT_API_VERSION. ORT will use this to ensure it does not call functions that were not available when the library was compiled.
| void( * OrtEpFactory::ReleaseAllocator) (OrtEpFactory *this_ptr, OrtAllocator *allocator) |
Release an OrtAllocator created by the factory.
| void( * OrtEpFactory::ReleaseEp) (OrtEpFactory *this_ptr, struct OrtEp *ep) |
Release the OrtEp instance.
| [in] | this_ptr | The OrtEpFactory instance. |
| [in] | ep | The OrtEp instance to release. |