From 160fd5cea048ec58062c0742377716f458713acf Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Thu, 10 Jul 2025 22:53:19 -0700 Subject: [PATCH 1/3] add Node_GetEpName --- include/onnxruntime/core/session/onnxruntime_c_api.h | 5 +++-- onnxruntime/core/graph/ep_api_types.cc | 2 +- onnxruntime/core/graph/ep_api_types.h | 4 ++-- onnxruntime/core/session/onnxruntime_c_api.cc | 6 +++--- onnxruntime/core/session/ort_apis.h | 2 +- onnxruntime/test/autoep/library/ep.cc | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 9172965e18fcf..a6bff77eff968 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -6026,8 +6026,9 @@ struct OrtApi { */ ORT_API2_STATUS(Node_GetGraph, _In_ const OrtNode* node, _Outptr_result_maybenull_ const OrtGraph** graph); - /** \brief Returns the execution provider type (name) that this node is assigned to run on. + /** \brief Returns the execution provider name that this node is assigned to run on. * Returns NULL if the node has not been assigned to any execution provider yet. + * For plugin execution providers, the name is the one registered via RegisterExecutionProviderLibrary. * * \param[in] node The OrtNode instance. * \param[out] out Output execution provider type and can be NULL if node has not been assigned. @@ -6036,7 +6037,7 @@ struct OrtApi { * * \since Version 1.23. */ - ORT_API2_STATUS(Node_GetEpType, _In_ const OrtNode* node, _Outptr_result_maybenull_ const char** out); + ORT_API2_STATUS(Node_GetEpName, _In_ const OrtNode* node, _Outptr_result_maybenull_ const char** out); /// @} diff --git a/onnxruntime/core/graph/ep_api_types.cc b/onnxruntime/core/graph/ep_api_types.cc index 073c6a2c743eb..f57543416a68f 100644 --- a/onnxruntime/core/graph/ep_api_types.cc +++ b/onnxruntime/core/graph/ep_api_types.cc @@ -276,7 +276,7 @@ const OrtOpAttr* EpNode::GetAttribute(const std::string& name) const { } } -const std::string& EpNode::GetEpType() const { +const std::string& EpNode::GetEpName() const { return node_.GetExecutionProviderType(); } diff --git a/onnxruntime/core/graph/ep_api_types.h b/onnxruntime/core/graph/ep_api_types.h index 1acbcc478a99b..d3921e051e18a 100644 --- a/onnxruntime/core/graph/ep_api_types.h +++ b/onnxruntime/core/graph/ep_api_types.h @@ -208,8 +208,8 @@ struct EpNode : public OrtNode { // Helper that gets the node's attributes by name. const OrtOpAttr* GetAttribute(const std::string& name) const; - // Helper that gets the execution provider that this node is assigned to run on. - const std::string& GetEpType() const; + // Helper that gets the execution provider name that this node is assigned to run on. + const std::string& GetEpName() const; private: // Back pointer to containing graph. Useful when traversing through nested subgraphs. diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 55bc28cd7139f..9e210a0f428b9 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -3052,7 +3052,7 @@ ORT_API_STATUS_IMPL(OrtApis::Node_GetGraph, _In_ const OrtNode* node, API_IMPL_END } -ORT_API_STATUS_IMPL(OrtApis::Node_GetEpType, _In_ const OrtNode* node, +ORT_API_STATUS_IMPL(OrtApis::Node_GetEpName, _In_ const OrtNode* node, _Outptr_result_maybenull_ const char** out) { API_IMPL_BEGIN if (out == nullptr) { @@ -3061,10 +3061,10 @@ ORT_API_STATUS_IMPL(OrtApis::Node_GetEpType, _In_ const OrtNode* node, const EpNode* ep_node = EpNode::ToInternal(node); if (ep_node == nullptr) { - return OrtApis::CreateStatus(OrtErrorCode::ORT_INVALID_ARGUMENT, "node is a ModelEditorNode which doesn't support Node_GetEpType."); + return OrtApis::CreateStatus(OrtErrorCode::ORT_INVALID_ARGUMENT, "node is a ModelEditorNode which doesn't support Node_GetEpName."); } - *out = ep_node->GetEpType().c_str(); + *out = ep_node->GetEpName().c_str(); return nullptr; API_IMPL_END } diff --git a/onnxruntime/core/session/ort_apis.h b/onnxruntime/core/session/ort_apis.h index fed7009828999..9ab927006c320 100644 --- a/onnxruntime/core/session/ort_apis.h +++ b/onnxruntime/core/session/ort_apis.h @@ -680,7 +680,7 @@ ORT_API_STATUS_IMPL(Node_GetSubgraphs, _In_ const OrtNode* node, _Out_writes_(num_subgraphs) const OrtGraph** subgraphs, _In_ size_t num_subgraphs, _Out_writes_opt_(num_subgraphs) const char** attribute_names); ORT_API_STATUS_IMPL(Node_GetGraph, _In_ const OrtNode* node, _Outptr_result_maybenull_ const OrtGraph** graph); -ORT_API_STATUS_IMPL(Node_GetEpType, _In_ const OrtNode* node, _Outptr_result_maybenull_ const char** out); +ORT_API_STATUS_IMPL(Node_GetEpName, _In_ const OrtNode* node, _Outptr_result_maybenull_ const char** out); ORT_API_STATUS_IMPL(GetRunConfigEntry, _In_ const OrtRunOptions* options, _In_z_ const char* config_key, _Outptr_result_maybenull_z_ const char** config_value); diff --git a/onnxruntime/test/autoep/library/ep.cc b/onnxruntime/test/autoep/library/ep.cc index a5b46c74ecc21..78261162ebaf8 100644 --- a/onnxruntime/test/autoep/library/ep.cc +++ b/onnxruntime/test/autoep/library/ep.cc @@ -328,9 +328,9 @@ OrtStatus* ORT_API_CALL ExampleEp::CompileImpl(_In_ OrtEp* this_ptr, _In_ const RETURN_IF_ERROR(ort_api.GetValueInfoName(node_inputs[0], &node_input_names[0])); RETURN_IF_ERROR(ort_api.GetValueInfoName(node_inputs[1], &node_input_names[1])); - const char* ep_type = nullptr; - RETURN_IF_ERROR(ort_api.Node_GetEpType(fused_nodes[0], &ep_type)); - if (std::strncmp(ep_type, "example_ep", 11) != 0) { + const char* ep_name = nullptr; + RETURN_IF_ERROR(ort_api.Node_GetEpName(fused_nodes[0], &ep_name)); + if (std::strncmp(ep_name, "example_ep", 11) != 0) { return ort_api.CreateStatus(ORT_EP_FAIL, "The fused node is expected to assigned to this EP to run on"); } From f13d6afc3f264ff5b520705a2abb6d58fa8e5360 Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Thu, 10 Jul 2025 23:01:33 -0700 Subject: [PATCH 2/3] update --- onnxruntime/core/session/onnxruntime_c_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 9e210a0f428b9..db2a62c77d1bc 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -3751,7 +3751,7 @@ static constexpr OrtApi ort_api_1_to_23 = { &OrtApis::Node_GetNumSubgraphs, &OrtApis::Node_GetSubgraphs, &OrtApis::Node_GetGraph, - &OrtApis::Node_GetEpType, + &OrtApis::Node_GetEpName, &OrtApis::GetRunConfigEntry, From 58b3ab83ed1c9386a0d76806882c5744bace8600 Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Fri, 11 Jul 2025 08:46:20 -0700 Subject: [PATCH 3/3] address reviewer comment --- include/onnxruntime/core/session/onnxruntime_c_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index a6bff77eff968..bcb414743e2b4 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -6028,7 +6028,7 @@ struct OrtApi { /** \brief Returns the execution provider name that this node is assigned to run on. * Returns NULL if the node has not been assigned to any execution provider yet. - * For plugin execution providers, the name is the one registered via RegisterExecutionProviderLibrary. + * For plugin execution providers, the name is the one returned by OrtEp::GetName. * * \param[in] node The OrtNode instance. * \param[out] out Output execution provider type and can be NULL if node has not been assigned.