Skip to content

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

[NPU] Implement driver type skip mechanism (#36661)

Alexandru Enache749d332ac8bb
diff --git a/src/plugins/intel_npu/tests/functional/README.md b/src/plugins/intel_npu/tests/functional/README.md
index e190aa82a0c..b4da6af2e94 100644
--- a/src/plugins/intel_npu/tests/functional/README.md
+++ b/src/plugins/intel_npu/tests/functional/README.md
@@ -4,6 +4,21 @@ Test binary `ov_npu_func_tests` is built with GTest framework and includes test
for other OpenVINO plugins as well as test instances specific for this plugin.
`ov_npu_func_tests --help` will show the usage.
+## Command line arguments
+
+`ov_npu_func_tests` accepts the following command line arguments (alongside the standard GTest flags):
+
+* `--driver_release={pv|release|latest}` - declares which driver flavour the tests are running against. It does not detect the driver; it only records what the caller states, so skip rules and in-test guards can react to it. When omitted, it defaults to `latest`. An unrecognised value is ignored with a warning and the default is kept.
+
+The declared driver type feeds two mechanisms:
+* the `<driver_release>` skip rule in the skip config file (see below);
+* the in-code skip macros in [`common/npu_driver_aware_test.hpp`](./common/npu_driver_aware_test.hpp):
+ * `NPU_SKIP_IF_DRIVER_TYPE_IS(type, reason)` - `GTEST_SKIP()` when the declared driver type matches `type`;
+ * `NPU_SKIP_UNLESS_DRIVER_TYPE_IS(type, reason)` - `GTEST_SKIP()` when it does not match `type`;
+ * `ov::test::behavior::isDriverType(DriverType::type)` - predicate for branching inside a test.
+
+ `type` is one of `PV`, `RELEASE`, `LATEST`. Because the default is `LATEST`, a test guarded by `NPU_SKIP_IF_DRIVER_TYPE_IS(LATEST, ...)` is skipped even when no `--driver_release` argument is passed.
+
## Environment variables
The following environment variables can be set up for the run of test binary `ov_npu_func_tests`. Values for boolean variables are specified as `1` or `0`.
@@ -39,7 +54,9 @@ By default, the environment variable `OV_NPU_TESTS_SKIP_CONFIG_FILE` is set to f
<backend></backend> (empty brackets denote no backend)
<device>3720</device>
<device>!4000</device> (using "!" to negate rule)
- <driver_version>9999</driver_version>
+ <driver_version>9999</driver_version> (exact build number, safe only for PV drivers)
+ <driver_release>PV</driver_release> (driver type from --driver_release CLI arg: PV | RELEASE | LATEST)
+ <driver_release>!LATEST</driver_release> (negate: applies on PV and RELEASE)
<operating_system>windows</operating_system>
<operating_system>linux</operating_system>
</enable_rules>
@@ -52,9 +69,9 @@ By default, the environment variable `OV_NPU_TESTS_SKIP_CONFIG_FILE` is set to f
</skip_configs>
```
-Skip filters can be enabled/disabled according to rules defining the device, backend, driver version or operating system, depending on where tests are supposed to run.
+Skip filters can be enabled/disabled according to rules defining the device, backend, driver version, driver type or operating system, depending on where tests are supposed to run.
Rules are optional, multiple rules can be chained together. Users can negate a rule by using "!".
-When determining if a skip filter is active, rules across different categories (backend, device, driver_version, operating_system) are combined using an AND operation. While multiple entries of the same category will be evaluated using the OR operation.
+When determining if a skip filter is active, rules across different categories (backend, device, driver_version, driver_release, operating_system) are combined using an AND operation. While multiple entries of the same category will be evaluated using the OR operation.
## Folder structure
diff --git a/src/plugins/intel_npu/tests/functional/common/npu_driver_aware_test.hpp b/src/plugins/intel_npu/tests/functional/common/npu_driver_aware_test.hpp
new file mode 100644
index 00000000000..199de9aefcb
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/common/npu_driver_aware_test.hpp
@@ -0,0 +1,35 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "common/npu_test_env_cfg.hpp"
+
+// Example: NPU_SKIP_IF_DRIVER_TYPE_IS(PV, "C#12345: feature X not supported on PV driver");
+#define NPU_SKIP_IF_DRIVER_TYPE_IS(type, reason) \
+ do { \
+ if (::ov::test::behavior::isDriverType(::ov::test::utils::DriverType::type)) { \
+ GTEST_SKIP() << (reason); \
+ } \
+ } while (0)
+
+#define NPU_SKIP_UNLESS_DRIVER_TYPE_IS(type, reason) \
+ do { \
+ if (!::ov::test::behavior::isDriverType(::ov::test::utils::DriverType::type)) { \
+ GTEST_SKIP() << (reason); \
+ } \
+ } while (0)
+
+namespace ov::test::behavior {
+
+inline ov::test::utils::DriverType getDriverType() {
+ return ov::test::utils::NpuTestEnvConfig::getInstance().driver_type;
+}
+
+// Returns true when the driver type matches `type`.
+inline bool isDriverType(ov::test::utils::DriverType type) {
+ return getDriverType() == type;
+}
+
+} // namespace ov::test::behavior
diff --git a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp
index 3264f9fe7bd..d9f9f8568d0 100644
--- a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp
+++ b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp
@@ -149,6 +149,45 @@ const NpuTestEnvConfig& NpuTestEnvConfig::getInstance() {
return instance;
}
+std::string driverTypeToString(DriverType type) {
+ switch (type) {
+ case DriverType::PV:
+ return "PV";
+ case DriverType::RELEASE:
+ return "RELEASE";
+ case DriverType::LATEST:
+ return "LATEST";
+ }
+ return "";
+}
+
+std::optional<DriverType> parseDriverType(const std::string& str) {
+ // accept any case ("PV", "pv", "Pv", ...) and ignore surrounding whitespace
+ const auto begin = std::find_if_not(str.begin(), str.end(), [](unsigned char c) {
+ return std::isspace(c);
+ });
+ const auto end = std::find_if_not(str.rbegin(), str.rend(), [](unsigned char c) {
+ return std::isspace(c);
+ }).base();
+
+ std::string normalized;
+ if (begin < end) {
+ normalized.reserve(static_cast<size_t>(end - begin));
+ std::transform(begin, end, std::back_inserter(normalized), [](unsigned char c) {
+ return static_cast<char>(std::tolower(c));
+ });
+ }
+
+ if (normalized == "pv") {
+ return DriverType::PV;
+ } else if (normalized == "release") {
+ return DriverType::RELEASE;
+ } else if (normalized == "latest") {
+ return DriverType::LATEST;
+ }
+ return std::nullopt;
+}
+
std::string getTestsDeviceNameFromEnvironmentOr(const std::string& instead) {
return (!NpuTestEnvConfig::getInstance().IE_NPU_TESTS_DEVICE_NAME.empty())
? NpuTestEnvConfig::getInstance().IE_NPU_TESTS_DEVICE_NAME
diff --git a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.hpp b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.hpp
index da483c2f535..1969d786a0b 100644
--- a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.hpp
+++ b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.hpp
@@ -7,20 +7,31 @@
#include <gtest/gtest.h>
#include <openvino/runtime/device_id_parser.hpp>
+#include <optional>
#include <string>
-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
#include "intel_npu/npu_private_properties.hpp"
+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
using namespace ov::test::behavior;
namespace ov::test::utils {
+enum class DriverType { PV, RELEASE, LATEST };
+
+std::string driverTypeToString(DriverType type);
+
+std::optional<DriverType> parseDriverType(const std::string& str);
+
/**
- * Reads configuration environment variables
+ * Reads configuration environment variables and CLI arguments
*/
class NpuTestEnvConfig {
public:
+ // CLI argument: --driver_release={pv|release|latest}
+ // Defaults to LATEST when not provided. Set in main.cpp before tests run
+ mutable DriverType driver_release = DriverType::LATEST;
+
std::string IE_NPU_TESTS_DEVICE_NAME;
std::string IE_NPU_TESTS_DUMP_PATH;
std::string IE_NPU_TESTS_LOG_LEVEL;
diff --git a/src/plugins/intel_npu/tests/functional/main.cpp b/src/plugins/intel_npu/tests/functional/main.cpp
index 8c8b85b76e3..6b0704904c4 100644
--- a/src/plugins/intel_npu/tests/functional/main.cpp
+++ b/src/plugins/intel_npu/tests/functional/main.cpp
@@ -10,6 +10,7 @@
#include <iostream>
#include <sstream>
+#include "common/npu_test_env_cfg.hpp"
#include "gtest/gtest.h"
#include "intel_npu/config/config.hpp"
#include "intel_npu/npu_private_properties.hpp"
@@ -59,8 +60,8 @@ int main(int argc, char** argv, char** envp) {
oss << *env << "; ";
}
- auto blobPaths = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH;
- if (blobPaths.empty()) {
+ auto& cfg = ov::test::utils::NpuTestEnvConfig::getInstance();
+ if (cfg.OV_NPU_TESTS_BLOBS_PATH.empty()) {
auto path = std::string_view(argv[0]);
const char slashDelimiter = '/';
const char backSlashDelimiter = '\\';
@@ -74,12 +75,30 @@ int main(int argc, char** argv, char** envp) {
? path.find_last_of(backSlashDelimiter)
: path.find_last_of(slashDelimiter);
}
- ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH =
- pos != std::string_view::npos ? path.substr(0, pos + 1) : "";
- ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH += "intel_npu_blobs/";
+ cfg.OV_NPU_TESTS_BLOBS_PATH = pos != std::string_view::npos ? path.substr(0, pos + 1) : "";
+ cfg.OV_NPU_TESTS_BLOBS_PATH += "intel_npu_blobs/";
}
::testing::InitGoogleTest(&argc, argv);
+
+ for (int i = 1; i < argc; i++) {
+ const std::string_view arg(argv[i]);
+ constexpr std::string_view prefix = "--driver_release=";
+ if (arg.find(prefix) == 0) {
+ const std::string_view value = arg.substr(prefix.length());
+ auto parsed = ov::test::utils::parseDriverType(value.data());
+ if (parsed.has_value()) {
+ cfg.driver_release = *parsed;
+ std::cout << "Driver type set to: " << ov::test::utils::driverTypeToString(cfg.driver_release)
+ << std::endl;
+ } else {
+ std::cerr << "WARNING: Invalid --driver_release value: '" << value
+ << "' (expected pv, release, or latest)." << std::endl;
+ }
+ break;
+ }
+ }
+
::testing::AddGlobalTestEnvironment(new ov::test::utils::NpuTestReportEnvironment());
const bool dryRun = ::testing::GTEST_FLAG(list_tests) || ::testing::internal::g_help_flag;
@@ -102,7 +121,7 @@ int main(int argc, char** argv, char** envp) {
const std::string noFetch{"<not fetched>"};
std::string backend{noFetch}, arch{noFetch}, full{noFetch};
try {
- ov::test::utils::NpuTestTool npuTestTool(ov::test::utils::NpuTestEnvConfig::getInstance());
+ ov::test::utils::NpuTestTool npuTestTool(cfg);
backend = npuTestTool.getDeviceMetric(ov::intel_npu::backend_name.name());
arch = npuTestTool.getDeviceMetric(ov::device::architecture.name());
full = npuTestTool.getDeviceMetric(ov::device::full_name.name());
@@ -121,9 +140,9 @@ int main(int argc, char** argv, char** envp) {
}
auto& log = intel_npu::Logger::global();
- auto level = ov::test::utils::NpuTestEnvConfig::getInstance().IE_NPU_TESTS_LOG_LEVEL;
- ov::log::Level logLevel =
- level.empty() ? ov::log::Level::ERR : intel_npu::OptionParser<ov::log::Level>::parse(level.c_str());
+ ov::log::Level logLevel = cfg.IE_NPU_TESTS_LOG_LEVEL.empty()
+ ? ov::log::Level::ERR
+ : intel_npu::OptionParser<ov::log::Level>::parse(cfg.IE_NPU_TESTS_LOG_LEVEL.c_str());
log.setLevel(logLevel);
return RUN_ALL_TESTS();
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
index b5daf5ce90e..0a172683990 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
@@ -7,6 +7,9 @@ Example:
<backend></backend> (special case for no backend)
<device>3720</device>
<device>!4000</device> (using "!" to negate rule)
+ <driver_version>1688</driver_version> (exact build number, safe only for PV builds)
+ <driver_release>PV</driver_release> (driver type from --driver_release CLI arg: PV | RELEASE | LATEST)
+ <driver_release>!LATEST</driver_release> (negate: applies on PV and RELEASE)
<operating_system>windows</operating_system>
<operating_system>linux</operating_system>
</enable_rules>
@@ -105,7 +108,7 @@ Example:
<message>Data types not supported by NPU3720 PV Driver.</message>
<enable_rules>
<device>3720</device>
- <driver_version>1688</driver_version>
+ <driver_release>PV</driver_release>
</enable_rules>
<filters>
<filter>.*InferRequestIOTensorSetPrecisionTest.*type=boolean.*</filter>
@@ -163,7 +166,7 @@ Example:
<message>Failing Windows PV Driver core threading tests</message>
<enable_rules>
<device>3720</device>
- <driver_version>1688</driver_version>
+ <driver_release>PV</driver_release>
<operating_system>windows</operating_system>
</enable_rules>
<filters>
@@ -288,7 +291,7 @@ Example:
<message>PV driver cannot create infer request for models with boolean inputs</message>
<enable_rules>
<device>3720</device>
- <driver_version>1688</driver_version>
+ <driver_release>PV</driver_release>
</enable_rules>
<filters>
<filter>.*BooleanPrecisionInferRequestRunTests.*</filter>
@@ -331,7 +334,7 @@ Example:
<message>UD12 driver does not support CACHE_ENCRYPTION_CALLBACKS on MTL</message>
<enable_rules>
<device>3720</device>
- <driver_version>2020568</driver_version>
+ <driver_release>RELEASE</driver_release>
</enable_rules>
<filters>
<filter>.*OVClassCompiledModelPropertiesTests.CanUseCache.*CACHE_ENCRYPTION_CALLBACKS.*</filter>
@@ -345,7 +348,7 @@ Example:
<skip_config>
<message>UD12 driver does not support secure compilation</message>
<enable_rules>
- <driver_version>2020568</driver_version>
+ <driver_release>RELEASE</driver_release>
</enable_rules>
<filters>
<filter>.*WeightlessCacheAccuracy.ReadConcatSplitAssign.*do_encryption=True.*(config=_|NPU_COMPILER_TYPE\[DRIVER\]).*</filter>
@@ -358,7 +361,7 @@ Example:
<message>PV driver cannot compile models securely</message>
<enable_rules>
<device>3720</device>
- <driver_version>1688</driver_version>
+ <driver_release>PV</driver_release>
</enable_rules>
<filters>
<filter>.*OVHoldersTestNPU.CompileModelWithEncryptionWorksAfterConfigDeallocate.*</filter>
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
index a235d171b25..147e6d1bc6a 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/skip_tests_config.cpp
@@ -72,10 +72,8 @@ public:
_availableDevices.push_back(getDeviceNameID(standardizedEnvironmentDevice));
}
- auto driverVersionPropetry =
- corePtr->get_property(DEVICE_NPU, ov::intel_npu::driver_version.name());
+ auto driverVersionPropetry = corePtr->get_property(DEVICE_NPU, ov::intel_npu::driver_version.name());
_driverVersion = driverVersionPropetry.as<std::string>();
-
}
const auto& getAvailableDevices() const {
@@ -273,6 +271,9 @@ const std::vector<std::regex>& disabled_test_patterns() {
ruleFlag &= categoryRuleEnabler("backend", {backendName.getName()}, enableRules);
ruleFlag &= categoryRuleEnabler("device", devices.getAvailableDevices(), enableRules);
ruleFlag &= categoryRuleEnabler("driver_version", {devices.getDriverVersion()}, enableRules);
+ ruleFlag &= categoryRuleEnabler("driver_release",
+ {driverTypeToString(NpuTestEnvConfig::getInstance().driver_release)},
+ enableRules);
ruleFlag &= categoryRuleEnabler("operating_system", {currentOS.getName()}, enableRules);
}