Skip to content

Commit 3faf7d9

Browse files
ov_factory: Use 'GPU_DEVICE_ID' property to match with ORT device_id (#759)
* ov_factory: Use 'GPU_DEVICE_ID' property to match with ORT device_id * clean up comment
1 parent e1b2c28 commit 3faf7d9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

onnxruntime/core/providers/openvino/ov_factory.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ OrtStatus* OpenVINOEpPluginFactory::GetSupportedDevices(const OrtHardwareDevice*
9696

9797
const auto& ov_device_type = device_it->second;
9898
std::string ov_device_name;
99-
auto get_pci_device_id = [&](const std::string& ov_device) {
99+
auto get_gpu_device_id = [&](const std::string& ov_device) {
100100
try {
101-
ov::device::PCIInfo pci_info = ov_core_->get_property(ov_device, ov::device::pci_info);
102-
return pci_info.device;
101+
auto device_id_str = ov_core_->get_property(ov_device, "GPU_DEVICE_ID").as<std::string>();
102+
return static_cast<uint32_t>(std::stoul(device_id_str, nullptr, 0));
103103
} catch (ov::Exception&) {
104-
return 0u; // If we can't get the PCI info, we won't have a device ID.
104+
return 0u; // If we can't get the GPU_DEVICE_ID info, we won't have a device ID.
105105
}
106106
};
107107

@@ -111,7 +111,7 @@ OrtStatus* OpenVINOEpPluginFactory::GetSupportedDevices(const OrtHardwareDevice*
111111
// If there are multiple devices of the same type, we need to match by device ID.
112112
matched_device = std::find_if(filtered_devices.begin(), filtered_devices.end(), [&](const std::string& ov_device) {
113113
uint32_t ort_device_id = ort_api.HardwareDevice_DeviceId(&device);
114-
return ort_device_id == get_pci_device_id(ov_device);
114+
return ort_device_id == get_gpu_device_id(ov_device);
115115
});
116116
}
117117

0 commit comments

Comments
 (0)