Repository: microsoft/onnxruntime
File: onnxruntime/test/framework/ep_plugin_provider_test.cc (C++)

Code before:
#if !defined(ORT_NO_EXCEPTIONS)
  // 2 OrtEpDevice instances with DIFFERENT device_memory_info instances.
  // Should throw an exception on construction of PluginExecutionProvider.
  {
    auto ort_device_gpu = test_plugin_ep::MakeTestOrtDevice(OrtDevice::GPU, OrtDevice::MemType::DEFAULT);
    auto ort_memory_info_gpu = std::make_unique<OrtMemoryInfo>("TestOrtEp GPU", OrtAllocatorType::OrtDeviceAllocator,
                                                               ort_device_gpu, OrtMemTypeDefault);

    auto ort_device_npu = test_plugin_ep::MakeTestOrtDevice(OrtDevice::NPU, OrtDevice::MemType::DEFAULT);
    auto ort_memory_info_npu = std::make_unique<OrtMemoryInfo>("TestOrtEp NPU", OrtAllocatorType::OrtDeviceAllocator,
                                                               ort_device_npu, OrtMemTypeDefault);

    auto ort_hw_device_gpu = test_plugin_ep::MakeTestOrtHardwareDevice(OrtHardwareDeviceType_GPU);
    auto ort_hw_device_npu = test_plugin_ep::MakeTestOrtHardwareDevice(OrtHardwareDeviceType_NPU);
    auto ort_ep_device_gpu = test_plugin_ep::MakeTestOrtEpDevice(ort_hw_device_gpu.get(), ort_memory_info_gpu.get());
    auto ort_ep_device_npu = test_plugin_ep::MakeTestOrtEpDevice(ort_hw_device_npu.get(), ort_memory_info_npu.get());
    std::vector<const OrtEpDevice*> ep_devices{ort_ep_device_gpu.get(), ort_ep_device_npu.get()};

    ASSERT_THROW(test_plugin_ep::MakeTestOrtEp(ep_devices), OnnxRuntimeException);
  }
#endif  // !defined(ORT_NO_EXCEPTIONS)
}

static void LoadModelAndAssignNodesToEp(const ORTCHAR_T* model_path,
                                        const char* ep_name,
                                        std::unordered_set<std::string> ep_node_names,
                                        /*out*/ std::shared_ptr<Model>& model) {
  ASSERT_STATUS_OK(Model::Load(model_path, model, nullptr,
                               DefaultLoggingManager().DefaultLogger()));

  Graph& graph = model->MainGraph();

  for (Node& node : graph.Nodes()) {
    if (ep_node_names.count(node.Name()) > 0) {
      node.SetExecutionProviderType(ep_name);
    }
  }
}

static OrtStatus* ORT_API_CALL GetCapabilityTakeAllNodes(OrtEp* this_ptr, const OrtGraph* graph,
                                                         OrtEpGraphSupportInfo* graph_support_info) noexcept {
  auto* this_ep = static_cast<test_plugin_ep::TestOrtEp*>(this_ptr);

  size_t num_nodes = 0;
  if (OrtStatus* st = this_ep->ort_api->Graph_GetNumNodes(graph, &num_nodes); st != nullptr) {
    return st;
  }

  std::vector<const OrtNode*> nodes(num_nodes);
  if (OrtStatus* st = this_ep->ort_api->Graph_GetNodes(graph, nodes.data(), nodes.size()); st != nullptr) {
    return st;

Review comment (suggestion):
```suggestion
                                        const std::unordered_set<std::string>& ep_node_names,
```

Code after:
#if !defined(ORT_NO_EXCEPTIONS)
  // 2 OrtEpDevice instances with DIFFERENT device_memory_info instances.
  // Should throw an exception on construction of PluginExecutionProvider.
  {
    auto ort_device_gpu = test_plugin_ep::MakeTestOrtDevice(OrtDevice::GPU, OrtDevice::MemType::DEFAULT);
    auto ort_memory_info_gpu = std::make_unique<OrtMemoryInfo>("TestOrtEp GPU", OrtAllocatorType::OrtDeviceAllocator,
                                                               ort_device_gpu, OrtMemTypeDefault);

    auto ort_device_npu = test_plugin_ep::MakeTestOrtDevice(OrtDevice::NPU, OrtDevice::MemType::DEFAULT);
    auto ort_memory_info_npu = std::make_unique<OrtMemoryInfo>("TestOrtEp NPU", OrtAllocatorType::OrtDeviceAllocator,
                                                               ort_device_npu, OrtMemTypeDefault);

    auto ort_hw_device_gpu = test_plugin_ep::MakeTestOrtHardwareDevice(OrtHardwareDeviceType_GPU);
    auto ort_hw_device_npu = test_plugin_ep::MakeTestOrtHardwareDevice(OrtHardwareDeviceType_NPU);
    auto ort_ep_device_gpu = test_plugin_ep::MakeTestOrtEpDevice(ort_hw_device_gpu.get(), ort_memory_info_gpu.get());
    auto ort_ep_device_npu = test_plugin_ep::MakeTestOrtEpDevice(ort_hw_device_npu.get(), ort_memory_info_npu.get());
    std::vector<const OrtEpDevice*> ep_devices{ort_ep_device_gpu.get(), ort_ep_device_npu.get()};

    ASSERT_THROW(test_plugin_ep::MakeTestOrtEp(ep_devices), OnnxRuntimeException);
  }
#endif  // !defined(ORT_NO_EXCEPTIONS)
}

static void LoadModelAndAssignNodesToEp(const ORTCHAR_T* model_path,
                                        const char* ep_name,
                                        const std::unordered_set<std::string>& ep_node_names,
                                        /*out*/ std::shared_ptr<Model>& model) {
  ASSERT_STATUS_OK(Model::Load(model_path, model, nullptr,
                               DefaultLoggingManager().DefaultLogger()));

  Graph& graph = model->MainGraph();

  for (Node& node : graph.Nodes()) {
    if (ep_node_names.count(node.Name()) > 0) {
      node.SetExecutionProviderType(ep_name);
    }
  }
}

static OrtStatus* ORT_API_CALL GetCapabilityTakeAllNodesOneGroup(OrtEp* this_ptr, const OrtGraph* graph,
                                                                 OrtEpGraphSupportInfo* graph_support_info) noexcept {
  auto* this_ep = static_cast<test_plugin_ep::TestOrtEp*>(this_ptr);

  size_t num_nodes = 0;
  if (OrtStatus* st = this_ep->ort_api->Graph_GetNumNodes(graph, &num_nodes); st != nullptr) {
    return st;
  }

  std::vector<const OrtNode*> nodes(num_nodes);
  if (OrtStatus* st = this_ep->ort_api->Graph_GetNodes(graph, nodes.data(), nodes.size()); st != nullptr) {
    return st;