From 2118ba6a1f83adf8f2489fcd210a6cc5f98af823 Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Thu, 16 Oct 2025 16:19:40 +0300 Subject: [PATCH 1/6] Add support for graph ext version 1.4 Signed-off-by: Bogdan Pereanu --- .../include/ze_graph_ext_wrappers.hpp | 5 +- .../src/driver_compiler_adapter.cpp | 18 +- .../src/ze_graph_ext_wrappers.cpp | 206 +++++++++----- .../internal/backend/zero_tensor_tests.hpp | 1 - .../backend/zero_variable_state_tests.hpp | 1 - .../internal/compiler_adapter/zero_graph.cpp | 20 +- .../internal/compiler_adapter/zero_graph.hpp | 256 +++++++++++------- .../npu_skip_func_tests.xml | 14 - 8 files changed, 309 insertions(+), 212 deletions(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp index e88ebe5634ab4d..cdaeb5e34e35c9 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp @@ -35,7 +35,7 @@ class ZeGraphExtWrappers { GraphDescriptor getGraphDescriptor(SerializedIR serializedIR, const std::string& buildFlags, - const uint32_t& flags) const; + const Config& config) const; GraphDescriptor getGraphDescriptor(void* data, size_t size) const; @@ -60,6 +60,9 @@ class ZeGraphExtWrappers { bool isBlobDataImported(const GraphDescriptor& graphDescriptor) const; private: + std::unordered_set getQueryResultFromSupportedLayers( + ze_graph_query_network_handle_t& hGraphQueryNetwork) const; + void getMetadata(ze_graph_handle_t graphHandle, uint32_t index, std::vector& inputs, diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp index 9cd1320b1a59aa..70d47da3ca68e9 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp @@ -101,15 +101,8 @@ std::shared_ptr DriverCompilerAdapter::compile(const std::shared_ptr(); - if (!set_cache_dir.empty() || config.get()) { - flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; - } - _logger.debug("compile start"); - auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, flags); + auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, config); _logger.debug("compile end"); OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta"); @@ -161,13 +154,6 @@ std::shared_ptr DriverCompilerAdapter::compileWS(const std::shared_ptr(); - if (!set_cache_dir.empty() || config.get()) { - flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; - } - // WS v3 is based on a stateless compiler. We'll use a separate config entry for informing the compiler the index of // the current call iteration. std::vector initNetworkMetadata; @@ -191,7 +177,7 @@ std::shared_ptr DriverCompilerAdapter::compileWS(const std::shared_ptrgetGraphDescriptor(serializedIR, buildFlags, flags); + auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR, buildFlags, config); _logger.debug("compile end"); OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta"); diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index f27c4187b81134..3e28926fdce185 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -8,6 +8,7 @@ #include +#include "intel_npu/config/options.hpp" #include "intel_npu/prefix.hpp" #include "intel_npu/utils/utils.hpp" #include "intel_npu/utils/zero/zero_api.hpp" @@ -17,6 +18,12 @@ #include "openvino/core/dimension.hpp" #include "openvino/core/partial_shape.hpp" +// ext version >= 1.5, support API (pfnQueryNetworkCreate2, pfnQueryContextMemory) +#define NotSupportAPIGraphQueryNetworkV2(T) (T < ZE_GRAPH_EXT_VERSION_1_5) + +// For ext version >= 1.5, pfnCreate2 api is available +#define NotSupportGraph2(T) (T < ZE_GRAPH_EXT_VERSION_1_5) + // A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to // "ze_graph_dditable_ext_1_6_t". // See: E#117498 @@ -133,8 +140,8 @@ ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr parseQueryResult(std::vector& data) return result; } -std::unordered_set ZeGraphExtWrappers::queryGraph(SerializedIR serializedIR, - const std::string& buildFlags) const { - // For ext version >= 1.5 - ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; - - // For ext version >= 1.5 - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - ZE_GRAPH_FLAG_NONE}; - - // Create querynetwork handle - _logger.debug("For ext larger than 1.4 - perform pfnQueryNetworkCreate2"); - ze_result_t result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &hGraphQueryNetwork); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate2", result, _zeroInitStruct->getGraphDdiTable()); - - _logger.debug("queryGraph - perform pfnQueryNetworkGetSupportedLayers to get size"); +std::unordered_set ZeGraphExtWrappers::getQueryResultFromSupportedLayers( + ze_graph_query_network_handle_t& hGraphQueryNetwork) const { + // Get the size of query result + _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkGetSupportedLayers to get size"); size_t size = 0; - result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); + auto result = + _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get size of query result", result, _zeroInitStruct->getGraphDdiTable()); // Get the result data of query - _logger.debug("queryGraph - perform pfnQueryNetworkGetSupportedLayers to get data"); + _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkGetSupportedLayers to get data"); std::vector supportedLayers(size); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, @@ -311,13 +300,57 @@ std::unordered_set ZeGraphExtWrappers::queryGraph(SerializedIR seri result, _zeroInitStruct->getGraphDdiTable()); - _logger.debug("queryGraph - perform pfnQueryNetworkDestroy"); + _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkDestroy"); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkDestroy(hGraphQueryNetwork); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkDestroy", result, _zeroInitStruct->getGraphDdiTable()); return parseQueryResult(supportedLayers); } +std::unordered_set ZeGraphExtWrappers::queryGraph(SerializedIR serializedIR, + const std::string& buildFlags) const { + if (NotSupportAPIGraphQueryNetworkV2(_graphExtVersion)) { + // For ext version == 1.4, query network is supported + ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; + + ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str()}; + + _logger.debug("queryGraph - perform pfnQueryNetworkCreate"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate", result, _zeroInitStruct->getGraphDdiTable()); + + return getQueryResultFromSupportedLayers(hGraphQueryNetwork); + } else { + // For ext version >= 1.5 + ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; + + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + ZE_GRAPH_FLAG_NONE}; + + _logger.debug("queryGraph - perform pfnQueryNetworkCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate2", result, _zeroInitStruct->getGraphDdiTable()); + + return getQueryResultFromSupportedLayers(hGraphQueryNetwork); + } +} + bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size) const { if (_graphExtVersion < ZE_MAKE_VERSION(1, 13) || !utils::memory_and_size_aligned_to_standard_page_size(data, size)) { @@ -341,59 +374,100 @@ bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size) const { GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR, const std::string& buildFlags, - const uint32_t& flags) const { - // For ext version >= 1.5, calling pfnCreate2 api in _zeroInitStruct->getGraphDdiTable() - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - flags}; - - _logger.debug("getGraphDescriptor - perform pfnCreate2"); - // Create querynetwork handle + const Config& config) const { ze_graph_handle_t graphHandle = nullptr; - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + + if (NotSupportGraph2(_graphExtVersion)) { + // For ext version <1.5, calling pfnCreate api + ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str()}; + + _logger.debug("getGraphDescriptor - perform pfnCreate"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); + } else { + // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching + uint32_t flags = ZE_GRAPH_FLAG_NONE; + const auto set_cache_dir = config.get(); + if (!set_cache_dir.empty() || config.get()) { + flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; + } + + // For ext version >= 1.5, calling pfnCreate2 + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + flags}; + + _logger.debug("getGraphDescriptor - perform pfnCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + } return GraphDescriptor{graphHandle}; } GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t blobSize) const { ze_graph_handle_t graphHandle = nullptr; + bool setPersistentFlag = false; if (blobSize == 0) { OPENVINO_THROW("Empty blob"); } - uint32_t flags = 0; - bool setPersistentFlag = canCpuVaBeImported(blobData, blobSize); + if (NotSupportGraph2(_graphExtVersion)) { + // For ext version < 1.5, calling pfnCreate api + ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NATIVE, + blobSize, + reinterpret_cast(blobData), + nullptr}; + + _logger.debug("getGraphHandle - perform pfnCreate"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); + } else { + uint32_t flags = 0; + setPersistentFlag = canCpuVaBeImported(blobData, blobSize); + if (setPersistentFlag) { + _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); + flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; + } - if (setPersistentFlag) { - _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); - flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; + // For ext version >= 1.5, calling pfnCreate2 + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NATIVE, + blobSize, + reinterpret_cast(blobData), + nullptr, + flags}; + + _logger.debug("getGraphDescriptor - perform pfnCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); } - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NATIVE, - blobSize, - reinterpret_cast(blobData), - nullptr, - flags}; - - _logger.debug("getGraphDescriptor - perform pfnCreate2"); - - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); - return GraphDescriptor{graphHandle, setPersistentFlag}; } diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp index c554ae1e14af08..1519ddd772495d 100644 --- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp +++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp @@ -61,7 +61,6 @@ class ZeroTensorTests : public ov::test::behavior::OVPluginTestBase, ov::element::Type type; std::tie(targetDevice, configuration, type) = obj.param; std::replace(targetDevice.begin(), targetDevice.end(), ':', '_'); - targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU); std::ostringstream result; result << "targetDevice=" << targetDevice << "_"; diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp index ca2d1fa3fb736b..13379a41bb7dc1 100644 --- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp +++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp @@ -59,7 +59,6 @@ class ZeroVariableStateTests : public ov::test::behavior::OVPluginTestBase, ov::AnyMap configuration; std::tie(targetDevice, configuration) = obj.param; std::replace(targetDevice.begin(), targetDevice.end(), ':', '_'); - targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU); std::ostringstream result; result << "targetDevice=" << targetDevice << "_"; diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp index 683ba498eb1f2c..8c20306542e19f 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp @@ -4,23 +4,27 @@ #include "zero_graph.hpp" -#include - namespace { -std::vector graphDescflags = {ZE_GRAPH_FLAG_NONE, ZE_GRAPH_FLAG_DISABLE_CACHING, ZE_GRAPH_FLAG_ENABLE_PROFILING}; +const std::vector configsGraphCompilationTests = {{}, + {ov::cache_dir("test")}, + {ov::intel_npu::bypass_umd_caching(true)}}; -// tested versions interval is [1.5, CURRENT + 1) -auto extVersions = ::testing::Range(ZE_MAKE_VERSION(1, 5), ZE_GRAPH_EXT_VERSION_CURRENT + 1); +// tested versions interval is [1.4, CURRENT + 1) +auto graphExtVersions = ::testing::Range(ZE_MAKE_VERSION(1, 4), ZE_GRAPH_EXT_VERSION_CURRENT + 1); INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, ZeroGraphCompilationTests, - ::testing::Combine(::testing::ValuesIn(graphDescflags), extVersions), + ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU), + ::testing::ValuesIn(configsGraphCompilationTests), + graphExtVersions), ZeroGraphTest::getTestCaseName); -std::vector noneGraphDescflags = {ZE_GRAPH_FLAG_NONE}; +const std::vector emptyConfigsTests = {{}}; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, ZeroGraphTest, - ::testing::Combine(::testing::ValuesIn(noneGraphDescflags), extVersions), + ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU), + ::testing::ValuesIn(emptyConfigsTests), + graphExtVersions), ZeroGraphTest::getTestCaseName); } // namespace diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp index fccc36659fd149..ef1ff6cb2d55ae 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp @@ -12,15 +12,20 @@ #include "common/npu_test_env_cfg.hpp" #include "common_test_utils/subgraph_builders/multi_single_conv.hpp" #include "common_test_utils/test_constants.hpp" +#include "intel_npu/config/options.hpp" #include "intel_npu/utils/utils.hpp" #include "intel_npu/utils/zero/zero_mem.hpp" #include "intel_npu/utils/zero/zero_utils.hpp" #include "ir_serializer.hpp" +#include "openvino/runtime/intel_npu/properties.hpp" #include "ze_graph_ext_wrappers.hpp" #include "zero_init_mock.hpp" using namespace intel_npu; +using CompilationParamsAndExtensionVersion = std::tuple; // Extension Version namespace { size_t calculate_size_with_alignment_padding(size_t size, size_t alignment) { return size + alignment - (size % alignment); @@ -37,45 +42,28 @@ size_t get_file_size(std::ifstream& file) { } // namespace namespace ov::test::behavior { -class ZeroGraphTest : public ::testing::TestWithParam> { +class ZeroGraphTest : public ::testing::TestWithParam { public: - std::shared_ptr zeroInitStruct; - - std::shared_ptr zeGraphExt; - - SerializedIR serializedIR; - - GraphDescriptor graphDescriptor; - - std::shared_ptr model; - - std::shared_ptr irSerializer; - - std::string blobPath; - - int extVersion; - - int graphDescFlag; - - static std::string getTestCaseName(const testing::TestParamInfo>& obj) { - int flag, version; - std::tie(flag, version) = obj.param; - std::string targetDevice = ov::test::utils::DEVICE_NPU; + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + std::string targetDevice; + ov::AnyMap configuration; + int graphExtVersion; + std::tie(targetDevice, configuration, graphExtVersion) = obj.param; + std::replace(targetDevice.begin(), targetDevice.end(), ':', '_'); std::ostringstream result; result << "targetDevice=" << targetDevice << "_"; result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_"; - result << "graphDescriptorFlag=" + std::to_string(flag) << "_"; - result << "extVersion=" + std::to_string(ZE_MAJOR_VERSION(version)) + "." + - std::to_string(ZE_MINOR_VERSION(version)); - return result.str(); - } + if (!configuration.empty()) { + for (auto& configItem : configuration) { + result << "configItem=" << configItem.first << "_"; + configItem.second.print(result); + } + } + result << "graphExtVersion=" + std::to_string(ZE_MAJOR_VERSION(graphExtVersion)) + "." + + std::to_string(ZE_MINOR_VERSION(graphExtVersion)); - void serializeIR() { - auto compilerProperties = zeroInitStruct->getCompilerProperties(); - const ze_graph_compiler_version_info_t& compilerVersion = compilerProperties.compilerVersion; - const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported; - serializedIR = irSerializer->serializeIR(model, compilerVersion, maxOpsetVersion); + return result.str(); } protected: @@ -84,17 +72,24 @@ class ZeroGraphTest : public ::testing::TestWithParam> { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - std::tie(graphDescFlag, extVersion) = GetParam(); + std::tie(targetDevice, configuration, graphExtVersion) = this->GetParam(); const std::string BLOB_NAME = "blob_compatibility_dummy_model_MTL_ov_2025_1_0_driver_1003967.blob"; blobPath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH + BLOB_NAME; model = ov::test::utils::make_multi_single_conv(); - std::shared_ptr zeroInitMock = std::make_shared(extVersion); + options->add<::intel_npu::BYPASS_UMD_CACHING>(); + options->add<::intel_npu::CACHE_DIR>(); - zeroInitStruct = std::reinterpret_pointer_cast(zeroInitMock); + if (!configuration.empty()) { + for (auto& configItem : configuration) { + npu_config.update({{configItem.first, configItem.second.as()}}); + } + } + std::shared_ptr zeroInitMock = std::make_shared(graphExtVersion); + zeroInitStruct = std::reinterpret_pointer_cast(zeroInitMock); zeGraphExt = std::make_shared(zeroInitStruct); auto compilerProperties = zeroInitStruct->getCompilerProperties(); @@ -105,13 +100,37 @@ class ZeroGraphTest : public ::testing::TestWithParam> { void TearDown() override { zeGraphExt->destroyGraph(graphDescriptor); } + + void serializeIR() { + auto compilerProperties = zeroInitStruct->getCompilerProperties(); + const ze_graph_compiler_version_info_t& compilerVersion = compilerProperties.compilerVersion; + const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported; + serializedIR = irSerializer->serializeIR(model, compilerVersion, maxOpsetVersion); + } + + std::shared_ptr zeroInitStruct; + std::shared_ptr zeGraphExt; + ov::AnyMap configuration; + + std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>(); + ::intel_npu::Config npu_config = ::intel_npu::Config(options); + + SerializedIR serializedIR; + GraphDescriptor graphDescriptor; + + std::shared_ptr model; + std::shared_ptr irSerializer; + + std::string targetDevice; + std::string blobPath; + int graphExtVersion; }; using ZeroGraphCompilationTests = ZeroGraphTest; TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -122,7 +141,7 @@ TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) { TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -139,26 +158,32 @@ TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) { } TEST_P(ZeroGraphTest, GetGraphInitBlob) { - std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); - ASSERT_TRUE(blobStream.is_open()); - size_t size = get_file_size(blobStream); - - std::vector blob(size); - blobStream.read(reinterpret_cast(blob.data()), size); - blobStream.close(); - - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob.data(), blob.size())); - - uint32_t initCommandQueueOrdinal = 0; - OV_ASSERT_NO_THROW(initCommandQueueOrdinal = - zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), - ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); - OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); + std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice); + size_t pos = platform.find("3720"); + if (pos != std::string::npos) { + std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); + ASSERT_TRUE(blobStream.is_open()); + size_t size = get_file_size(blobStream); + + std::vector blob(size); + blobStream.read(reinterpret_cast(blob.data()), size); + blobStream.close(); + + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob.data(), blob.size())); + + uint32_t initCommandQueueOrdinal = 0; + OV_ASSERT_NO_THROW(initCommandQueueOrdinal = + zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); + OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); + } else { + GTEST_SKIP() << "Skip due to incompatible blob format on this platform."; + } } TEST_P(ZeroGraphTest, GetNetworkMeta) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); OV_ASSERT_NO_THROW(NetworkMetadata meta = zeGraphExt->getNetworkMeta(graphDescriptor)); } @@ -169,30 +194,36 @@ TEST_P(ZeroGraphTest, QueryGraph) { } TEST_P(ZeroGraphTest, GetGraphBinary) { - std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); - ASSERT_TRUE(blobStream.is_open()); - size_t size = get_file_size(blobStream); + std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice); + size_t pos = platform.find("3720"); + if (pos != std::string::npos) { + std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); + ASSERT_TRUE(blobStream.is_open()); + size_t size = get_file_size(blobStream); - std::vector blob(size); - blobStream.read(reinterpret_cast(blob.data()), size); - blobStream.close(); + std::vector blob(size); + blobStream.read(reinterpret_cast(blob.data()), size); + blobStream.close(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob.data(), blob.size())); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob.data(), blob.size())); - uint32_t initCommandQueueOrdinal = 0; - OV_ASSERT_NO_THROW(initCommandQueueOrdinal = - zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), - ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); - OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); + uint32_t initCommandQueueOrdinal = 0; + OV_ASSERT_NO_THROW(initCommandQueueOrdinal = + zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); + OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); - const uint8_t* blobPtr = nullptr; - OV_ASSERT_NO_THROW(zeGraphExt->getGraphBinary(graphDescriptor, blob, blobPtr, size)); + const uint8_t* blobPtr = nullptr; + OV_ASSERT_NO_THROW(zeGraphExt->getGraphBinary(graphDescriptor, blob, blobPtr, size)); + } else { + GTEST_SKIP() << "Skip due to incompatible blob format on this platform."; + } } TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -204,54 +235,69 @@ TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) { } TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob) { - std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); - ASSERT_TRUE(blobStream.is_open()); - size_t size = get_file_size(blobStream); - size = calculate_size_with_alignment_padding(size, ::utils::STANDARD_PAGE_SIZE); + std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice); + size_t pos = platform.find("3720"); + if (pos != std::string::npos) { + std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); + ASSERT_TRUE(blobStream.is_open()); + size_t size = get_file_size(blobStream); + size = calculate_size_with_alignment_padding(size, ::utils::STANDARD_PAGE_SIZE); - uint8_t* blob = static_cast(::operator new(size, std::align_val_t(::utils::STANDARD_PAGE_SIZE))); - blobStream.read(reinterpret_cast(blob), size); - blobStream.close(); + uint8_t* blob = static_cast(::operator new(size, std::align_val_t(::utils::STANDARD_PAGE_SIZE))); + blobStream.read(reinterpret_cast(blob), size); + blobStream.close(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, size)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, size)); - uint32_t initCommandQueueOrdinal = 0; - OV_ASSERT_NO_THROW(initCommandQueueOrdinal = - zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), - ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); - OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); + uint32_t initCommandQueueOrdinal = 0; + OV_ASSERT_NO_THROW(initCommandQueueOrdinal = + zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); + OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); - std::unique_ptr buffer; - OV_ASSERT_NO_THROW(buffer = std::make_unique(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false)); + std::unique_ptr buffer; + OV_ASSERT_NO_THROW(buffer = + std::make_unique(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false)); - OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data())); + OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data())); - ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE)); + ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE)); + } else { + GTEST_SKIP() << "Skip due to incompatible blob format on this platform."; + } } TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob) { - std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); - ASSERT_TRUE(blobStream.is_open()); - size_t size = get_file_size(blobStream); + std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice); + size_t pos = platform.find("3720"); + if (pos != std::string::npos) { + std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); + ASSERT_TRUE(blobStream.is_open()); + size_t size = get_file_size(blobStream); - uint8_t* blob = static_cast(::operator new(size, std::align_val_t(::utils::STANDARD_PAGE_SIZE))); - blobStream.read(reinterpret_cast(blob), size); - blobStream.close(); + uint8_t* blob = static_cast(::operator new(size, std::align_val_t(::utils::STANDARD_PAGE_SIZE))); + blobStream.read(reinterpret_cast(blob), size); + blobStream.close(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, size)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, size)); - uint32_t initCommandQueueOrdinal = 0; - OV_ASSERT_NO_THROW(initCommandQueueOrdinal = - zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), - ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); - OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); + uint32_t initCommandQueueOrdinal = 0; + OV_ASSERT_NO_THROW(initCommandQueueOrdinal = + zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(), + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE)); + OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal)); - std::unique_ptr buffer; - OV_ASSERT_NO_THROW(buffer = std::make_unique(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false)); + std::unique_ptr buffer; + OV_ASSERT_NO_THROW(buffer = + std::make_unique(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false)); - OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, static_cast(buffer->data()) + 1)); + OV_ASSERT_NO_THROW( + zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, static_cast(buffer->data()) + 1)); - ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE)); + ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE)); + } else { + GTEST_SKIP() << "Skip due to incompatible blob format on this platform."; + } } TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) { @@ -264,7 +310,7 @@ TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; @@ -299,7 +345,7 @@ TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; @@ -334,7 +380,7 @@ TEST_P(ZeroGraphTest, SetAlignedBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag)); + OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; 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 ad7ae5182004e8..20b0bff6176c23 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 @@ -845,18 +845,4 @@ Example: - - - Some ZeroGraphTest run only on NPU 3720 - - !3720 - - - .*smoke_BehaviorTest/ZeroGraphTest.GetGraphInitBlob.* - .*smoke_BehaviorTest/ZeroGraphTest.GetGraphBinary.* - .*smoke_BehaviorTest/ZeroGraphTest.GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob.* - .*smoke_BehaviorTest/ZeroGraphTest.GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob.* - - - From 37ec1630bfbae9245c0b0d05c512dfc15e16c366 Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Fri, 24 Oct 2025 10:30:35 +0300 Subject: [PATCH 2/6] Remove support for graph ext 1_4 Signed-off-by: Bogdan Pereanu --- .../include/ze_graph_ext_wrappers.hpp | 3 - .../src/ze_graph_ext_wrappers.cpp | 200 ++++++------------ .../internal/compiler_adapter/zero_graph.cpp | 4 +- 3 files changed, 65 insertions(+), 142 deletions(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp index cdaeb5e34e35c9..4feeeb4a538c1a 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp @@ -60,9 +60,6 @@ class ZeGraphExtWrappers { bool isBlobDataImported(const GraphDescriptor& graphDescriptor) const; private: - std::unordered_set getQueryResultFromSupportedLayers( - ze_graph_query_network_handle_t& hGraphQueryNetwork) const; - void getMetadata(ze_graph_handle_t graphHandle, uint32_t index, std::vector& inputs, diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 3e28926fdce185..18379c60a4ea86 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -18,12 +18,6 @@ #include "openvino/core/dimension.hpp" #include "openvino/core/partial_shape.hpp" -// ext version >= 1.5, support API (pfnQueryNetworkCreate2, pfnQueryContextMemory) -#define NotSupportAPIGraphQueryNetworkV2(T) (T < ZE_GRAPH_EXT_VERSION_1_5) - -// For ext version >= 1.5, pfnCreate2 api is available -#define NotSupportGraph2(T) (T < ZE_GRAPH_EXT_VERSION_1_5) - // A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to // "ze_graph_dditable_ext_1_6_t". // See: E#117498 @@ -138,10 +132,6 @@ ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr parseQueryResult(std::vector& data) return result; } -std::unordered_set ZeGraphExtWrappers::getQueryResultFromSupportedLayers( - ze_graph_query_network_handle_t& hGraphQueryNetwork) const { +std::unordered_set ZeGraphExtWrappers::queryGraph(SerializedIR serializedIR, + const std::string& buildFlags) const { + ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; + + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + ZE_GRAPH_FLAG_NONE}; + + _logger.debug("queryGraph - perform pfnQueryNetworkCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate2", result, _zeroInitStruct->getGraphDdiTable()); + // Get the size of query result - _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkGetSupportedLayers to get size"); + _logger.debug("queryGraph - perform pfnQueryNetworkGetSupportedLayers to get size"); size_t size = 0; - auto result = - _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); + result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get size of query result", result, _zeroInitStruct->getGraphDdiTable()); // Get the result data of query - _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkGetSupportedLayers to get data"); + _logger.debug("queryGraph - perform pfnQueryNetworkGetSupportedLayers to get data"); std::vector supportedLayers(size); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, @@ -300,57 +306,13 @@ std::unordered_set ZeGraphExtWrappers::getQueryResultFromSupportedL result, _zeroInitStruct->getGraphDdiTable()); - _logger.debug("getQueryResultFromSupportedLayers - perform pfnQueryNetworkDestroy"); + _logger.debug("queryGraph - perform pfnQueryNetworkDestroy"); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkDestroy(hGraphQueryNetwork); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkDestroy", result, _zeroInitStruct->getGraphDdiTable()); return parseQueryResult(supportedLayers); } -std::unordered_set ZeGraphExtWrappers::queryGraph(SerializedIR serializedIR, - const std::string& buildFlags) const { - if (NotSupportAPIGraphQueryNetworkV2(_graphExtVersion)) { - // For ext version == 1.4, query network is supported - ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; - - ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str()}; - - _logger.debug("queryGraph - perform pfnQueryNetworkCreate"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &hGraphQueryNetwork); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate", result, _zeroInitStruct->getGraphDdiTable()); - - return getQueryResultFromSupportedLayers(hGraphQueryNetwork); - } else { - // For ext version >= 1.5 - ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; - - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - ZE_GRAPH_FLAG_NONE}; - - _logger.debug("queryGraph - perform pfnQueryNetworkCreate2"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &hGraphQueryNetwork); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate2", result, _zeroInitStruct->getGraphDdiTable()); - - return getQueryResultFromSupportedLayers(hGraphQueryNetwork); - } -} - bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size) const { if (_graphExtVersion < ZE_MAKE_VERSION(1, 13) || !utils::memory_and_size_aligned_to_standard_page_size(data, size)) { @@ -377,46 +339,28 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR const Config& config) const { ze_graph_handle_t graphHandle = nullptr; - if (NotSupportGraph2(_graphExtVersion)) { - // For ext version <1.5, calling pfnCreate api - ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str()}; - - _logger.debug("getGraphDescriptor - perform pfnCreate"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); - } else { - // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching - uint32_t flags = ZE_GRAPH_FLAG_NONE; - const auto set_cache_dir = config.get(); - if (!set_cache_dir.empty() || config.get()) { - flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; - } - - // For ext version >= 1.5, calling pfnCreate2 - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - flags}; - - _logger.debug("getGraphDescriptor - perform pfnCreate2"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching + uint32_t flags = ZE_GRAPH_FLAG_NONE; + const auto set_cache_dir = config.get(); + if (!set_cache_dir.empty() || config.get()) { + flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; } + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + flags}; + + _logger.debug("getGraphDescriptor - perform pfnCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + return GraphDescriptor{graphHandle}; } @@ -428,46 +372,28 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t bl OPENVINO_THROW("Empty blob"); } - if (NotSupportGraph2(_graphExtVersion)) { - // For ext version < 1.5, calling pfnCreate api - ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NATIVE, - blobSize, - reinterpret_cast(blobData), - nullptr}; - - _logger.debug("getGraphHandle - perform pfnCreate"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); - } else { - uint32_t flags = 0; - setPersistentFlag = canCpuVaBeImported(blobData, blobSize); - if (setPersistentFlag) { - _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); - flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; - } - - // For ext version >= 1.5, calling pfnCreate2 - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NATIVE, - blobSize, - reinterpret_cast(blobData), - nullptr, - flags}; - - _logger.debug("getGraphDescriptor - perform pfnCreate2"); - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &graphHandle); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + uint32_t flags = 0; + setPersistentFlag = canCpuVaBeImported(blobData, blobSize); + if (setPersistentFlag) { + _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); + flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; } + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NATIVE, + blobSize, + reinterpret_cast(blobData), + nullptr, + flags}; + + _logger.debug("getGraphDescriptor - perform pfnCreate2"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + return GraphDescriptor{graphHandle, setPersistentFlag}; } diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp index 8c20306542e19f..e48a5ca12439ab 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp @@ -9,8 +9,8 @@ const std::vector configsGraphCompilationTests = {{}, {ov::cache_dir("test")}, {ov::intel_npu::bypass_umd_caching(true)}}; -// tested versions interval is [1.4, CURRENT + 1) -auto graphExtVersions = ::testing::Range(ZE_MAKE_VERSION(1, 4), ZE_GRAPH_EXT_VERSION_CURRENT + 1); +// tested versions interval is [1.5, CURRENT + 1) +auto graphExtVersions = ::testing::Range(ZE_MAKE_VERSION(1, 5), ZE_GRAPH_EXT_VERSION_CURRENT + 1); INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest, ZeroGraphCompilationTests, From 09f4071e975355cd6848ab40ea8cb3e35d0b4a97 Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Fri, 24 Oct 2025 14:24:21 +0300 Subject: [PATCH 3/6] Update src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp --- .../intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 18379c60a4ea86..7dd451e6fbbe3d 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -366,7 +366,6 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t blobSize) const { ze_graph_handle_t graphHandle = nullptr; - bool setPersistentFlag = false; if (blobSize == 0) { OPENVINO_THROW("Empty blob"); From b4bbc76bdc6904f8782beb0ba48906d972fc5dbd Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Fri, 24 Oct 2025 14:24:34 +0300 Subject: [PATCH 4/6] Update src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp --- .../src/compiler_adapter/src/ze_graph_ext_wrappers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 7dd451e6fbbe3d..2984870fc31a89 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -372,7 +372,7 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t bl } uint32_t flags = 0; - setPersistentFlag = canCpuVaBeImported(blobData, blobSize); + bool setPersistentFlag = canCpuVaBeImported(blobData, blobSize); if (setPersistentFlag) { _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; From 239b9b28baba4884da5d45ec46a29e035abec552 Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Fri, 24 Oct 2025 16:24:58 +0300 Subject: [PATCH 5/6] Don't share config with ze_graph_ext_wrappers Signed-off-by: Bogdan Pereanu --- .../include/ze_graph_ext_wrappers.hpp | 2 +- .../src/driver_compiler_adapter.cpp | 10 +++- .../src/ze_graph_ext_wrappers.cpp | 7 +-- .../internal/compiler_adapter/zero_graph.cpp | 2 + .../internal/compiler_adapter/zero_graph.hpp | 51 +++++++++++-------- 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp index 4feeeb4a538c1a..94a058650019e0 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp @@ -35,7 +35,7 @@ class ZeGraphExtWrappers { GraphDescriptor getGraphDescriptor(SerializedIR serializedIR, const std::string& buildFlags, - const Config& config) const; + const bool bypassUmdCache = false) const; GraphDescriptor getGraphDescriptor(void* data, size_t size) const; diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp index 70d47da3ca68e9..ed1a83261c3c6e 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp @@ -102,7 +102,10 @@ std::shared_ptr DriverCompilerAdapter::compile(const std::shared_ptrgetGraphDescriptor(std::move(serializedIR), buildFlags, config); + // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching + const auto setCacheDir = config.get(); + bool bypassCache = !setCacheDir.empty() || config.get(); + auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, bypassCache); _logger.debug("compile end"); OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta"); @@ -177,7 +180,10 @@ std::shared_ptr DriverCompilerAdapter::compileWS(const std::shared_ptrgetGraphDescriptor(serializedIR, buildFlags, config); + // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching + const auto setCacheDir = config.get(); + bool bypassCache = !setCacheDir.empty() || config.get(); + auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR, buildFlags, bypassCache); _logger.debug("compile end"); OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta"); diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 2984870fc31a89..086b92bae065a4 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -8,7 +8,6 @@ #include -#include "intel_npu/config/options.hpp" #include "intel_npu/prefix.hpp" #include "intel_npu/utils/utils.hpp" #include "intel_npu/utils/zero/zero_api.hpp" @@ -336,13 +335,11 @@ bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size) const { GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR, const std::string& buildFlags, - const Config& config) const { + const bool bypassUmdCache) const { ze_graph_handle_t graphHandle = nullptr; - // If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching uint32_t flags = ZE_GRAPH_FLAG_NONE; - const auto set_cache_dir = config.get(); - if (!set_cache_dir.empty() || config.get()) { + if (bypassUmdCache) { flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; } diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp index e48a5ca12439ab..266a6d013335c3 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp @@ -4,6 +4,8 @@ #include "zero_graph.hpp" +#include "openvino/runtime/intel_npu/properties.hpp" + namespace { const std::vector configsGraphCompilationTests = {{}, {ov::cache_dir("test")}, diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp index ef1ff6cb2d55ae..68502ab801defb 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp @@ -12,12 +12,10 @@ #include "common/npu_test_env_cfg.hpp" #include "common_test_utils/subgraph_builders/multi_single_conv.hpp" #include "common_test_utils/test_constants.hpp" -#include "intel_npu/config/options.hpp" #include "intel_npu/utils/utils.hpp" #include "intel_npu/utils/zero/zero_mem.hpp" #include "intel_npu/utils/zero/zero_utils.hpp" #include "ir_serializer.hpp" -#include "openvino/runtime/intel_npu/properties.hpp" #include "ze_graph_ext_wrappers.hpp" #include "zero_init_mock.hpp" @@ -79,15 +77,6 @@ class ZeroGraphTest : public ::testing::TestWithParamadd<::intel_npu::BYPASS_UMD_CACHING>(); - options->add<::intel_npu::CACHE_DIR>(); - - if (!configuration.empty()) { - for (auto& configItem : configuration) { - npu_config.update({{configItem.first, configItem.second.as()}}); - } - } - std::shared_ptr zeroInitMock = std::make_shared(graphExtVersion); zeroInitStruct = std::reinterpret_pointer_cast(zeroInitMock); zeGraphExt = std::make_shared(zeroInitStruct); @@ -108,13 +97,30 @@ class ZeroGraphTest : public ::testing::TestWithParamserializeIR(model, compilerVersion, maxOpsetVersion); } + bool bypassUmdCache() { + if (!configuration.empty()) { + for (auto& configItem : configuration) { + if (configItem.first == "CACHE_DIR") { + const auto set_cache_dir = configItem.second; + if (!set_cache_dir.empty()) { + return true; + } + } + if (configItem.first == "NPU_BYPASS_UMD_CACHING") { + if (configItem.second.as()) { + return true; + } + } + } + } + + return false; + } + std::shared_ptr zeroInitStruct; std::shared_ptr zeGraphExt; ov::AnyMap configuration; - std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>(); - ::intel_npu::Config npu_config = ::intel_npu::Config(options); - SerializedIR serializedIR; GraphDescriptor graphDescriptor; @@ -130,7 +136,7 @@ using ZeroGraphCompilationTests = ZeroGraphTest; TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -141,7 +147,7 @@ TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) { TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -183,7 +189,7 @@ TEST_P(ZeroGraphTest, GetGraphInitBlob) { TEST_P(ZeroGraphTest, GetNetworkMeta) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); OV_ASSERT_NO_THROW(NetworkMetadata meta = zeGraphExt->getNetworkMeta(graphDescriptor)); } @@ -223,7 +229,7 @@ TEST_P(ZeroGraphTest, GetGraphBinary) { TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) { serializeIR(); - OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); uint32_t initCommandQueueOrdinal = 0; OV_ASSERT_NO_THROW(initCommandQueueOrdinal = @@ -310,7 +316,8 @@ TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(localGraphDescriptor = + localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; @@ -345,7 +352,8 @@ TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(localGraphDescriptor = + localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; @@ -380,7 +388,8 @@ TEST_P(ZeroGraphTest, SetAlignedBlob) { auto localZeGraphExt = std::make_shared(zeroInitStruct); GraphDescriptor localGraphDescriptor; serializeIR(); - OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config)); + OV_ASSERT_NO_THROW(localGraphDescriptor = + localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache())); const uint8_t* blobPtr = nullptr; std::vector blobVec; // plugin needs to keep a copy of the blob for older drivers size_t blobSize; From aa1895526019434657ccaa8f1b4edf7b7095a292 Mon Sep 17 00:00:00 2001 From: Bogdan Pereanu Date: Mon, 27 Oct 2025 11:19:25 +0200 Subject: [PATCH 6/6] Update code after review Signed-off-by: Bogdan Pereanu --- .../src/compiler_adapter/src/driver_compiler_adapter.cpp | 6 ++---- .../src/compiler_adapter/src/ze_graph_ext_wrappers.cpp | 7 ++++--- .../functional/internal/compiler_adapter/zero_graph.cpp | 2 -- .../functional/internal/compiler_adapter/zero_graph.hpp | 5 +++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp index ed1a83261c3c6e..4fba7d414dae90 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp @@ -103,8 +103,7 @@ std::shared_ptr DriverCompilerAdapter::compile(const std::shared_ptr(); - bool bypassCache = !setCacheDir.empty() || config.get(); + const bool bypassCache = !config.get().empty() || config.get(); auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, bypassCache); _logger.debug("compile end"); @@ -181,8 +180,7 @@ std::shared_ptr DriverCompilerAdapter::compileWS(const std::shared_ptr(); - bool bypassCache = !setCacheDir.empty() || config.get(); + const bool bypassCache = !config.get().empty() || config.get(); auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR, buildFlags, bypassCache); _logger.debug("compile end"); diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index 086b92bae065a4..b7ec5af25f2ead 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp @@ -340,7 +340,8 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR uint32_t flags = ZE_GRAPH_FLAG_NONE; if (bypassUmdCache) { - flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING; + _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_DISABLE_CACHING"); + flags |= ZE_GRAPH_FLAG_DISABLE_CACHING; } ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, @@ -368,11 +369,11 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t bl OPENVINO_THROW("Empty blob"); } - uint32_t flags = 0; + uint32_t flags = ZE_GRAPH_FLAG_NONE; bool setPersistentFlag = canCpuVaBeImported(blobData, blobSize); if (setPersistentFlag) { _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"); - flags = ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; + flags |= ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT; } ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp index 266a6d013335c3..e48a5ca12439ab 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp @@ -4,8 +4,6 @@ #include "zero_graph.hpp" -#include "openvino/runtime/intel_npu/properties.hpp" - namespace { const std::vector configsGraphCompilationTests = {{}, {ov::cache_dir("test")}, diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp index 68502ab801defb..1b17bfffb47418 100644 --- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp +++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp @@ -16,6 +16,7 @@ #include "intel_npu/utils/zero/zero_mem.hpp" #include "intel_npu/utils/zero/zero_utils.hpp" #include "ir_serializer.hpp" +#include "openvino/runtime/intel_npu/properties.hpp" #include "ze_graph_ext_wrappers.hpp" #include "zero_init_mock.hpp" @@ -100,13 +101,13 @@ class ZeroGraphTest : public ::testing::TestWithParam()) { return true; }