Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Move get_engine_gpu_device_name() into test_utils (#39938)

Eddy Kimc45b6e80c530
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
index e8fa5faa87a..42d9e219763 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp
@@ -6232,26 +6232,6 @@ TEST_F(fully_connected_gpu_tests, compressed_int8_parameter_scale_zp_per_group_t
this->test_compressed_int8_parameter_scale_zp(true, true);
}
-// ov::Core resolves plain "GPU" to the first enumerated device and ignores --device_suffix, so pin the
-// execution device to the one behind get_test_engine() (the plugin reports the very cldnn device_info uuid).
-static std::string get_engine_gpu_device_name() {
- auto& engine = get_test_engine();
- const auto engine_uuid = engine.get_device_info().uuid;
- ov::Core core;
- for (const auto& device : core.get_available_devices()) {
- if (device.rfind("GPU", 0) != 0) {
- continue;
- }
- try {
- if (core.get_property(device, ov::device::uuid).uuid == engine_uuid.uuid) {
- return device;
- }
- } catch (const ov::Exception&) {
- }
- }
- return "GPU";
-}
-
// Full-pipeline regression for runtime scale/zp: an f32 scale Parameter and a u8 zp Parameter feeding a
// compressed MatMul reach GPU:PostLPT through ConvertPrecision, so the scale arrives as a bare
// Convert(Parameter) and the zp as Convert(Parameter) over the Subtract operand. The pipeline must
diff --git a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
index 1f90971cbf1..7b50fb27d2d 100644
--- a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
@@ -5,6 +5,8 @@
#include "test_utils.h"
#include <iostream>
+#include "openvino/runtime/core.hpp"
+
using namespace cldnn;
@@ -515,4 +517,23 @@ void print_profiling_all_exectimes(const std::map<cldnn::primitive_id, cldnn::ne
std::cout << std::endl;
}
+
+std::string get_engine_gpu_device_name() {
+ auto& engine = get_test_engine();
+ const auto engine_uuid = engine.get_device_info().uuid;
+ ov::Core core;
+ for (const auto& device : core.get_available_devices()) {
+ if (device.rfind("GPU", 0) != 0) {
+ continue;
+ }
+ try {
+ if (core.get_property(device, ov::device::uuid).uuid == engine_uuid.uuid) {
+ return device;
+ }
+ } catch (const ov::Exception&) {
+ }
+ }
+ return "GPU";
+}
+
} // namespace tests
diff --git a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
index 3ba9f8beed2..a274ba508fd 100644
--- a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
+++ b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
@@ -669,4 +669,9 @@ double get_profiling_exectime(const std::map<cldnn::primitive_id, cldnn::network
const std::string& primitive_id);
void print_profiling_all_exectimes(const std::map<cldnn::primitive_id, cldnn::network_output>& outputs);
+/// Returns the ov::Core device string ("GPU", "GPU.1", ...) of the device behind `get_test_engine()`, i.e. the one
+/// selected by `--device_suffix`. ov::Core resolves the plain "GPU" to the first enumerated device and ignores the
+/// flag, so full-pipeline tests that gate on `get_test_engine()` capabilities must compile against this name instead.
+std::string get_engine_gpu_device_name();
+
} // namespace tests