ONNX Runtime
Loading...
Searching...
No Matches
OrtEpFactory Struct Reference

The OrtEpFactory provides functions to create and manage execution providers. More...

#include <onnxruntime_ep_c_api.h>

Public Member Functions

OrtStatusGetSupportedDevices (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.
 
OrtStatusCreateEp (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.
 
OrtStatusValidateCompiledModelCompatibilityInfo (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.
 
OrtStatusCreateAllocator (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.
 
OrtStatusCreateDataTransfer (OrtEpFactory *this_ptr, OrtDataTransferImpl **data_transfer)
 Create an OrtDataTransferImpl instance for the factory.
 
OrtStatusCreateSyncStreamForDevice (OrtEpFactory *this_ptr, const OrtMemoryDevice *memory_device, const OrtKeyValuePairs *stream_options, OrtSyncStreamImpl **stream)
 Create a synchronization stream for the given memory device.
 
OrtStatusSetEnvironmentOptions (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.
 

Detailed Description

The OrtEpFactory provides functions to create and manage execution providers.

Since
Version 1.22.

Member Function Documentation

◆ CreateAllocator()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]memory_infoThe OrtMemoryInfo to create the allocator for. May be nullptr.
[in]allocator_optionsOptional key-value pairs for allocator options, can be nullptr.
[out]allocatorThe created OrtAllocator instance. Set to nullptr if the default CPU allocator is used.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.23.

◆ CreateDataTransfer()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[out]data_transferThe created OrtDataTransferImpl instance. Set to nullptr if not required.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.23.

◆ CreateEp()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]devicesThe 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_pairsExecution provider metadata that was provided to OrtEpApi::CreateEpDevice, for each device.
[in]num_devicesThe number of devices the execution provider was selected for.
[in]session_optionsThe 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]loggerThe OrtLogger instance for the session that the execution provider should use for logging.
[out]epThe OrtEp instance created by the factory.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.22.

◆ CreateSyncStreamForDevice()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]memory_deviceThe OrtMemoryDevice to create the synchronization stream for.
[in]stream_optionsOptions for stream creation. May be nullptr.
[out]streamThe created OrtSyncStreamImpl instance. nullptr if the execution provider is not stream aware.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.23.

◆ GetSupportedDevices()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance. Non-const as the factory is passed through to the CreateEp call via the OrtEpDevice.
[in]devicesThe OrtHardwareDevice instances that are available.
[in]num_devicesThe number of OrtHardwareDevice instances.
[out]ep_devicesOrtEpDevice 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_devicesThe maximum number of OrtEpDevices that can be added to ep_devices. Current default is 8. This can be increased if needed.
[out]num_ep_devicesThe number of EP devices added to ep_devices.
Returns
true if the factory can create an execution provider that uses device.
Since
Version 1.22.

◆ SetEnvironmentOptions()

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:

  1. "0": Default. Creation of virtual devices is not allowed.
  2. "1": Creation of virtual devices is allowed.
Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]optionsThe configuration options.
Note
Implementation of this function is optional. An EP factory should only implement this if it needs to handle any environment options.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.24.

◆ ValidateCompiledModelCompatibilityInfo()

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]devicesArray of OrtHardwareDevice pointers that the EP would run on. All must map to this EP.
[in]num_devicesNumber of entries in devices.
[in]compatibility_infoThe compatibility information string produced when the model was compiled.
[out]model_compatibilityOrtCompiledModelCompatibility value describing the compatibility of the model with the EP.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.23.

Member Data Documentation

◆ GetName

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
Returns
The name of the execution provider the factory creates.
Since
Version 1.22.

◆ GetVendor

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
Returns
vendor The vendor name of the execution provider the factory creates.
Since
Version 1.22.

◆ GetVendorId

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

Parameters
[in]this_ptrThe OrtEpFactory instance.
Returns
vendor_id The vendor ID of the execution provider the factory creates.
Since
Version 1.23.

◆ GetVersion

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.

Parameters
[in]this_ptrThe OrtEpFactory instance.
Returns
The execution provider version string.
Since
Version 1.23.

◆ IsStreamAware

bool( * OrtEpFactory::IsStreamAware) (const OrtEpFactory *this_ptr)

Check if execution providers created by the factory are stream aware.

Parameters
[in]this_ptrThe OrtEpFactory instance.
Returns
True if the factory creates execution providers that are stream aware and it implements CreateSyncStreamForDevice.
Since
Version 1.23.

◆ ort_version_supported

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.

Since
Version 1.22.

◆ ReleaseAllocator

void( * OrtEpFactory::ReleaseAllocator) (OrtEpFactory *this_ptr, OrtAllocator *allocator)

Release an OrtAllocator created by the factory.

Since
Version 1.23.

◆ ReleaseEp

void( * OrtEpFactory::ReleaseEp) (OrtEpFactory *this_ptr, struct OrtEp *ep)

Release the OrtEp instance.

Parameters
[in]this_ptrThe OrtEpFactory instance.
[in]epThe OrtEp instance to release.
Since
Version 1.22.