OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Adding support for ZE_GRAPH_PROPERTIES_FLAG_NO_STANDARD_ALLOCATION (#32404)
Bogdan Pereanu8dadfa6742cf
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.hppindex 7f845314783..e88ebe5634a 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@@ -57,6 +57,8 @@ public:void initializeGraph(const GraphDescriptor& graphDescriptor, uint32_t commandQueueGroupOrdinal) const;+ bool isBlobDataImported(const GraphDescriptor& graphDescriptor) const;+private:void getMetadata(ze_graph_handle_t graphHandle,uint32_t index,@@ -65,7 +67,7 @@ private:void initializeGraphThroughCommandList(ze_graph_handle_t graphHandle, uint32_t commandQueueGroupOrdinal) const;- bool canCpuVaBeImported(void* data, size_t size, const uint32_t flags = 0) const;+ bool canCpuVaBeImported(void* data, size_t size) const;std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;uint32_t _graphExtVersion;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cppindex b24ee977dd4..9494f484bb7 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp@@ -245,8 +245,9 @@ void Graph::initialize(const Config& config) {}bool Graph::release_blob(const Config& config) {- if (_graphDesc._memoryPersistent || _blobIsPersistent || _blob == std::nullopt ||- _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8) || config.get<PERF_COUNT>()) {+ if ((_zeGraphExt != nullptr && _zeGraphExt->isBlobDataImported(_graphDesc)) || _blobIsPersistent ||+ _blob == std::nullopt || _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8) ||+ config.get<PERF_COUNT>()) {return false;}diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cppindex 1d01272d364..5ac38177f70 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp@@ -600,8 +600,8 @@ void WeightlessGraph::set_weights_inputs() {}void WeightlessGraph::release_init_blob(const size_t initIndex) {- if (_initsGraphDesc.at(initIndex)._memoryPersistent || _blobIsPersistent || _initBlobs == std::nullopt ||- _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8)) {+ if ((_zeGraphExt != nullptr && _zeGraphExt->isBlobDataImported(_graphDesc)) || _blobIsPersistent ||+ _initBlobs == std::nullopt || _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8)) {return;}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.cppindex 5e70878b1ed..f27c4187b81 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@@ -24,6 +24,99 @@#define UseCopyForNativeBinary(T) (T < ZE_GRAPH_EXT_VERSION_1_7)+namespace {+using namespace intel_npu;+/**+ * @brief Extracts the I/O metadata from Level Zero specific structures and converts them into OpenVINO specific+ * ones.+ *+ * @param arg The main Level Zero structure from which most metadata will be extracted.+ * @param metadata The secondary Level Zero structure from which metadata will be extracted. More specifically, the+ * argument is used for populating "shapeFromIRModel". Not providing this argument will lead to an empty value for+ * the referenced attribute.+ * @returns A descriptor object containing the metadata converted in OpenVINO specific structures.+ */+static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg,+ const std::optional<ze_graph_argument_metadata_t>& metadata) {+ auto logger = Logger::global().clone("getIODescriptor");+ ov::element::Type_t precision = zeroUtils::toOVElementType(arg.devicePrecision);+ ov::Shape shapeFromCompiler;+ ov::PartialShape shapeFromIRModel;+ std::unordered_set<std::string> outputTensorNames;++ for (uint32_t id = 0; id < arg.associated_tensor_names_count; id++) {+ outputTensorNames.insert(arg.associated_tensor_names[id]);+ }+ for (uint32_t id = 0; id < arg.dims_count; id++) {+ shapeFromCompiler.push_back(arg.dims[id]);+ }+ if (metadata.has_value()) {+ const auto dynamicDim = std::numeric_limits<uint64_t>::max();+ shapeFromIRModel.reserve(metadata->shape_size);+ for (uint32_t id = 0; id < metadata->shape_size; id++) {+ if (metadata->shape[id] != dynamicDim) {+ shapeFromIRModel.push_back(metadata->shape[id]);+ } else {+ // lower bound is ignored, so we set it to 1 just to satisfy the Dimension constructor,+ // upper bound is set to the value from shapeFromCompiler as it is filled with upper bounds+ // in case of dynamic dimensions+ if (id == utils::BATCH_AXIS && shapeFromCompiler[id] == utils::DEFAULT_BATCH_SIZE) {+ logger.info("Ignore dynamic batch size upper limit, but keep the dimension dynamic as a metadata "+ "from compiler has been lost.");+ // We need to keep batch dimension dynamic+ shapeFromIRModel.push_back(ov::Dimension(1, dynamicDim));+ } else {+ shapeFromIRModel.push_back(ov::Dimension(1, shapeFromCompiler[id]));+ }+ }+ }+ }++ // Flags will be used instead of indices for informing the type of the current entry+ std::string nameFromCompiler = arg.name;+ const bool isInput = (arg.type == ZE_GRAPH_ARGUMENT_TYPE_INPUT);+ bool isStateInput = false;+ bool isStateOutput = false;+ bool isShapeTensor = false;+ bool isInitInputWeights = false;+ bool isInitOutputWeights = false;+ bool isMainInputWeights = false;+ if (isInput && isStateInputName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(READVALUE_PREFIX.length());+ isStateInput = true;+ } else if (!isInput && isStateOutputName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(ASSIGN_PREFIX.length());+ isStateOutput = true;+ } else if (isShapeTensorName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(SHAPE_TENSOR_PREFIX.length());+ isShapeTensor = true;+ } else if (isInput && isInitInputWeightsName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(INIT_INPUT_WEIGHTS_PREFIX.length());+ isInitInputWeights = true;+ } else if (!isInput && isInitOutputWeightsName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(INIT_OUTPUT_WEIGHTS_PREFIX.length());+ isInitOutputWeights = true;+ } else if (isInput && isMainInputWeightsName(nameFromCompiler)) {+ nameFromCompiler = nameFromCompiler.substr(MAIN_INPUT_WEIGHTS_PREFIX.length());+ isMainInputWeights = true;+ }++ return {std::move(nameFromCompiler),+ precision,+ shapeFromCompiler,+ isStateInput,+ isStateOutput,+ isShapeTensor,+ isInitInputWeights,+ isInitOutputWeights,+ isMainInputWeights,+ std::nullopt,+ arg.debug_friendly_name,+ std::move(outputTensorNames),+ metadata.has_value() ? std::optional(shapeFromIRModel) : std::nullopt};+}+} // namespace+namespace intel_npu {GraphDescriptor::GraphDescriptor(ze_graph_handle_t handle, bool memoryPersistent)@@ -225,19 +318,22 @@ std::unordered_set<std::string> ZeGraphExtWrappers::queryGraph(SerializedIR serireturn parseQueryResult(supportedLayers);}-bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size, const uint32_t flags) const {+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)) {return false;}- ze_device_external_memory_properties_t externalMemorydDesc = {};- externalMemorydDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_EXTERNAL_MEMORY_PROPERTIES;+ if (_graphExtVersion == ZE_MAKE_VERSION(1, 13)) {+ // special case for ext version 1.13+ ze_device_external_memory_properties_t externalMemorydDesc = {};+ externalMemorydDesc.stype = ZE_STRUCTURE_TYPE_DEVICE_EXTERNAL_MEMORY_PROPERTIES;- auto res = zeDeviceGetExternalMemoryProperties(_zeroInitStruct->getDevice(), &externalMemorydDesc);- if ((res != ZE_RESULT_SUCCESS) ||- ((externalMemorydDesc.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_STANDARD_ALLOCATION) == 0)) {- return false;+ auto res = zeDeviceGetExternalMemoryProperties(_zeroInitStruct->getDevice(), &externalMemorydDesc);+ if ((res != ZE_RESULT_SUCCESS) || ((externalMemorydDesc.memoryAllocationImportTypes &+ ZE_EXTERNAL_MEMORY_TYPE_FLAG_STANDARD_ALLOCATION) == 0)) {+ return false;+ }}return true;@@ -275,8 +371,7 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t bl}uint32_t flags = 0;-- bool setPersistentFlag = canCpuVaBeImported(blobData, blobSize, ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED);+ bool setPersistentFlag = canCpuVaBeImported(blobData, blobSize);if (setPersistentFlag) {_logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT");@@ -302,94 +397,23 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(void* blobData, size_t blreturn GraphDescriptor{graphHandle, setPersistentFlag};}-/**- * @brief Extracts the I/O metadata from Level Zero specific structures and converts them into OpenVINO specific- * ones.- *- * @param arg The main Level Zero structure from which most metadata will be extracted.- * @param metadata The secondary Level Zero structure from which metadata will be extracted. More specifically, the- * argument is used for populating "shapeFromIRModel". Not providing this argument will lead to an empty value for- * the referenced attribute.- * @returns A descriptor object containing the metadata converted in OpenVINO specific structures.- */-static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg,- const std::optional<ze_graph_argument_metadata_t>& metadata) {- auto logger = Logger::global().clone("getIODescriptor");- ov::element::Type_t precision = zeroUtils::toOVElementType(arg.devicePrecision);- ov::Shape shapeFromCompiler;- ov::PartialShape shapeFromIRModel;- std::unordered_set<std::string> outputTensorNames;-- for (uint32_t id = 0; id < arg.associated_tensor_names_count; id++) {- outputTensorNames.insert(arg.associated_tensor_names[id]);- }- for (uint32_t id = 0; id < arg.dims_count; id++) {- shapeFromCompiler.push_back(arg.dims[id]);- }- if (metadata.has_value()) {- const auto dynamicDim = std::numeric_limits<uint64_t>::max();- shapeFromIRModel.reserve(metadata->shape_size);- for (uint32_t id = 0; id < metadata->shape_size; id++) {- if (metadata->shape[id] != dynamicDim) {- shapeFromIRModel.push_back(metadata->shape[id]);- } else {- // lower bound is ignored, so we set it to 1 just to satisfy the Dimension constructor,- // upper bound is set to the value from shapeFromCompiler as it is filled with upper bounds- // in case of dynamic dimensions- if (id == utils::BATCH_AXIS && shapeFromCompiler[id] == utils::DEFAULT_BATCH_SIZE) {- logger.info("Ignore dynamic batch size upper limit, but keep the dimension dynamic as a metadata "- "from compiler has been lost.");- // We need to kepp batch dimension dynamic- shapeFromIRModel.push_back(ov::Dimension(1, dynamicDim));- } else {- shapeFromIRModel.push_back(ov::Dimension(1, shapeFromCompiler[id]));- }- }- }+bool ZeGraphExtWrappers::isBlobDataImported(const GraphDescriptor& graphDescriptor) const {+ if (_graphExtVersion < ZE_MAKE_VERSION(1, 14)) {+ return graphDescriptor._memoryPersistent;}- // Flags will be used instead of indices for informing the type of the current entry- std::string nameFromCompiler = arg.name;- const bool isInput = (arg.type == ZE_GRAPH_ARGUMENT_TYPE_INPUT);- bool isStateInput = false;- bool isStateOutput = false;- bool isShapeTensor = false;- bool isInitInputWeights = false;- bool isInitOutputWeights = false;- bool isMainInputWeights = false;- if (isInput && isStateInputName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(READVALUE_PREFIX.length());- isStateInput = true;- } else if (!isInput && isStateOutputName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(ASSIGN_PREFIX.length());- isStateOutput = true;- } else if (isShapeTensorName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(SHAPE_TENSOR_PREFIX.length());- isShapeTensor = true;- } else if (isInput && isInitInputWeightsName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(INIT_INPUT_WEIGHTS_PREFIX.length());- isInitInputWeights = true;- } else if (!isInput && isInitOutputWeightsName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(INIT_OUTPUT_WEIGHTS_PREFIX.length());- isInitOutputWeights = true;- } else if (isInput && isMainInputWeightsName(nameFromCompiler)) {- nameFromCompiler = nameFromCompiler.substr(MAIN_INPUT_WEIGHTS_PREFIX.length());- isMainInputWeights = true;+ if (graphDescriptor._memoryPersistent) {+ ze_graph_properties_3_t graphProperties = {};+ graphProperties.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES;+ auto result = _zeroInitStruct->getGraphDdiTable().pfnGetProperties3(graphDescriptor._handle, &graphProperties);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties3", result, _zeroInitStruct->getGraphDdiTable());++ if (graphProperties.flags & ZE_GRAPH_PROPERTIES_FLAG_NO_STANDARD_ALLOCATION) {+ return false;+ }}- return {std::move(nameFromCompiler),- precision,- shapeFromCompiler,- isStateInput,- isStateOutput,- isShapeTensor,- isInitInputWeights,- isInitOutputWeights,- isMainInputWeights,- std::nullopt,- arg.debug_friendly_name,- std::move(outputTensorNames),- metadata.has_value() ? std::optional(shapeFromIRModel) : std::nullopt};+ return graphDescriptor._memoryPersistent;}void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle,diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hppindex 6e5bad82018..a8bf4ea3b1d 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_types.hpp@@ -188,6 +188,33 @@ public:throwWhenUnsupported("pfnCompilerIsOptionSupported", ZE_GRAPH_EXT_VERSION_1_11);return _impl->pfnCompilerIsOptionSupported(hDevice, type, pOption, pValue);}++ // version 1.12+ ze_result_t ZE_APICALL pfnCreate3(ze_context_handle_t hContext,+ ze_device_handle_t hDevice,+ const ze_graph_desc_2_t* desc,+ ze_graph_handle_t* phGraph,+ ze_graph_build_log_handle_t* phGraphBuildLog) {+ throwWhenUnsupported("pfnCreate3", ZE_GRAPH_EXT_VERSION_1_12);+ return _impl->pfnCreate3(hContext, hDevice, desc, phGraph, phGraphBuildLog);+ }++ ze_result_t ZE_APICALL pfnGetProperties3(ze_graph_handle_t hGraph, ze_graph_properties_3_t* pGraphProperties) {+ throwWhenUnsupported("pfnGetProperties3", ZE_GRAPH_EXT_VERSION_1_12);+ return _impl->pfnGetProperties3(hGraph, pGraphProperties);+ }++ ze_result_t ZE_APICALL pfnBuildLogGetString2(ze_graph_build_log_handle_t hGraphBuildLog,+ uint32_t* pSize,+ char* pBuildLog) {+ throwWhenUnsupported("pfnBuildLogGetString2", ZE_GRAPH_EXT_VERSION_1_12);+ return _impl->pfnBuildLogGetString2(hGraphBuildLog, pSize, pBuildLog);+ }++ ze_result_t ZE_APICALL pfnBuildLogDestroy(ze_graph_build_log_handle_t hGraphBuildLog) {+ throwWhenUnsupported("pfnBuildLogDestroy", ZE_GRAPH_EXT_VERSION_1_12);+ return _impl->pfnBuildLogDestroy(hGraphBuildLog);+ }};/**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.cppindex 70f75ed2f13..683ba498eb1 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@@ -7,16 +7,20 @@#include <common_test_utils/test_assertions.hpp>namespace {-std::vector<int> graphDescflags = {ZE_GRAPH_FLAG_NONE,- ZE_GRAPH_FLAG_DISABLE_CACHING,- ZE_GRAPH_FLAG_ENABLE_PROFILING,- ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT};+std::vector<int> graphDescflags = {ZE_GRAPH_FLAG_NONE, ZE_GRAPH_FLAG_DISABLE_CACHING, ZE_GRAPH_FLAG_ENABLE_PROFILING};// tested versions interval is [1.5, CURRENT + 1)auto extVersions = ::testing::Range(ZE_MAKE_VERSION(1, 5), ZE_GRAPH_EXT_VERSION_CURRENT + 1);INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,- ZeroGraphTest,+ ZeroGraphCompilationTests,::testing::Combine(::testing::ValuesIn(graphDescflags), extVersions),ZeroGraphTest::getTestCaseName);++std::vector<int> noneGraphDescflags = {ZE_GRAPH_FLAG_NONE};++INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,+ ZeroGraphTest,+ ::testing::Combine(::testing::ValuesIn(noneGraphDescflags), extVersions),+ ZeroGraphTest::getTestCaseName);} // namespacediff --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.hppindex 19c8750a15c..7a34f6612cd 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@@ -105,7 +105,20 @@ protected:}};-TEST_P(ZeroGraphTest, GetGraphInitIR) {+using ZeroGraphCompilationTests = ZeroGraphTest;++TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) {+ serializeIR();+ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));++ 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));+}++TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) {serializeIR();OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));@@ -114,6 +127,13 @@ TEST_P(ZeroGraphTest, GetGraphInitIR) {zeroUtils::findCommandQueueGroupOrdinal(zeroInitStruct->getDevice(),ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE));OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor, initCommandQueueOrdinal));++ size_t totalSize = 1 * 3 * 24 * 24 * sizeof(float);+ std::unique_ptr<ZeroMem> buffer;+ OV_ASSERT_NO_THROW(buffer =+ std::make_unique<ZeroMem>(zeroInitStruct, totalSize, ::utils::STANDARD_PAGE_SIZE, false));++ OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));}TEST_P(ZeroGraphTest, GetGraphInitBlob) {@@ -181,25 +201,6 @@ TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) {ASSERT_ANY_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, nullptr));}-TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryIR) {- serializeIR();-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));-- 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));-- size_t totalSize = 1 * 3 * 24 * 24 * sizeof(float);- std::unique_ptr<ZeroMem> buffer;- OV_ASSERT_NO_THROW(buffer =- std::make_unique<ZeroMem>(zeroInitStruct, totalSize, ::utils::STANDARD_PAGE_SIZE, false));-- OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));-}-TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob) {std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in);ASSERT_TRUE(blobStream.is_open());@@ -222,6 +223,8 @@ TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob) {OV_ASSERT_NO_THROW(buffer = std::make_unique<ZeroMem>(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false));OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));++ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));}TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob) {@@ -245,5 +248,116 @@ TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob) {OV_ASSERT_NO_THROW(buffer = std::make_unique<ZeroMem>(zeroInitStruct, size, ::utils::STANDARD_PAGE_SIZE, false));OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, static_cast<char*>(buffer->data()) + 1));++ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+}++TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) {+ // create blob -> compile model first+ void* blob = nullptr;+ void* blobAddressUnaligned = nullptr;+ size_t alignedSize;+ {+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor;+ serializeIR();+ OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize;+ OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ size_t unalignedSize = alignedSize + 16;+ blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ blobAddressUnaligned = static_cast<uint8_t*>(blob) + 16;+ std::memcpy(blobAddressUnaligned, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);+ }++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blobAddressUnaligned, alignedSize));+ 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));+ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));++ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+}++TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) {+ // create blob -> compile model first+ void* blob = nullptr;+ size_t alignedSize;+ size_t unalignedSize;+ {+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor;+ serializeIR();+ OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize;+ OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ unalignedSize = alignedSize + 16;+ blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ std::memcpy(blob, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);+ }++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, unalignedSize));++ 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));++ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));++ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+}++TEST_P(ZeroGraphTest, SetAlignedBlob) {+ // create blob -> compile model first+ void* blob = nullptr;+ size_t alignedSize;+ {+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor;+ serializeIR();+ OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", graphDescFlag));+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize;+ OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ blob = ::operator new(alignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ std::memcpy(blob, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);+ }++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ 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));+ if (zeroInitStruct->getGraphDdiTable().version() >= ZE_MAKE_VERSION(1, 13) &&+ zeroInitStruct->isExternalMemoryStandardAllocationSupported()) {+ ASSERT_TRUE(zeGraphExt->isBlobDataImported(graphDescriptor));+ } else {+ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));+ }++ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));}+} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/thirdparty/level-zero-ext b/src/plugins/intel_npu/thirdparty/level-zero-extindex f8bba8915e0..61e4aeb00af 160000--- a/src/plugins/intel_npu/thirdparty/level-zero-ext+++ b/src/plugins/intel_npu/thirdparty/level-zero-ext@@ -1 +1 @@-Subproject commit f8bba8915e0a5fe8317f7aa48007ecc5a8c179ca+Subproject commit 61e4aeb00afd2a5b6955986269eed3a713c7b562