@@ -2046,6 +2046,65 @@ struct OrtEpFactory {
20462046 ORT_API2_STATUS (CreateExternalResourceImporterForDevice , _In_ OrtEpFactory * this_ptr ,
20472047 _In_ const OrtEpDevice * ep_device ,
20482048 _Outptr_result_maybenull_ OrtExternalResourceImporterImpl * * out_importer );
2049+
2050+ /** \brief Returns the number of OrtCustomOpDomains that this factory provides.
2051+ *
2052+ * \param[in] this_ptr The OrtEpFactory instance.
2053+ * \param[out] num_domains Output parameter set to the number of provided OrtCustomOpDomain instances.
2054+ *
2055+ * \snippet{doc} snippets.dox OrtStatus Return Value
2056+ *
2057+ * \since Version 1.24.
2058+ */
2059+ ORT_API2_STATUS (GetNumCustomOpDomains , _In_ OrtEpFactory * this_ptr , _Out_ size_t * num_domains );
2060+
2061+ /** \brief Gets the EP-specific OrtCustomOpDomains.
2062+ *
2063+ * This function is used when running inference on a model that contains EP-specific custom operations.
2064+ *
2065+ * Workflow:
2066+ * 1. The EP factory implements this function to supply a list of OrtCustomOpDomain instances.
2067+ * 2. The application either 1) calls SessionOptionsAppendExecutionProvider_V2() with an OrtEpDevice containing
2068+ * the plugin EP's factory or 2) enables auto ep selection.
2069+ * 3. 1) SessionOptionsAppendExecutionProvider_V2() appends the provided OrtCustomOpDomains to the
2070+ * session options or 2) ORT registers the OrtCustomOpDomains provided by the EP devices
2071+ * that could be potentially selected.
2072+ *
2073+ * As a result, any session created from these session options will have these custom op domains registered
2074+ * in ORT, ensuring that the custom ops are properly recognized and validated when the model is loaded.
2075+ *
2076+ * Plugin EPs can provide two types of custom ops:
2077+ * 1. A full OrtCustomOp with a concrete kernel implementation
2078+ * - A Plugin EP can supply an OrtCustomOp and a corresponding CustomKernel::Compute() implementation.
2079+ * - In GetCapability(), it calls EpGraphSupportInfo_AddSingleNode() to inform ORT
2080+ * that the custom node should NOT be fused or compiled. Instead, ORT should invoke
2081+ * the custom node's Compute() function at runtime.
2082+ *
2083+ * 2. A "placeholder" OrtCustomOp with an empty kernel implementation
2084+ * - A compile-based Plugin EP can supply an OrtCustomOp whose CustomKernel::Compute()
2085+ * does nothing. The purpose is to satisfy model validation during model loading by
2086+ * registering the custom op as a valid operator in the session.
2087+ * - In GetCapability(), the EP should call EpGraphSupportInfo_AddNodesToFuse() to
2088+ * notify ORT that this custom node should be fused and compiled by the EP.
2089+ * - In Compile(), the EP executes its compiled bits to perform inference for
2090+ * the fused custom node.
2091+ *
2092+ * Note: The OrtCustomOpDomain instances must be valid while any session is using them.
2093+ EP factory has the responsibility to release OrtCustomOpDomain instances it creates. It happens
2094+ * automatically if using the C++ Ort::CustomOpDomain class.
2095+ *
2096+ * \param[in] this_ptr The OrtEpFactory instance.
2097+ * \param[out] domains Array of `num_domains` elements pre-allocated by ORT that should be filled with
2098+ OrtCustomOpDomain instances created by the EP. The `num_domains` is the value returned by
2099+ GetNumCustomOpDomains().
2100+ * \param[in] num_domains The size of the `domains` array pre-allocated by ORT.
2101+ *
2102+ * \snippet{doc} snippets.dox OrtStatus Return Value
2103+ *
2104+ * \since Version 1.24.
2105+ */
2106+ ORT_API2_STATUS (GetCustomOpDomains , _In_ OrtEpFactory * this_ptr ,
2107+ _Out_writes_all_ (num_domains ) OrtCustomOpDomain * * domains , _In_ size_t num_domains );
20492108};
20502109
20512110#ifdef __cplusplus
0 commit comments