Skip to content

Commit 4b42d60

Browse files
authored
[NPU][IE-MDK] Add fallbacks for platform indentification (openvinotoolkit#33156)
### Details: - The skip config gets multiple fallbacks for platform identification. - Some tests can set their own desired platform, while the skip config is populated before any test is run. This means that it needs to know what's the expected platform, in order to populate the list correctly. - This implementation uses `IE_NPU_TESTS_PLATFORM` as the first source form platform identification, as it's a mandatory envvar to run `ov_npu_func_tests`. It then falls back to using `IE_NPU_TESTS_DEVICE_NAME`. If neither envvar provide a usable platform, the final fallback is the list returned by the NPU Plugin ### Tickets: - E 189860
1 parent 54ab316 commit 4b42d60

3 files changed

Lines changed: 27 additions & 34 deletions

File tree

src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ std::string getDeviceNameID(const std::string& str) {
175175
return parser.get_device_id();
176176
}
177177

178+
std::string getTestPlatform() {
179+
return ov::intel_npu::Platform::standardize(NpuTestEnvConfig::getInstance().IE_NPU_TESTS_PLATFORM);
180+
}
181+
178182
} // namespace ov::test::utils
179183

180184
namespace InferRequestParamsAnyMapTestName {

src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ std::string getTestsPlatformFromEnvironmentOr(const std::string& instead);
5454
std::string getDeviceNameTestCase(const std::string& str);
5555
std::string getDeviceName();
5656
std::string getDeviceNameID(const std::string& str);
57+
std::string getTestPlatform();
5758

5859
} // namespace ov::test::utils
5960

src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
#include "intel_npu/npu_private_properties.hpp"
1818
#include "openvino/util/xml_parse_utils.hpp"
1919

20+
using namespace ov::test::utils;
21+
using namespace ov::util::pugixml;
22+
2023
class BackendName {
2124
public:
2225
BackendName() {
23-
const auto corePtr = ov::test::utils::PluginCache::get().core();
26+
const auto corePtr = PluginCache::get().core();
2427
if (corePtr != nullptr) {
2528
_name = getBackendName(*corePtr);
2629
} else {
@@ -32,14 +35,6 @@ class BackendName {
3235
return _name;
3336
}
3437

35-
bool isEmpty() const noexcept {
36-
return _name.empty();
37-
}
38-
39-
bool isZero() const {
40-
return _name == "LEVEL0";
41-
}
42-
4338
private:
4439
std::string _name;
4540
intel_npu::Logger _log = intel_npu::Logger("BackendName", ov::log::Level::INFO);
@@ -48,26 +43,37 @@ class BackendName {
4843
class AvailableDevices {
4944
public:
5045
AvailableDevices() {
51-
const auto corePtr = ov::test::utils::PluginCache::get().core();
46+
const auto corePtr = PluginCache::get().core();
5247
if (corePtr != nullptr) {
53-
_availableDevices = ::getAvailableDevices(*corePtr);
48+
_availableDevices.push_back(getTestPlatform());
49+
50+
if (_availableDevices.empty()) {
51+
auto deviceName = getDeviceName();
52+
if (!deviceName.empty()) {
53+
_availableDevices.push_back(getDeviceNameID(deviceName));
54+
}
55+
}
56+
57+
if (_availableDevices.empty()) {
58+
_availableDevices = ::getAvailableDevices(*corePtr);
59+
}
5460
} else {
5561
_log.error("Failed to get OpenVINO Core from cache!");
5662
}
5763

5864
// Private device names may be registered via environment variables
5965
const std::string environmentDevice =
60-
ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::intel_npu::Platform::AUTO_DETECT.data());
66+
getTestsPlatformFromEnvironmentOr(ov::intel_npu::Platform::AUTO_DETECT.data());
6167
const std::string standardizedEnvironmentDevice = ov::intel_npu::Platform::standardize(environmentDevice);
6268

6369
if (std::all_of(_availableDevices.begin(), _availableDevices.end(), [&](const std::string& deviceName) {
6470
return deviceName.find(standardizedEnvironmentDevice) == std::string::npos;
6571
})) {
66-
_availableDevices.push_back(standardizedEnvironmentDevice);
72+
_availableDevices.push_back(getDeviceNameID(standardizedEnvironmentDevice));
6773
}
6874

6975
auto driverVersionPropetry =
70-
corePtr->get_property(ov::test::utils::DEVICE_NPU, ov::intel_npu::driver_version.name());
76+
corePtr->get_property(DEVICE_NPU, ov::intel_npu::driver_version.name());
7177
_driverVersion = driverVersionPropetry.as<std::string>();
7278

7379
}
@@ -76,20 +82,10 @@ class AvailableDevices {
7682
return _availableDevices;
7783
}
7884

79-
auto count() const {
80-
return _availableDevices.size();
81-
}
82-
8385
const std::string& getDriverVersion() const {
8486
return _driverVersion;
8587
}
8688

87-
bool has3720() const {
88-
return std::any_of(_availableDevices.begin(), _availableDevices.end(), [](const std::string& deviceName) {
89-
return deviceName.find("3720") != std::string::npos;
90-
});
91-
}
92-
9389
private:
9490
std::vector<std::string> _availableDevices;
9591
std::string _driverVersion;
@@ -110,14 +106,6 @@ class CurrentOS {
110106
return _name;
111107
}
112108

113-
bool isLinux() const {
114-
return _name == "linux";
115-
}
116-
117-
bool isWindows() const {
118-
return _name == "windows";
119-
}
120-
121109
private:
122110
std::string _name;
123111
};
@@ -255,10 +243,10 @@ std::vector<std::string> disabledTestPatterns() {
255243
const CurrentOS currentOS;
256244

257245
try {
258-
const auto& filePath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_SKIP_CONFIG_FILE;
246+
const auto& filePath = NpuTestEnvConfig::getInstance().OV_NPU_TESTS_SKIP_CONFIG_FILE;
259247
_log.info("Using %s as skip config", filePath.c_str());
260248

261-
auto xmlResult = ov::util::pugixml::parse_xml(filePath.c_str());
249+
auto xmlResult = parse_xml(filePath.c_str());
262250
// Error returned from pugixml, fallback to legacy skips
263251
if (!xmlResult.error_msg.empty()) {
264252
_log.error(xmlResult.error_msg.c_str());

0 commit comments

Comments
 (0)