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] Implement extension versions properly for each method (#26638)
Bogdan Pereanu77dfb1de59de
diff --git a/src/plugins/intel_npu/src/al/include/npu.hpp b/src/plugins/intel_npu/src/al/include/npu.hppindex b501c1727c4..570eedc5fa3 100644--- a/src/plugins/intel_npu/src/al/include/npu.hpp+++ b/src/plugins/intel_npu/src/al/include/npu.hpp@@ -32,7 +32,7 @@ public:/** @brief Provide driver version */virtual uint32_t getDriverVersion() const;/** @brief Provide driver extension version */- virtual uint32_t getDriverExtVersion() const;+ virtual uint32_t getGraphExtVersion() const;/** @brief Get name of backend */virtual const std::string getName() const = 0;/** @brief Backend has support for concurrency batching */diff --git a/src/plugins/intel_npu/src/al/src/npu.cpp b/src/plugins/intel_npu/src/al/src/npu.cppindex 8da55475e9b..8912a4e6e4f 100644--- a/src/plugins/intel_npu/src/al/src/npu.cpp+++ b/src/plugins/intel_npu/src/al/src/npu.cpp@@ -29,7 +29,7 @@ uint32_t IEngineBackend::getDriverVersion() const {OPENVINO_THROW("Get NPU driver version is not supported with this backend");}-uint32_t IEngineBackend::getDriverExtVersion() const {+uint32_t IEngineBackend::getGraphExtVersion() const {OPENVINO_THROW("Get NPU driver extension version is not supported with this backend");}diff --git a/src/plugins/intel_npu/src/backend/include/zero_backend.hpp b/src/plugins/intel_npu/src/backend/include/zero_backend.hppindex 71d6a20512b..7323553f6dc 100644--- a/src/plugins/intel_npu/src/backend/include/zero_backend.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_backend.hpp@@ -23,7 +23,7 @@ public:}const std::vector<std::string> getDeviceNames() const override;uint32_t getDriverVersion() const override;- uint32_t getDriverExtVersion() const override;+ uint32_t getGraphExtVersion() const override;bool isBatchingSupported() const override;bool isCommandQueueExtSupported() const override;@@ -31,8 +31,7 @@ public:void* getContext() const override;void* getDriverHandle() const;void* getDeviceHandle() const;- char* getGraphExtName();- ze_graph_dditable_ext_last_t* getGraphDDITableExt();+ ze_graph_dditable_ext_curr_t& getGraphDdiTable() const;void updateInfo(const Config& config) override;diff --git a/src/plugins/intel_npu/src/backend/include/zero_device.hpp b/src/plugins/intel_npu/src/backend/include/zero_device.hppindex 9b2234c7865..7453cfc3008 100644--- a/src/plugins/intel_npu/src/backend/include/zero_device.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_device.hpp@@ -61,7 +61,7 @@ public:private:const std::shared_ptr<ZeroInitStructsHolder> _initStructs;- ze_graph_dditable_ext_curr_t* _graph_ddi_table_ext = nullptr;+ ze_graph_dditable_ext_curr_t& _graph_ddi_table_ext;ze_device_properties_t device_properties = {};diff --git a/src/plugins/intel_npu/src/backend/include/zero_executor.hpp b/src/plugins/intel_npu/src/backend/include/zero_executor.hppindex 4cbe03bcc7a..11cc6fab4bc 100644--- a/src/plugins/intel_npu/src/backend/include/zero_executor.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_executor.hpp@@ -67,7 +67,7 @@ private:const std::shared_ptr<const ZeroInitStructsHolder> _initStructs;std::shared_ptr<const NetworkDescription> _networkDesc;- ze_graph_dditable_ext_curr_t* _graph_ddi_table_ext = nullptr;+ ze_graph_dditable_ext_curr_t& _graph_ddi_table_ext;const uint32_t _group_ordinal;diff --git a/src/plugins/intel_npu/src/backend/include/zero_init.hpp b/src/plugins/intel_npu/src/backend/include/zero_init.hppindex 4128ec6120f..7404417a17f 100644--- a/src/plugins/intel_npu/src/backend/include/zero_init.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_init.hpp@@ -37,27 +37,18 @@ public:inline ze_context_handle_t getContext() const {return context;}- inline char* getGraphExtName() const {- return graphExtName;+ inline ze_graph_dditable_ext_curr_t& getGraphDdiTable() const {+ return *graph_dditable_ext_decorator;}- inline ze_graph_dditable_ext_last_t* getGraphDDITableExt() {- return graph_ddi_table_ext;+ inline ze_command_queue_npu_dditable_ext_curr_t& getCommandQueueDdiTable() const {+ return *command_queue_npu_dditable_ext_decorator;}- inline ze_graph_dditable_ext_curr_t* getGraphDdiTable() const {- return graph_dditable_ext_decorator.get();- }- inline ze_command_queue_npu_dditable_ext_curr_t* getCommandQueueDdiTable() const {- return _command_queue_npu_dditable_ext;- }- inline ze_graph_profiling_dditable_ext_t* getProfilingDdiTable() const {- return _graph_profiling_ddi_table_ext;+ inline ze_graph_profiling_dditable_ext_curr_t& getProfilingDdiTable() const {+ return *graph_profiling_npu_dditable_ext_decorator;}inline uint32_t getDriverVersion() const {return driver_properties.driverVersion;}- inline uint32_t getDriverExtVersion() const {- return driver_ext_version;- }inline uint32_t getMutableCommandListVersion() const {return mutable_command_list_version;}@@ -69,15 +60,12 @@ private:ze_context_handle_t context = nullptr;ze_driver_handle_t driver_handle = nullptr;ze_device_handle_t device_handle = nullptr;- char* graphExtName;- ze_graph_dditable_ext_last_t* graph_ddi_table_ext = nullptr;std::unique_ptr<ze_graph_dditable_ext_decorator> graph_dditable_ext_decorator;- ze_command_queue_npu_dditable_ext_curr_t* _command_queue_npu_dditable_ext = nullptr;- ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;+ std::unique_ptr<ze_command_queue_npu_dditable_ext_decorator> command_queue_npu_dditable_ext_decorator;+ std::unique_ptr<ze_graph_profiling_ddi_table_ext_decorator> graph_profiling_npu_dditable_ext_decorator;ze_driver_properties_t driver_properties = {};- uint32_t driver_ext_version = 0;uint32_t mutable_command_list_version = 0;};diff --git a/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp b/src/plugins/intel_npu/src/backend/include/zero_profiling.hppindex f01eff26a23..53263d9491d 100644--- a/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp@@ -13,6 +13,7 @@#include "intel_npu/al/config/compiler.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/runtime/profiling_info.hpp"+#include "zero_types.hpp"namespace intel_npu {namespace zeroProfiling {@@ -24,7 +25,7 @@ constexpr uint32_t POOL_SIZE = 1;struct ProfilingPool {ProfilingPool(ze_graph_handle_t graph_handle,uint32_t profiling_count,- ze_graph_profiling_dditable_ext_t* graph_profiling_ddi_table_ext)+ ze_graph_profiling_dditable_ext_curr_t& graph_profiling_ddi_table_ext): _graph_handle(graph_handle),_profiling_count(profiling_count),_graph_profiling_ddi_table_ext(graph_profiling_ddi_table_ext) {}@@ -37,13 +38,13 @@ struct ProfilingPool {ze_graph_handle_t _graph_handle;const uint32_t _profiling_count;ze_graph_profiling_pool_handle_t _handle = nullptr;- ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;+ ze_graph_profiling_dditable_ext_curr_t& _graph_profiling_ddi_table_ext;};struct ProfilingQuery {ProfilingQuery(uint32_t index,ze_device_handle_t device_handle,- ze_graph_profiling_dditable_ext_t* graph_profiling_ddi_table_ext)+ ze_graph_profiling_dditable_ext_curr_t& graph_profiling_ddi_table_ext): _index(index),_device_handle(device_handle),_graph_profiling_ddi_table_ext(graph_profiling_ddi_table_ext) {}@@ -66,7 +67,7 @@ private:const uint32_t _index;ze_device_handle_t _device_handle;ze_graph_profiling_query_handle_t _handle = nullptr;- ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;+ ze_graph_profiling_dditable_ext_curr_t& _graph_profiling_ddi_table_ext;};extern template std::vector<uint8_t> ProfilingQuery::getData<uint8_t>() const;diff --git a/src/plugins/intel_npu/src/backend/include/zero_types.hpp b/src/plugins/intel_npu/src/backend/include/zero_types.hppindex b6f1251f1ce..b0dbef84386 100644--- a/src/plugins/intel_npu/src/backend/include/zero_types.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_types.hpp@@ -5,15 +5,26 @@#pragma once#include <ze_api.h>+#include <ze_command_queue_npu_ext.h>#include <ze_graph_ext.h>+#include <ze_graph_profiling_ext.h>++#include <string_view>#include "intel_npu/al/config/runtime.hpp"-#include "ze_command_queue_npu_ext.h"/*** @brief Last version of Table of Graph Extension functions used within plugin*/using ze_graph_dditable_ext_last_t = ze_graph_dditable_ext_1_6_t;+/**+ * @brief Last version of the Command Queue functions used within plugin+ */+using ze_command_queue_npu_dditable_ext_last_t = ze_command_queue_npu_dditable_ext_1_0_t;+/**+ * @brief Last version of the Graph Profiling functions used within plugin+ */+using ze_graph_profiling_dditable_ext_last_t = ze_graph_profiling_dditable_ext_t;/*** @brief Table of Graph Extension functions pointers and function wrappers@@ -29,11 +40,11 @@ private:ze_graph_dditable_ext_decorator(const ze_graph_dditable_ext_decorator&) = delete;ze_graph_dditable_ext_decorator(ze_graph_dditable_ext_decorator&&) = delete;- void throwWhenUnsupported(const std::string func, uint32_t since) {+ void throwWhenUnsupported(std::string_view func, uint32_t since) {if (_driverExtVersion < since) {- OPENVINO_THROW("L0 extension function ",+ OPENVINO_THROW("Driver Graph extension function ",func,- " is only available with driver version ",+ " is only available with version ",ZE_MAJOR_VERSION(since),".",ZE_MINOR_VERSION(since),@@ -44,38 +55,31 @@ private:public:ze_graph_dditable_ext_decorator(ze_graph_dditable_ext_last_t* impl, uint32_t driverExtVersion): _impl(impl),- _driverExtVersion(driverExtVersion) {- // version 1.0- pfnCreate = _impl->pfnCreate;- pfnDestroy = _impl->pfnDestroy;- pfnGetProperties = _impl->pfnGetProperties;- pfnGetArgumentProperties = _impl->pfnGetArgumentProperties;- pfnSetArgumentValue = _impl->pfnSetArgumentValue;- pfnAppendGraphInitialize = _impl->pfnAppendGraphInitialize;- pfnAppendGraphExecute = _impl->pfnAppendGraphExecute;- pfnGetNativeBinary = _impl->pfnGetNativeBinary;- pfnDeviceGetGraphProperties = _impl->pfnDeviceGetGraphProperties;-- // version 1.1- pfnGraphGetArgumentMetadata = _impl->pfnGraphGetArgumentMetadata;- pfnGetArgumentProperties2 = _impl->pfnGetArgumentProperties2;-- // version 1.2- pfnGetArgumentProperties3 = _impl->pfnGetArgumentProperties3;-+ _driverExtVersion(driverExtVersion),+ // version 1.0+ pfnCreate(_impl->pfnCreate),+ pfnDestroy(_impl->pfnDestroy),+ pfnGetProperties(_impl->pfnGetProperties),+ pfnGetArgumentProperties(_impl->pfnGetArgumentProperties),+ pfnSetArgumentValue(_impl->pfnSetArgumentValue),+ pfnAppendGraphInitialize(_impl->pfnAppendGraphInitialize),+ pfnAppendGraphExecute(_impl->pfnAppendGraphExecute),+ pfnGetNativeBinary(_impl->pfnGetNativeBinary),+ pfnDeviceGetGraphProperties(_impl->pfnDeviceGetGraphProperties),+ // version 1.1+ pfnGraphGetArgumentMetadata(_impl->pfnGraphGetArgumentMetadata),+ pfnGetArgumentProperties2(_impl->pfnGetArgumentProperties2),+ // version 1.2+ pfnGetArgumentProperties3(_impl->pfnGetArgumentProperties3) {// version 1.3- pfnQueryNetworkCreate = _impl->pfnQueryNetworkCreate;- pfnQueryNetworkDestroy = _impl->pfnQueryNetworkDestroy;- pfnQueryNetworkGetSupportedLayers = _impl->pfnQueryNetworkGetSupportedLayers;-- // version 1.4- pfnBuildLogGetString = _impl->pfnBuildLogGetString;-- // version 1.5// wrappers replace pointers}~ze_graph_dditable_ext_decorator() = default;+ inline const uint32_t version() const {+ return _driverExtVersion;+ }+// version 1.0ze_pfnGraphCreate_ext_t pfnCreate;ze_pfnGraphDestroy_ext_t pfnDestroy;@@ -95,12 +99,31 @@ public:ze_pfnGraphGetArgumentProperties_ext_3_t pfnGetArgumentProperties3;// version 1.3- ze_pfnGraphQueryNetworkCreate_ext_t pfnQueryNetworkCreate;- ze_pfnGraphQueryNetworkDestroy_ext_t pfnQueryNetworkDestroy;- ze_pfnGraphQueryNetworkGetSupportedLayers_ext_t pfnQueryNetworkGetSupportedLayers;+ ze_result_t ZE_APICALL pfnQueryNetworkCreate(ze_context_handle_t hContext,+ ze_device_handle_t hDevice,+ const ze_graph_desc_t* desc,+ ze_graph_query_network_handle_t* phGraphQueryNetwork) {+ throwWhenUnsupported("pfnQueryNetworkCreate", ZE_GRAPH_EXT_VERSION_1_3);+ return _impl->pfnQueryNetworkCreate(hContext, hDevice, desc, phGraphQueryNetwork);+ }++ ze_result_t ZE_APICALL pfnQueryNetworkDestroy(ze_graph_query_network_handle_t hGraphQueryNetworkk) {+ throwWhenUnsupported("pfnQueryNetworkDestroy", ZE_GRAPH_EXT_VERSION_1_3);+ return _impl->pfnQueryNetworkDestroy(hGraphQueryNetworkk);+ }++ ze_result_t ZE_APICALL pfnQueryNetworkGetSupportedLayers(ze_graph_query_network_handle_t hGraphQueryNetwork,+ size_t* pSize,+ char* pSupportedLayers) {+ throwWhenUnsupported("pfnQueryNetworkGetSupportedLayers", ZE_GRAPH_EXT_VERSION_1_3);+ return _impl->pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, pSize, pSupportedLayers);+ }// version 1.4- ze_pfnGraphBuildLogGetString_ext_t pfnBuildLogGetString;+ ze_result_t ZE_APICALL pfnBuildLogGetString(ze_graph_handle_t hGraph, uint32_t* pSize, char* pBuildLog) {+ throwWhenUnsupported("pfnBuildLogGetString", ZE_GRAPH_EXT_VERSION_1_4);+ return _impl->pfnBuildLogGetString(hGraph, pSize, pBuildLog);+ }// version 1.5ze_result_t ZE_APICALL pfnCreate2(ze_context_handle_t hContext,@@ -134,5 +157,84 @@ public:}};+/**+ * @brief Command Queue function wrappers+ * @details Use function wrappers for function from within higher driver versions in order to throw when loaded driver+ * is older than required+ */+struct ze_command_queue_npu_dditable_ext_decorator final {+private:+ ze_command_queue_npu_dditable_ext_last_t* const _impl;+ const uint32_t _commandQueueExtVersion;++ ze_command_queue_npu_dditable_ext_decorator(const ze_command_queue_npu_dditable_ext_decorator&) = delete;+ ze_command_queue_npu_dditable_ext_decorator(ze_command_queue_npu_dditable_ext_decorator&&) = delete;++ void throwWhenUnsupported(std::string_view func, uint32_t since) {+ if (_commandQueueExtVersion < since) {+ OPENVINO_THROW("Driver Command Queue extension function ",+ func,+ " is only available with version ",+ ZE_MAJOR_VERSION(since),+ ".",+ ZE_MINOR_VERSION(since),+ " or later");+ }+ }++public:+ ze_command_queue_npu_dditable_ext_decorator(ze_command_queue_npu_dditable_ext_last_t* impl,+ uint32_t commandQueueExtVersion)+ : _impl(impl),+ _commandQueueExtVersion(commandQueueExtVersion) {}+ ~ze_command_queue_npu_dditable_ext_decorator() = default;++ inline const uint32_t version() const {+ return _commandQueueExtVersion;+ }++ // version 1.0+ ze_result_t ZE_APICALL pfnSetWorkloadType(ze_command_queue_handle_t hCommandQueue,+ ze_command_queue_workload_type_t workloadType) {+ throwWhenUnsupported("pfnSetWorkloadType", ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_0);+ return _impl->pfnSetWorkloadType(hCommandQueue, workloadType);+ }+};++/**+ * @brief Graph profiling function pointers+ * @details Use original Graph profiling functions pointers from driver for function from within lower driver versions.+ */+struct ze_graph_profiling_ddi_table_ext_decorator final {+private:+ ze_graph_profiling_dditable_ext_last_t* const _impl;++ ze_graph_profiling_ddi_table_ext_decorator(const ze_graph_profiling_ddi_table_ext_decorator&) = delete;+ ze_graph_profiling_ddi_table_ext_decorator(ze_graph_profiling_ddi_table_ext_decorator&&) = delete;++public:+ ze_graph_profiling_ddi_table_ext_decorator(ze_graph_profiling_dditable_ext_last_t* impl)+ : _impl(impl),+ // version 1.0+ pfnProfilingPoolCreate(_impl->pfnProfilingPoolCreate),+ pfnProfilingPoolDestroy(_impl->pfnProfilingPoolDestroy),+ pfnProfilingQueryCreate(_impl->pfnProfilingQueryCreate),+ pfnProfilingQueryDestroy(_impl->pfnProfilingQueryDestroy),+ pfnProfilingQueryGetData(_impl->pfnProfilingQueryGetData),+ pfnDeviceGetProfilingDataProperties(_impl->pfnDeviceGetProfilingDataProperties),+ pfnProfilingLogGetString(_impl->pfnProfilingLogGetString) {}+ ~ze_graph_profiling_ddi_table_ext_decorator() = default;++ // version 1.0+ ze_pfnGraphProfilingPoolCreate_ext_t pfnProfilingPoolCreate;+ ze_pfnGraphProfilingPoolDestroy_ext_t pfnProfilingPoolDestroy;+ ze_pfnGraphProfilingQueryCreate_ext_t pfnProfilingQueryCreate;+ ze_pfnGraphProfilingQueryDestroy_ext_t pfnProfilingQueryDestroy;+ ze_pfnGraphProfilingQueryGetData_ext_t pfnProfilingQueryGetData;+ ze_pfnDeviceGetProfilingDataProperties_ext_t pfnDeviceGetProfilingDataProperties;+ ze_pfnGraphProfilingLogGetString_ext_t pfnProfilingLogGetString;+};+using ze_graph_dditable_ext_curr_t = ze_graph_dditable_ext_decorator;-using ze_command_queue_npu_dditable_ext_curr_t = ze_command_queue_npu_dditable_ext_1_0_t;+using ze_command_queue_npu_dditable_ext_curr_t = ze_command_queue_npu_dditable_ext_decorator;+using ze_graph_profiling_dditable_ext_curr_t = ze_graph_profiling_ddi_table_ext_decorator;diff --git a/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp b/src/plugins/intel_npu/src/backend/include/zero_wrappers.hppindex 76cfce8fecf..12a745e42e3 100644--- a/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp@@ -73,7 +73,7 @@ public:CommandList() = delete;CommandList(const ze_device_handle_t& device_handle,const ze_context_handle_t& context,- ze_graph_dditable_ext_curr_t* graph_ddi_table_ext,+ ze_graph_dditable_ext_curr_t& graph_ddi_table_ext,const Config& config,const uint32_t& group_ordinal,bool mtci_is_supported = false);@@ -100,7 +100,7 @@ public:private:ze_command_list_handle_t _handle = nullptr;const ze_context_handle_t _context = nullptr;- ze_graph_dditable_ext_curr_t* _graph_ddi_table_ext = nullptr;+ ze_graph_dditable_ext_curr_t& _graph_ddi_table_ext;uint64_t _command_id = 0;Logger _log;@@ -134,7 +134,7 @@ public:CommandQueue(const ze_device_handle_t& device_handle,const ze_context_handle_t& context,const ze_command_queue_priority_t& priority,- ze_command_queue_npu_dditable_ext_curr_t* command_queue_npu_dditable_ext,+ ze_command_queue_npu_dditable_ext_curr_t& command_queue_npu_dditable_ext,const Config& config,const uint32_t& group_ordinal);CommandQueue(const CommandQueue&) = delete;@@ -153,7 +153,7 @@ public:private:ze_command_queue_handle_t _handle = nullptr;ze_context_handle_t _context = nullptr;- ze_command_queue_npu_dditable_ext_curr_t* _command_queue_npu_dditable_ext = nullptr;+ ze_command_queue_npu_dditable_ext_curr_t& _command_queue_npu_dditable_ext;Logger _log;};diff --git a/src/plugins/intel_npu/src/backend/src/zero_backend.cpp b/src/plugins/intel_npu/src/backend/src/zero_backend.cppindex 10cd8249a97..ccb232b16c7 100644--- a/src/plugins/intel_npu/src/backend/src/zero_backend.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_backend.cpp@@ -25,16 +25,16 @@ uint32_t ZeroEngineBackend::getDriverVersion() const {return _instance->getDriverVersion();}-uint32_t ZeroEngineBackend::getDriverExtVersion() const {- return _instance->getDriverExtVersion();+uint32_t ZeroEngineBackend::getGraphExtVersion() const {+ return _instance->getGraphDdiTable().version();}bool ZeroEngineBackend::isBatchingSupported() const {- return _instance->getDriverExtVersion() >= ZE_GRAPH_EXT_VERSION_1_6;+ return _instance->getGraphDdiTable().version() >= ZE_GRAPH_EXT_VERSION_1_6;}bool ZeroEngineBackend::isCommandQueueExtSupported() const {- return _instance->getCommandQueueDdiTable() != nullptr;+ return _instance->getCommandQueueDdiTable().version() >= ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_0;}ZeroEngineBackend::~ZeroEngineBackend() = default;@@ -76,12 +76,8 @@ void* ZeroEngineBackend::getDeviceHandle() const {return _instance->getDevice();}-char* ZeroEngineBackend::getGraphExtName() {- return _instance->getGraphExtName();-}--ze_graph_dditable_ext_last_t* ZeroEngineBackend::getGraphDDITableExt() {- return _instance->getGraphDDITableExt();+ze_graph_dditable_ext_curr_t& ZeroEngineBackend::getGraphDdiTable() const {+ return _instance->getGraphDdiTable();}void ZeroEngineBackend::updateInfo(const Config& config) {diff --git a/src/plugins/intel_npu/src/backend/src/zero_device.cpp b/src/plugins/intel_npu/src/backend/src/zero_device.cppindex 316fd4ab192..2df37a59ae1 100644--- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp@@ -4,8 +4,6 @@#include "zero_device.hpp"-#include <ze_api.h>-#include "intel_npu/al/itt.hpp"#include "intel_npu/utils/zero/zero_api.hpp"#include "zero_executor.hpp"@@ -142,7 +140,7 @@ uint64_t ZeroDevice::getAllocMemSize() const {ze_graph_memory_query_t query{};zeroUtils::throwOnFail("pfnQueryContextMemory",- _graph_ddi_table_ext->pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query));+ _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query));return query.allocated;}@@ -150,7 +148,7 @@ uint64_t ZeroDevice::getTotalMemSize() const {ze_graph_memory_query_t query{};zeroUtils::throwOnFail("pfnQueryContextMemory",- _graph_ddi_table_ext->pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query));+ _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query));return query.total;}diff --git a/src/plugins/intel_npu/src/backend/src/zero_executor.cpp b/src/plugins/intel_npu/src/backend/src/zero_executor.cppindex 4abaa361960..ade476c5649 100644--- a/src/plugins/intel_npu/src/backend/src/zero_executor.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_executor.cpp@@ -41,7 +41,7 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& iOV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "Executor::ZeroExecutor");CommandList graph_command_list(_initStructs->getDevice(),_initStructs->getContext(),- _initStructs->getGraphDdiTable(),+ _graph_ddi_table_ext,_config,_group_ordinal);_logger.debug("ZeroExecutor::ZeroExecutor - create graph_command_queue");@@ -70,7 +70,7 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& izeroUtils::throwOnFail("pfnCreate",- _graph_ddi_table_ext->pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph));+ _graph_ddi_table_ext.pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph));} else {_logger.debug("reuse graph handle created from compiler");@@ -79,8 +79,8 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& iOV_ITT_TASK_NEXT(ZERO_EXECUTOR_GRAPH, "pfnGetProperties");_logger.debug("performing pfnGetProperties");- zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext->pfnGetProperties(_graph, &_props));- auto targetDriverExtVersion = _initStructs->getDriverExtVersion();+ zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext.pfnGetProperties(_graph, &_props));+ auto targetDriverExtVersion = _graph_ddi_table_ext.version();if (targetDriverExtVersion <= ZE_GRAPH_EXT_VERSION_1_1) {OPENVINO_THROW("Incompatibility between the NPU plugin and driver! The driver version is too old, please ""update the driver version");@@ -91,7 +91,7 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& ifor (uint32_t index = 0; index < _props.numGraphArgs; ++index) {ze_graph_argument_properties_3_t arg3;zeroUtils::throwOnFail("pfnGetArgumentProperties3",- _graph_ddi_table_ext->pfnGetArgumentProperties3(_graph, index, &arg3));+ _graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3));if (arg3.type == ZE_GRAPH_ARGUMENT_TYPE_INPUT) {_input_descriptors.push_back(ArgumentDescriptor{arg3, index});@@ -135,7 +135,7 @@ void ZeroExecutor::setWorkloadType(const ov::WorkloadType workloadType) const {}void ZeroExecutor::setArgumentValue(uint32_t argi_, const void* argv_) const {- zeroUtils::throwOnFail("zeGraphSetArgumentValue", _graph_ddi_table_ext->pfnSetArgumentValue(_graph, argi_, argv_));+ zeroUtils::throwOnFail("zeGraphSetArgumentValue", _graph_ddi_table_ext.pfnSetArgumentValue(_graph, argi_, argv_));}void ZeroExecutor::mutexLock() const {@@ -148,8 +148,8 @@ void ZeroExecutor::mutexUnlock() const {ZeroExecutor::~ZeroExecutor() {_logger.debug("~ZeroExecutor() - pfnDestroy _graph ");- auto result = _graph_ddi_table_ext->pfnDestroy(_graph);+ auto result = _graph_ddi_table_ext.pfnDestroy(_graph);if (ZE_RESULT_SUCCESS != result) {- _logger.error("_graph_ddi_table_ext->pfnDestroy failed %#X", uint64_t(result));+ _logger.error("_graph_ddi_table_ext.pfnDestroy failed %#X", uint64_t(result));}}diff --git a/src/plugins/intel_npu/src/backend/src/zero_init.cpp b/src/plugins/intel_npu/src/backend/src/zero_init.cppindex d992f67b5eb..39d0613ec64 100644--- a/src/plugins/intel_npu/src/backend/src/zero_init.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_init.cpp@@ -21,72 +21,34 @@ namespace intel_npu {const ze_driver_uuid_t ZeroInitStructsHolder::uuid = ze_intel_npu_driver_uuid;static std::tuple<uint32_t, std::string> queryDriverExtensionVersion(+ const char* extName,+ uint32_t extCurrentVersion,std::vector<ze_driver_extension_properties_t>& extProps,uint32_t count) {- // query the extension properties- const char* graphExtName = nullptr;- uint32_t targetVersion = 0;- for (uint32_t i = 0; i < count; ++i) {- auto& property = extProps[i];-- if (strncmp(property.name, ZE_GRAPH_EXT_NAME, strlen(ZE_GRAPH_EXT_NAME)) != 0) {- continue;- }-- // If the driver version is latest, will just use its name.- if (property.version == ZE_GRAPH_EXT_VERSION_CURRENT) {- graphExtName = property.name;- targetVersion = property.version;- break;- }-- // Use the latest version supported by the driver.- if (property.version > targetVersion) {- graphExtName = property.name;- targetVersion = property.version;- }- }-- if (graphExtName == nullptr) {- OPENVINO_THROW("queryDriverExtensionVersion: Failed to find Graph extension in NPU Driver");- }-- const uint16_t supportedDriverExtMajorVersion = 1;- const uint16_t driverExtMajorVersion = ZE_MAJOR_VERSION(targetVersion);- if (supportedDriverExtMajorVersion != driverExtMajorVersion) {- OPENVINO_THROW("Plugin supports only driver with extension major version ",- supportedDriverExtMajorVersion,- "; discovered driver extension has major version ",- driverExtMajorVersion);- }-- return std::make_tuple(targetVersion, graphExtName);-}--static uint32_t queryMutableCommandListVersion(std::vector<ze_driver_extension_properties_t>& extProps,- uint32_t count) {- // query the mutable command list properties+ const char* functionExtName = nullptr;uint32_t targetVersion = 0;for (uint32_t i = 0; i < count; ++i) {auto& property = extProps[i];- if (strncmp(property.name, ZE_MUTABLE_COMMAND_LIST_EXP_NAME, strlen(ZE_MUTABLE_COMMAND_LIST_EXP_NAME)) != 0) {+ if (strncmp(property.name, extName, strlen(extName)) != 0) {continue;}- if (property.version == ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_CURRENT) {+ if (property.version == extCurrentVersion) {+ functionExtName = property.name;targetVersion = property.version;break;}// Use the latest version supported by the driver.if (property.version > targetVersion) {+ functionExtName = property.name;targetVersion = property.version;}}- return targetVersion;+ return std::make_tuple(targetVersion, functionExtName ? functionExtName : "");}ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", Logger::global().level()) {@@ -145,42 +107,78 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",// Query our graph extension versionstd::string graph_ext_name;- log.debug("ZeroInitStructsHolder - tie output of queryDriverExtensionVersion");- std::tie(driver_ext_version, graph_ext_name) = queryDriverExtensionVersion(extProps, count);+ uint32_t graph_ext_version = 0;++ std::tie(graph_ext_version, graph_ext_name) =+ queryDriverExtensionVersion(ZE_GRAPH_EXT_NAME, ZE_GRAPH_EXT_VERSION_CURRENT, extProps, count);++ if (graph_ext_name.empty()) {+ OPENVINO_THROW("queryGraphExtensionVersion: Failed to find Graph extension in NPU Driver");+ }++ const uint16_t supported_driver_ext_major_version = 1;+ const uint16_t driver_ext_major_version = ZE_MAJOR_VERSION(graph_ext_version);+ if (supported_driver_ext_major_version != driver_ext_major_version) {+ OPENVINO_THROW("Plugin supports only driver with extension major version ",+ supported_driver_ext_major_version,+ "; discovered driver extension has major version ",+ driver_ext_major_version);+ }- log.info("Found Driver Version %d.%d, Driver Extension Version %d.%d (%s)",+ log.info("Found Driver Version %d.%d, Graph Extension Version %d.%d (%s)",ZE_MAJOR_VERSION(ze_drv_api_version),ZE_MINOR_VERSION(ze_drv_api_version),- ZE_MAJOR_VERSION(driver_ext_version),- ZE_MINOR_VERSION(driver_ext_version),+ ZE_MAJOR_VERSION(graph_ext_version),+ ZE_MINOR_VERSION(graph_ext_version),graph_ext_name.c_str());+ // Query our command queue extension version+ std::string command_queue_ext_name;+ uint32_t command_queue_ext_version = 0;+ std::tie(command_queue_ext_version, command_queue_ext_name) =+ queryDriverExtensionVersion(ZE_COMMAND_QUEUE_NPU_EXT_NAME,+ ZE_COMMAND_QUEUE_NPU_EXT_VERSION_CURRENT,+ extProps,+ count);++ log.debug("NPU command queue version %d.%d",+ ZE_MAJOR_VERSION(command_queue_ext_version),+ ZE_MINOR_VERSION(command_queue_ext_version));+// Load our command queue extension- try {+ ze_command_queue_npu_dditable_ext_last_t* _command_queue_npu_dditable_ext = nullptr;+ if (command_queue_ext_version) {zeroUtils::throwOnFail(- "zeDriverGetExtensionFunctionAddress " + std::string(ZE_COMMAND_QUEUE_NPU_EXT_NAME),+ "zeDriverGetExtensionFunctionAddress " + command_queue_ext_name,zeDriverGetExtensionFunctionAddress(driver_handle,- ZE_COMMAND_QUEUE_NPU_EXT_NAME,+ command_queue_ext_name.c_str(),reinterpret_cast<void**>(&_command_queue_npu_dditable_ext)));- } catch (const ov::Exception& error) {- log.debug("Current Driver Version does not have the command queue extension: %s", error.what());}+ command_queue_npu_dditable_ext_decorator =+ std::make_unique<ze_command_queue_npu_dditable_ext_decorator>(_command_queue_npu_dditable_ext,+ command_queue_ext_version);+// Load our graph extension+ ze_graph_dditable_ext_last_t* graph_ddi_table_ext = nullptr;zeroUtils::throwOnFail("zeDriverGetExtensionFunctionAddress",zeDriverGetExtensionFunctionAddress(driver_handle,graph_ext_name.c_str(),reinterpret_cast<void**>(&graph_ddi_table_ext)));graph_dditable_ext_decorator =- std::make_unique<ze_graph_dditable_ext_decorator>(graph_ddi_table_ext, driver_ext_version);+ std::make_unique<ze_graph_dditable_ext_decorator>(graph_ddi_table_ext, graph_ext_version);// Query the mutable command list version#ifdef _WIN32// The 2688 Windows driver version doesn't support as expected the MutableCommandList featureif (driver_properties.driverVersion != WIN_DRIVER_NO_MCL_SUPPORT) {#endif- log.debug("ZeroInitStructsHolder - tie output of queryMutableCommandListVersion");- mutable_command_list_version = queryMutableCommandListVersion(extProps, count);+ [[maybe_unused]] std::string mutuable_command_list_ext_name;+ std::tie(mutable_command_list_version, mutuable_command_list_ext_name) =+ queryDriverExtensionVersion(ZE_MUTABLE_COMMAND_LIST_EXP_NAME,+ ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_CURRENT,+ extProps,+ count);#ifdef _WIN32}#endif@@ -190,12 +188,16 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",ZE_MINOR_VERSION(mutable_command_list_version));// Load our profiling extension+ ze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;zeroUtils::throwOnFail("zeDriverGetExtensionFunctionAddress",zeDriverGetExtensionFunctionAddress(driver_handle,"ZE_extension_profiling_data",reinterpret_cast<void**>(&_graph_profiling_ddi_table_ext)));+ graph_profiling_npu_dditable_ext_decorator =+ std::make_unique<ze_graph_profiling_ddi_table_ext_decorator>(_graph_profiling_ddi_table_ext);+uint32_t device_count = 1;// Get our target devicezeroUtils::throwOnFail("zeDeviceGet", zeDeviceGet(driver_handle, &device_count, &device_handle));diff --git a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp b/src/plugins/intel_npu/src/backend/src/zero_profiling.cppindex 19636066456..a99c9315b74 100644--- a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp@@ -4,7 +4,6 @@#include "zero_profiling.hpp"-#include <ze_api.h>#include <ze_graph_profiling_ext.h>#include "intel_npu/al/config/compiler.hpp"@@ -36,19 +35,19 @@ struct ZeProfilingTypeId<uint8_t> {};bool ProfilingPool::create() {- auto ret = _graph_profiling_ddi_table_ext->pfnProfilingPoolCreate(_graph_handle, _profiling_count, &_handle);+ auto ret = _graph_profiling_ddi_table_ext.pfnProfilingPoolCreate(_graph_handle, _profiling_count, &_handle);return ((ZE_RESULT_SUCCESS == ret) && (_handle != nullptr));}ProfilingPool::~ProfilingPool() {if (_handle) {- _graph_profiling_ddi_table_ext->pfnProfilingPoolDestroy(_handle);+ _graph_profiling_ddi_table_ext.pfnProfilingPoolDestroy(_handle);}}void ProfilingQuery::create(const ze_graph_profiling_pool_handle_t& profiling_pool) {zeroUtils::throwOnFail("pfnProfilingQueryCreate",- _graph_profiling_ddi_table_ext->pfnProfilingQueryCreate(profiling_pool, _index, &_handle));+ _graph_profiling_ddi_table_ext.pfnProfilingQueryCreate(profiling_pool, _index, &_handle));}LayerStatistics ProfilingQuery::getLayerStatistics() const {@@ -59,7 +58,7 @@ LayerStatistics ProfilingQuery::getLayerStatistics() const {ProfilingQuery::~ProfilingQuery() {if (_handle) {- _graph_profiling_ddi_table_ext->pfnProfilingQueryDestroy(_handle);+ _graph_profiling_ddi_table_ext.pfnProfilingQueryDestroy(_handle);}}@@ -69,7 +68,7 @@ void ProfilingQuery::queryGetData(const ze_graph_profiling_type_t profilingType,if (_handle && pSize) {zeroUtils::throwOnFail("pfnProfilingQueryGetData",- _graph_profiling_ddi_table_ext->pfnProfilingQueryGetData(_handle, profilingType, pSize, pData));+ _graph_profiling_ddi_table_ext.pfnProfilingQueryGetData(_handle, profilingType, pSize, pData));}}@@ -95,7 +94,7 @@ void ProfilingQuery::getProfilingProperties(ze_device_profiling_data_properties_if (_handle && properties) {zeroUtils::throwOnFail("getProfilingProperties",- _graph_profiling_ddi_table_ext->pfnDeviceGetProfilingDataProperties(_device_handle, properties));+ _graph_profiling_ddi_table_ext.pfnDeviceGetProfilingDataProperties(_device_handle, properties));}}diff --git a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cppindex 7ee49a72e38..8478eccb774 100644--- a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp@@ -61,7 +61,7 @@ Event::~Event() {CommandList::CommandList(const ze_device_handle_t& device_handle,const ze_context_handle_t& context,- ze_graph_dditable_ext_curr_t* graph_ddi_table_ext,+ ze_graph_dditable_ext_curr_t& graph_ddi_table_ext,const Config& config,const uint32_t& group_ordinal,bool mtci_is_supported)@@ -89,14 +89,13 @@ void CommandList::appendMemoryCopy(void* dst, const void* src, const std::size_t}void CommandList::appendGraphInitialize(const ze_graph_handle_t& graph_handle) const {zeroUtils::throwOnFail("pfnAppendGraphInitialize",- _graph_ddi_table_ext->pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr));+ _graph_ddi_table_ext.pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr));}void CommandList::appendGraphExecute(const ze_graph_handle_t& graph_handle,const ze_graph_profiling_query_handle_t& profiling_query_handle) const {zeroUtils::throwOnFail("pfnAppendGraphExecute",- _graph_ddi_table_ext- ->pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr));+ _graph_ddi_table_ext.pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr));}void CommandList::appendNpuTimestamp(uint64_t* timestamp_buff) const {zeroUtils::throwOnFail("zeCommandListAppendWriteGlobalTimestamp",@@ -132,7 +131,7 @@ void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_vCommandQueue::CommandQueue(const ze_device_handle_t& device_handle,const ze_context_handle_t& context,const ze_command_queue_priority_t& priority,- ze_command_queue_npu_dditable_ext_curr_t* command_queue_npu_dditable_ext,+ ze_command_queue_npu_dditable_ext_curr_t& command_queue_npu_dditable_ext,const Config& config,const uint32_t& group_ordinal): _context(context),@@ -141,7 +140,7 @@ CommandQueue::CommandQueue(const ze_device_handle_t& device_handle,ze_command_queue_desc_t queue_desc ={ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, nullptr, group_ordinal, 0, 0, ZE_COMMAND_QUEUE_MODE_DEFAULT, priority};if (config.has<TURBO>()) {- if (_command_queue_npu_dditable_ext != nullptr) {+ if (_command_queue_npu_dditable_ext.version()) {bool turbo = config.get<TURBO>();ze_command_queue_desc_npu_ext_t turbo_cfg = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC_NPU_EXT, nullptr, turbo};queue_desc.pNext = &turbo_cfg;@@ -162,9 +161,9 @@ void CommandQueue::executeCommandList(CommandList& command_list, Fence& fence) c}void CommandQueue::setWorkloadType(ze_command_queue_workload_type_t workloadType) const {- if (_command_queue_npu_dditable_ext != nullptr) {+ if (_command_queue_npu_dditable_ext.version()) {zeroUtils::throwOnFail("zeSetWorkloadType",- _command_queue_npu_dditable_ext->pfnSetWorkloadType(_handle, workloadType));+ _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType));} else {OPENVINO_THROW("The WorkloadType property is not supported by the current Driver Version!");}diff --git a/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp b/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hppindex fd7c656e814..108b48cf0c6 100644--- a/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp+++ b/src/plugins/intel_npu/src/compiler/include/zero_compiler_in_driver.hpp@@ -52,7 +52,7 @@ public:LevelZeroCompilerInDriver(ze_driver_handle_t driverHandle,ze_device_handle_t deviceHandle,ze_context_handle_t zeContext,- ze_graph_dditable_ext_last_t* graph_ddi_table_ext);+ ze_graph_dditable_ext_curr_t& graph_ddi_table_ext);LevelZeroCompilerInDriver(const LevelZeroCompilerInDriver&) = delete;LevelZeroCompilerInDriver& operator=(const LevelZeroCompilerInDriver&) = delete;~LevelZeroCompilerInDriver() override;@@ -110,14 +110,14 @@ private:std::string serializeConfig(const Config& config, ze_graph_compiler_version_info_t& compilerVersion) const;template <typename T = TableExtension, typename std::enable_if_t<NotSupportArgumentMetadata(T), bool> = true>- void getMetadata(TableExtension* graphDdiTableExt,+ void getMetadata(ze_graph_dditable_ext_curr_t& graphDdiTableExt,ze_graph_handle_t graphHandle,uint32_t index,std::vector<IODescriptor>& inputs,std::vector<IODescriptor>& outputs) const;template <typename T = TableExtension, typename std::enable_if_t<!NotSupportArgumentMetadata(T), bool> = true>- void getMetadata(TableExtension* graphDdiTableExt,+ void getMetadata(ze_graph_dditable_ext_curr_t& graphDdiTableExt,ze_graph_handle_t graphHandle,uint32_t index,std::vector<IODescriptor>& inputs,@@ -180,7 +180,7 @@ private:ze_device_handle_t _deviceHandle = nullptr;ze_context_handle_t _context = nullptr;- TableExtension* _graphDdiTableExt = nullptr;+ ze_graph_dditable_ext_curr_t& _graphDdiTableExt;Logger _logger;};diff --git a/src/plugins/intel_npu/src/compiler/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler/src/driver_compiler_adapter.cppindex a25b7e4c015..ceacd9cda03 100644--- a/src/plugins/intel_npu/src/compiler/src/driver_compiler_adapter.cpp+++ b/src/plugins/intel_npu/src/compiler/src/driver_compiler_adapter.cpp@@ -26,20 +26,20 @@ LevelZeroCompilerAdapter::LevelZeroCompilerAdapter(std::shared_ptr<IEngineBackenOPENVINO_THROW("LevelZeroCompilerAdapter init failed to cast zeroBackend, zeroBackend is a nullptr");}- uint32_t driverExtVersion = zeroBackend->getDriverExtVersion();-ze_context_handle_t zeContext = static_cast<ze_context_handle_t>(zeroBackend->getContext());ze_driver_handle_t driverHandle = static_cast<ze_driver_handle_t>(zeroBackend->getDriverHandle());ze_device_handle_t deviceHandle = static_cast<ze_device_handle_t>(zeroBackend->getDeviceHandle());- ze_graph_dditable_ext_last_t* graph_ddi_table_ext = zeroBackend->getGraphDDITableExt();+ ze_graph_dditable_ext_curr_t& graph_ddi_table_ext = zeroBackend->getGraphDdiTable();++ uint32_t graphExtVersion = graph_ddi_table_ext.version();if (driverHandle == nullptr) {OPENVINO_THROW("LevelZeroCompilerAdapter failed to get properties about zeDriver");}- _logger.info("LevelZeroCompilerAdapter creating adapter using driverExtVersion");+ _logger.info("LevelZeroCompilerAdapter creating adapter using graphExtVersion");- switch (driverExtVersion) {+ switch (graphExtVersion) {case ZE_GRAPH_EXT_VERSION_1_3:apiAdapter = std::make_shared<LevelZeroCompilerInDriver<ze_graph_dditable_ext_1_3_t>>(driverHandle,deviceHandle,@@ -72,9 +72,9 @@ LevelZeroCompilerAdapter::LevelZeroCompilerAdapter(std::shared_ptr<IEngineBackenbreak;}- _logger.info("initialize LevelZeroCompilerAdapter complete, using driverExtVersion: %d.%d",- ZE_MAJOR_VERSION(driverExtVersion),- ZE_MINOR_VERSION(driverExtVersion));+ _logger.info("initialize LevelZeroCompilerAdapter complete, using graphExtVersion: %d.%d",+ ZE_MAJOR_VERSION(graphExtVersion),+ ZE_MINOR_VERSION(graphExtVersion));}uint32_t LevelZeroCompilerAdapter::getSupportedOpsetVersion() const {diff --git a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cppindex 8a60833c3c7..c1398d22782 100644--- a/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp+++ b/src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp@@ -183,11 +183,11 @@ template <typename TableExtension>LevelZeroCompilerInDriver<TableExtension>::LevelZeroCompilerInDriver(ze_driver_handle_t driverHandle,ze_device_handle_t deviceHandle,ze_context_handle_t zeContext,- ze_graph_dditable_ext_last_t* graph_ddi_table_ext)+ ze_graph_dditable_ext_curr_t& graph_ddi_table_ext): _driverHandle(driverHandle),_deviceHandle(deviceHandle),_context(zeContext),- _graphDdiTableExt(reinterpret_cast<TableExtension*>(graph_ddi_table_ext)),+ _graphDdiTableExt(graph_ddi_table_ext),_logger("LevelZeroCompilerInDriver", Logger::global().level()) {}template <typename TableExtension>@@ -351,7 +351,7 @@ void LevelZeroCompilerInDriver<TableExtension>::release(std::shared_ptr<const Ne_logger.debug("release - graphHandle is not nullptr");ze_graph_handle_t graphHandle = static_cast<ze_graph_handle_t>(networkDescription->metadata.graphHandle);_logger.debug("release - pfnDestroy graphHandle");- auto result = _graphDdiTableExt->pfnDestroy(graphHandle);+ auto result = _graphDdiTableExt.pfnDestroy(graphHandle);if (ZE_RESULT_SUCCESS != result) {_logger.error("failed to release graph handle. L0 pfnDestroy result: %s, code %#X",@@ -372,7 +372,7 @@ std::vector<uint8_t> LevelZeroCompilerInDriver<TableExtension>::getCompiledNetwo// Get blob size firstsize_t blobSize = -1;- auto result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, &blobSize, nullptr);+ auto result = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, nullptr);OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,"Failed to compile network. L0 pfnGetNativeBinary get blob size",@@ -386,7 +386,7 @@ std::vector<uint8_t> LevelZeroCompilerInDriver<TableExtension>::getCompiledNetwostd::vector<uint8_t> blob(blobSize);// Get blob data- result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, &blobSize, blob.data());+ result = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, blob.data());OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,"Failed to compile network. L0 pfnGetNativeBinary get blob data",@@ -625,7 +625,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndQuerybuildFlags.c_str()};// Create querynetwork handle- ze_result_t result = _graphDdiTableExt->pfnQueryNetworkCreate(_context, _deviceHandle, &desc, &hGraphQueryNetwork);+ ze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate(_context, _deviceHandle, &desc, &hGraphQueryNetwork);return result;}@@ -639,7 +639,7 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::query_logger.info("queryImpl - Calling queryNetwork of 1.3 version.");ze_device_graph_properties_t deviceGraphProperties{};- auto result = _graphDdiTableExt->pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);+ auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnDeviceGetGraphProperties"," result: ",@@ -687,7 +687,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndQuery// Create querynetwork handle_logger.debug("seriazlideIRModelAndQueryNetworkCreateV2 - performing pfnQueryNetworkCreate2");- ze_result_t result = _graphDdiTableExt->pfnQueryNetworkCreate2(_context, _deviceHandle, &desc, &hGraphQueryNetwork);+ ze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate2(_context, _deviceHandle, &desc, &hGraphQueryNetwork);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 seriazlideIRModelAndQueryNetworkCreateV2",@@ -710,7 +710,7 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::query_logger.debug("queryImpl - Calling queryNetwork of 1.5 version.");ze_device_graph_properties_t deviceGraphProperties{};- auto result = _graphDdiTableExt->pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);+ auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnDeviceGetGraphProperties"," result: ",@@ -747,9 +747,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQu// Get the size of query resultsize_t size = 0;- result = _graphDdiTableExt->pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr);+ result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr);if (ZE_RESULT_SUCCESS != result) {- _graphDdiTableExt->pfnQueryNetworkDestroy(hGraphQueryNetwork);+ _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get size of query result"," result: ",ze_result_to_string(result),@@ -760,9 +760,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQu// Get the result data of querystd::vector<char> supportedLayers(size);- result = _graphDdiTableExt->pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, supportedLayers.data());+ result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, supportedLayers.data());if (ZE_RESULT_SUCCESS != result) {- _graphDdiTableExt->pfnQueryNetworkDestroy(hGraphQueryNetwork);+ _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get result data of query"," result: ",ze_result_to_string(result),@@ -771,7 +771,7 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQuuint64_t(result));}- result = _graphDdiTableExt->pfnQueryNetworkDestroy(hGraphQueryNetwork);+ result = _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnQueryNetworkDestroy"," result: ",@@ -822,7 +822,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grapbuildFlags.c_str()};// Create querynetwork handle- return _graphDdiTableExt->pfnCreate(_context, _deviceHandle, &desc, graph);+ return _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph);}// For ext version >= 1.5, calling pfnCreate2 api in _graphDdiTableExt@@ -843,7 +843,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grap_logger.debug("createGraph - performing pfnCreate2");// Create querynetwork handle- auto result = _graphDdiTableExt->pfnCreate2(_context, _deviceHandle, &desc, graph);+ auto result = _graphDdiTableExt.pfnCreate2(_context, _deviceHandle, &desc, graph);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnCreate2"," result: ",@@ -902,7 +902,7 @@ NetworkDescription LevelZeroCompilerInDriver<TableExtension>::compile(const std:_logger.debug("compile start");ze_device_graph_properties_t deviceGraphProperties{};- auto result = _graphDdiTableExt->pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);+ auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("Failed to compile network. L0 pfnDeviceGetGraphProperties"," result: ",@@ -952,7 +952,7 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::parse(const std::vectnetwork.data(),nullptr};- auto result = _graphDdiTableExt->pfnCreate(_context, _deviceHandle, &desc, &graphHandle);+ auto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, &graphHandle);OV_ITT_TASK_NEXT(PARSE_BLOB, "_graphDdiTableExt");if (ZE_RESULT_SUCCESS != result) {@@ -981,7 +981,7 @@ uint32_t LevelZeroCompilerInDriver<TableExtension>::getSupportedOpsetVersion() cze_device_graph_properties_t graphProperties;- auto result = _graphDdiTableExt->pfnDeviceGetGraphProperties(_deviceHandle, &graphProperties);+ auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &graphProperties);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnDeviceGetGraphProperties",@@ -1054,13 +1054,13 @@ static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg,template <typename TableExtension>template <typename T, std::enable_if_t<NotSupportArgumentMetadata(T), bool>>-void LevelZeroCompilerInDriver<TableExtension>::getMetadata(TableExtension* graphDdiTableExt,+void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_ext_curr_t& graphDdiTableExt,ze_graph_handle_t graphHandle,uint32_t index,std::vector<IODescriptor>& inputs,std::vector<IODescriptor>& outputs) const {ze_graph_argument_properties_3_t arg;- auto result = graphDdiTableExt->pfnGetArgumentProperties3(graphHandle, index, &arg);+ auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnGetArgumentProperties3"," result: ",@@ -1085,13 +1085,13 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(TableExtension* graptemplate <typename TableExtension>template <typename T, std::enable_if_t<!NotSupportArgumentMetadata(T), bool>>-void LevelZeroCompilerInDriver<TableExtension>::getMetadata(TableExtension* graphDdiTableExt,+void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_ext_curr_t& graphDdiTableExt,ze_graph_handle_t graphHandle,uint32_t index,std::vector<IODescriptor>& inputs,std::vector<IODescriptor>& outputs) const {ze_graph_argument_properties_3_t arg;- auto result = graphDdiTableExt->pfnGetArgumentProperties3(graphHandle, index, &arg);+ auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnGetArgumentProperties3"," result: ",@@ -1105,7 +1105,7 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(TableExtension* grapif (!isStateInputName(arg.name) && !isStateOutputName(arg.name) && !isShapeTensorName(arg.name)) {ze_graph_argument_metadata_t metadata;- result = graphDdiTableExt->pfnGraphGetArgumentMetadata(graphHandle, index, &metadata);+ result = graphDdiTableExt.pfnGraphGetArgumentMetadata(graphHandle, index, &metadata);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnGraphGetArgumentMetadata"," result: ",@@ -1135,7 +1135,7 @@ template <typename TableExtension>NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::getNetworkMeta(ze_graph_handle_t graphHandle) const {ze_graph_properties_t graphProperties{};- auto result = _graphDdiTableExt->pfnGetProperties(graphHandle, &graphProperties);+ auto result = _graphDdiTableExt.pfnGetProperties(graphHandle, &graphProperties);if (ZE_RESULT_SUCCESS != result) {OPENVINO_THROW("L0 pfnGetProperties",@@ -1168,7 +1168,7 @@ std::string LevelZeroCompilerInDriver<TableExtension>::getLatestBuildError() con// Get log sizeuint32_t size = 0;// Null graph handle to get erro log- auto result = _graphDdiTableExt->pfnBuildLogGetString(nullptr, &size, nullptr);+ auto result = _graphDdiTableExt.pfnBuildLogGetString(nullptr, &size, nullptr);if (ZE_RESULT_SUCCESS != result) {// The failure will not break normal execution, only warning here_logger.warning("getLatestBuildError Failed to get size of latest error log!");@@ -1185,7 +1185,7 @@ std::string LevelZeroCompilerInDriver<TableExtension>::getLatestBuildError() con// Get log contentstd::string logContent{};logContent.resize(size);- result = _graphDdiTableExt->pfnBuildLogGetString(nullptr, &size, const_cast<char*>(logContent.data()));+ result = _graphDdiTableExt.pfnBuildLogGetString(nullptr, &size, const_cast<char*>(logContent.data()));if (ZE_RESULT_SUCCESS != result) {// The failure will not break normal execution, only warning here_logger.warning("getLatestBuildError size of latest error log > 0, failed to get "diff --git a/src/plugins/intel_npu/src/plugin/include/backends.hpp b/src/plugins/intel_npu/src/plugin/include/backends.hppindex 5718ef01524..177c0b96eb2 100644--- a/src/plugins/intel_npu/src/plugin/include/backends.hpp+++ b/src/plugins/intel_npu/src/plugin/include/backends.hpp@@ -31,7 +31,7 @@ public:ov::SoPtr<IEngineBackend> getIEngineBackend();std::string getBackendName() const;uint32_t getDriverVersion() const;- uint32_t getDriverExtVersion() const;+ uint32_t getGraphExtVersion() const;bool isBatchingSupported() const;bool isCommandQueueExtSupported() const;void registerOptions(OptionsDesc& options) const;diff --git a/src/plugins/intel_npu/src/plugin/include/metrics.hpp b/src/plugins/intel_npu/src/plugin/include/metrics.hppindex abd24a3c1b0..e09966ba270 100644--- a/src/plugins/intel_npu/src/plugin/include/metrics.hpp+++ b/src/plugins/intel_npu/src/plugin/include/metrics.hpp@@ -34,7 +34,7 @@ public:uint64_t GetDeviceAllocMemSize(const std::string& specifiedDeviceName) const;uint64_t GetDeviceTotalMemSize(const std::string& specifiedDeviceName) const;uint32_t GetDriverVersion() const;- uint32_t GetDriverExtVersion() const;+ uint32_t GetGraphExtVersion() const;uint32_t GetSteppingNumber(const std::string& specifiedDeviceName) const;uint32_t GetMaxTiles(const std::string& specifiedDeviceName) const;ov::device::PCIInfo GetPciInfo(const std::string& specifiedDeviceName) const;diff --git a/src/plugins/intel_npu/src/plugin/src/backends.cpp b/src/plugins/intel_npu/src/plugin/src/backends.cppindex 9fff7f67ffc..1019cff3287 100644--- a/src/plugins/intel_npu/src/plugin/src/backends.cpp+++ b/src/plugins/intel_npu/src/plugin/src/backends.cpp@@ -151,9 +151,9 @@ uint32_t NPUBackends::getDriverVersion() const {OPENVINO_THROW("No available backend");}-uint32_t NPUBackends::getDriverExtVersion() const {+uint32_t NPUBackends::getGraphExtVersion() const {if (_backend != nullptr) {- return _backend->getDriverExtVersion();+ return _backend->getGraphExtVersion();}OPENVINO_THROW("No available backend");diff --git a/src/plugins/intel_npu/src/plugin/src/metrics.cpp b/src/plugins/intel_npu/src/plugin/src/metrics.cppindex f363d1ad9a2..15c7bb2bd32 100644--- a/src/plugins/intel_npu/src/plugin/src/metrics.cpp+++ b/src/plugins/intel_npu/src/plugin/src/metrics.cpp@@ -115,12 +115,12 @@ uint32_t Metrics::GetDriverVersion() const {return _backends->getDriverVersion();}-uint32_t Metrics::GetDriverExtVersion() const {+uint32_t Metrics::GetGraphExtVersion() const {if (_backends == nullptr) {OPENVINO_THROW("No available backends");}- return _backends->getDriverExtVersion();+ return _backends->getGraphExtVersion();}uint32_t Metrics::GetSteppingNumber(const std::string& specifiedDeviceName) const {diff --git a/src/plugins/intel_npu/tests/functional/internal/overload/compile_and_infer.hpp b/src/plugins/intel_npu/tests/functional/internal/overload/compile_and_infer.hppindex 03df711402c..767949b3afc 100644--- a/src/plugins/intel_npu/tests/functional/internal/overload/compile_and_infer.hpp+++ b/src/plugins/intel_npu/tests/functional/internal/overload/compile_and_infer.hpp@@ -34,7 +34,7 @@ inline std::shared_ptr<ov::Model> getConstantGraph(element::Type type) {}inline bool isCommandQueueExtSupported() {- return std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable() != nullptr;+ return std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() > 0;}typedef std::tuple<std::shared_ptr<ov::Model>, // Model