@@ -700,6 +700,9 @@ typedef struct OrtModelEditorApi OrtModelEditorApi;
700
700
struct OrtCompileApi ;
701
701
typedef struct OrtCompileApi OrtCompileApi;
702
702
703
+ struct OrtEpApi ;
704
+ typedef struct OrtEpApi OrtEpApi;
705
+
703
706
/* * \brief The helper interface to get the right version of OrtApi
704
707
*
705
708
* Get a pointer to this structure through ::OrtGetApiBase
@@ -5186,6 +5189,12 @@ struct OrtApi {
5186
5189
* \since Version 1.22.
5187
5190
*/
5188
5191
const OrtHardwareDevice*(ORT_API_CALL* EpDevice_Device)(_In_ const OrtEpDevice* ep_device);
5192
+
5193
+ /* * \brief Get the OrtEpApi instance for implementing an execution provider.
5194
+ *
5195
+ * \since Version 1.22.
5196
+ */
5197
+ const OrtEpApi*(ORT_API_CALL* GetEpApi)();
5189
5198
};
5190
5199
5191
5200
/*
@@ -5889,6 +5898,29 @@ struct OrtCompileApi {
5889
5898
ORT_RUNTIME_CLASS (Ep);
5890
5899
ORT_RUNTIME_CLASS (EpFactory);
5891
5900
5901
+ struct OrtEpApi {
5902
+ /* * \brief Create an OrtEpDevice for the EP and an OrtHardwareDevice.
5903
+ * \param[in] ep_factory Execution provider factory that is creating the instance.
5904
+ * \param[in] hardware_device Hardware device that the EP can utilize.
5905
+ * \param[in] ep_metadata Optional OrtKeyValuePairs instance for execution provider metadata that may be used
5906
+ * during execution provider selection and passed to CreateEp.
5907
+ * ep_device will copy this instance and the user should call ReleaseKeyValuePairs.
5908
+ * \param[in] ep_options Optional OrtKeyValuePairs instance for execution provider options that will be added
5909
+ * to the Session configuration options if the execution provider is selected.
5910
+ * ep_device will copy this instance and the user should call ReleaseKeyValuePairs.
5911
+ * \param ep_device OrtExecutionDevice that is created.
5912
+ *
5913
+ * \since Version 1.22.
5914
+ */
5915
+ ORT_API2_STATUS (CreateEpDevice, _In_ OrtEpFactory* ep_factory,
5916
+ _In_ const OrtHardwareDevice* hardware_device,
5917
+ _In_opt_ const OrtKeyValuePairs* ep_metadata,
5918
+ _In_opt_ const OrtKeyValuePairs* ep_options,
5919
+ _Out_ OrtEpDevice** ep_device);
5920
+
5921
+ ORT_CLASS_RELEASE (EpDevice);
5922
+ };
5923
+
5892
5924
/* *
5893
5925
* \brief The OrtEp struct provides functions to implement for an execution provider.
5894
5926
* \since Version 1.22.
@@ -5993,33 +6025,40 @@ struct OrtEpFactory {
5993
6025
/* * \brief Get information from the execution provider if it supports the OrtHardwareDevice.
5994
6026
*
5995
6027
* \param[in] this_ptr The OrtEpFactory instance.
5996
- * \param[in] device The OrtHardwareDevice instance.
5997
- * \param[out] ep_metadata Optional OrtKeyValuePairs instance for execution provider metadata that may be used
5998
- * during execution provider selection and/or CreateEp.
5999
- * \param[out] ep_options Optional OrtKeyValuePairs instance for execution provider options that will be added
6000
- * to the Session configuration options if the execution provider is selected.
6028
+ * Non-const as the factory is passed through to the CreateEp call via the OrtEpDevice.
6029
+ * \param[in] devices The OrtHardwareDevice instances that are available.
6030
+ * \param[in] num_devices The number of OrtHardwareDevice instances.
6031
+ * \param[out] ep_devices OrtEpDevice instances for each OrtHardwareDevice that the EP can use.
6032
+ * The implementation should call OrtEpApi::CreateEpDevice to create, and add the OrtEpDevice
6033
+ * instances to this pre-allocated array. ORT will take ownership of the values returned.
6034
+ * i.e. usage is `ep_devices[0] = <ptr to OrtEpDevice created with OrtEpApi::CreateEpDevice>;`
6035
+ * \param[in] max_ep_devices The maximum number of OrtEpDevices that can be added to ep_devices.
6036
+ * Current default is 8. This can be increased if needed.
6037
+ * \param[out] num_ep_devices The number of EP devices added to ep_devices.
6001
6038
* \return true if the factory can create an execution provider that uses `device`.
6002
6039
*
6003
6040
* \note ORT will take ownership or ep_metadata and/or ep_options if they are not null.
6004
6041
*
6005
6042
* \since Version 1.22.
6006
6043
*/
6007
- bool (ORT_API_CALL* GetDeviceInfoIfSupported)(const OrtEpFactory* this_ptr,
6008
- _In_ const OrtHardwareDevice* device,
6009
- _Out_opt_ OrtKeyValuePairs** ep_metadata,
6010
- _Out_opt_ OrtKeyValuePairs** ep_options);
6044
+ OrtStatus*(ORT_API_CALL* GetSupportedDevices)(_In_ OrtEpFactory* this_ptr,
6045
+ _In_reads_ (num_devices) const OrtHardwareDevice* const * devices,
6046
+ _In_ size_t num_devices,
6047
+ _Inout_ OrtEpDevice** ep_devices,
6048
+ _In_ size_t max_ep_devices,
6049
+ _Out_ size_t * num_ep_devices);
6011
6050
6012
6051
/* * \brief Function to create an OrtEp instance for use in a Session.
6013
6052
*
6014
6053
* ORT will call ReleaseEp to release the instance when it is no longer needed.
6015
6054
*
6016
6055
* \param[in] this_ptr The OrtEpFactory instance.
6017
6056
* \param[in] devices The OrtHardwareDevice instances that the execution provider was selected to use.
6018
- * \param[in] ep_metadata_pairs Execution provider metadata that was returned in GetDeviceInfoIfSupported , for each
6057
+ * \param[in] ep_metadata_pairs Execution provider metadata that was provided to OrtEpApi::CreateEpDevice , for each
6019
6058
* device.
6020
6059
* \param[in] num_devices The number of devices the execution provider was selected for.
6021
6060
* \param[in] session_options The OrtSessionOptions instance that contains the configuration options for the
6022
- * session. This will include ep_options from GetDeviceInfoIfSupported as well as any
6061
+ * session. This will include ep_options from GetSupportedDevices as well as any
6023
6062
* user provided overrides.
6024
6063
* Execution provider options will have been added with a prefix of 'ep.<ep name>.'.
6025
6064
* The OrtSessionOptions instance will NOT be valid after this call and should not be
@@ -6029,7 +6068,7 @@ struct OrtEpFactory {
6029
6068
*
6030
6069
* \snippet{doc} snippets.dox OrtStatus Return Value
6031
6070
*
6032
- * \since Version 1.22 .
6071
+ * \since Version <coming soon>. This is a placeholder .
6033
6072
*/
6034
6073
OrtStatus*(ORT_API_CALL* CreateEp)(_In_ OrtEpFactory* this_ptr,
6035
6074
_In_reads_ (num_devices) const OrtHardwareDevice* const * devices,
@@ -6043,7 +6082,7 @@ struct OrtEpFactory {
6043
6082
* \param[in] this_ptr The OrtEpFactory instance.
6044
6083
* \param[in] ep The OrtEp instance to release.
6045
6084
*
6046
- * \since Version 1.22 .
6085
+ * \since Version <coming soon>. This is a placeholder .
6047
6086
*/
6048
6087
void (ORT_API_CALL* ReleaseEp)(OrtEpFactory* this_ptr, struct OrtEp * ep);
6049
6088
};
0 commit comments