Skip to content

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

[NPU] Offline Compilation Test for 5020 (#34674)

Sorin Butnariu0fa009b1d380
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_api.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_api.hpp
index 52af570d1b2..832e55c40d9 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_api.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_api.hpp
@@ -65,7 +65,8 @@ namespace intel_npu {
symbol_statement(zeCommandListGetNextCommandIdExp) \
symbol_statement(zeCommandListUpdateMutableCommandsExp) \
symbol_statement(zeInitDrivers) \
- symbol_statement(zelGetLoaderVersion)
+ symbol_statement(zelGetLoaderVersion) \
+ symbol_statement(zelSetDriverTeardown)
// clang-format on
class ZeroApi {
diff --git a/src/plugins/intel_npu/tests/unit/main.cpp b/src/plugins/intel_npu/tests/unit/main.cpp
index 73cb83389ab..9cd7108d044 100644
--- a/src/plugins/intel_npu/tests/unit/main.cpp
+++ b/src/plugins/intel_npu/tests/unit/main.cpp
@@ -10,7 +10,6 @@
#include "intel_npu/utils/zero/zero_api.hpp"
#include "openvino/util/file_util.hpp"
#include "openvino/util/shared_object.hpp"
-#include "ze_api.h"
#ifdef WIN32
# include <process.h>
#endif
@@ -27,19 +26,12 @@ int main(int argc, char** argv, char** envp) {
// register crashHandler for SIGSEGV signal
signal(SIGSEGV, sigsegv_handler);
- std::shared_ptr<void> lib;
+ std::shared_ptr<intel_npu::ZeroApi> zeroApi;
try {
- using zelSetDriverTeardownF = ze_result_t (*)();
- zelSetDriverTeardownF zelSetDriverTeardown = nullptr;
-
- auto libpath = ov::util::make_plugin_library_name({}, "ze_loader");
-#if !defined(_WIN32) && !defined(ANDROID)
- libpath += LIB_ZE_LOADER_SUFFIX;
-#endif
- lib = ov::util::load_shared_object(libpath);
- zelSetDriverTeardown =
- reinterpret_cast<zelSetDriverTeardownF>(ov::util::get_symbol(lib, "zelSetDriverTeardown"));
- zelSetDriverTeardown();
+ zeroApi = intel_npu::ZeroApi::getInstance();
+ if (zeroApi) {
+ zeroApi->zelSetDriverTeardown();
+ }
} catch (...) {
// ze_loader not present on the system, probably it is not an NPU host
}
diff --git a/src/plugins/intel_npu/tests/unit/npu/offline_compilation.cpp b/src/plugins/intel_npu/tests/unit/npu/offline_compilation.cpp
index bfa2763c4cc..5a49b4ba661 100644
--- a/src/plugins/intel_npu/tests/unit/npu/offline_compilation.cpp
+++ b/src/plugins/intel_npu/tests/unit/npu/offline_compilation.cpp
@@ -16,38 +16,47 @@
using namespace ov::intel_npu;
using namespace ov::test::utils;
-class OfflineCompilationUnitTests : public ::testing::Test {
+class OfflineCompilationUnitTests : public ::testing::TestWithParam<ov::AnyMap> {
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<ParamType>& info) {
+ std::string result;
+ for (const auto& [key, value] : info.param) {
+ result += value.as<std::string>();
+ }
+ return result;
+ }
+
protected:
void SetUp() override {
+ config = GetParam();
std::vector<std::string> availableDevices = core.get_available_devices();
auto it = std::find(availableDevices.begin(), availableDevices.end(), DEVICE_NPU);
ASSERT_TRUE(it == availableDevices.end());
}
ov::Core core;
-};
-
-TEST_F(OfflineCompilationUnitTests, CompileWithCiPWhenDriverNotInstalledSetProperty) {
ov::AnyMap config;
+};
- config[ov::intel_npu::compiler_type.name()] = ov::intel_npu::CompilerType::PLUGIN;
- config[ov::intel_npu::platform.name()] = ov::intel_npu::Platform::NPU5010;
+TEST_P(OfflineCompilationUnitTests, CompileWithCiPWhenDriverNotInstalledSetProperty) {
core.set_property(DEVICE_NPU, config);
std::shared_ptr<ov::Model> model = ov::test::utils::make_multi_single_conv();
OV_ASSERT_NO_THROW(core.compile_model(model, DEVICE_NPU));
}
-TEST_F(OfflineCompilationUnitTests, CompileWithCiPWhenDriverNotInstalled) {
- ov::AnyMap config;
-
- config[ov::intel_npu::compiler_type.name()] = ov::intel_npu::CompilerType::PLUGIN;
- config[ov::intel_npu::platform.name()] = ov::intel_npu::Platform::NPU5010;
-
+TEST_P(OfflineCompilationUnitTests, CompileWithCiPWhenDriverNotInstalled) {
std::shared_ptr<ov::Model> model = ov::test::utils::make_multi_single_conv();
OV_ASSERT_NO_THROW(core.compile_model(model, DEVICE_NPU, config));
}
+INSTANTIATE_TEST_SUITE_P(
+ OfflineCompilationPlatforms,
+ OfflineCompilationUnitTests,
+ ::testing::Values(ov::AnyMap{{ov::intel_npu::platform.name(), ov::intel_npu::Platform::NPU5010}},
+ ov::AnyMap{{ov::intel_npu::platform.name(), ov::intel_npu::Platform::NPU5020}}),
+ OfflineCompilationUnitTests::getTestCaseName);
+
using UnavailableDeviceTests = ::testing::Test;
TEST_F(UnavailableDeviceTests, GetDeviceNotAvailable) {