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] Use level zero init structure/ Follow same code design (#27453)
Bogdan Pereanu51062eaa13e3
diff --git a/src/plugins/intel_npu/src/backend/include/zero_device.hpp b/src/plugins/intel_npu/src/backend/include/zero_device.hppindex 50f0d28ed21..aca3e97582f 100644--- a/src/plugins/intel_npu/src/backend/include/zero_device.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_device.hpp@@ -58,8 +58,6 @@ public:private:const std::shared_ptr<ZeroInitStructsHolder> _initStructs;- ze_graph_dditable_ext_curr_t& _graph_ddi_table_ext;-ze_device_properties_t device_properties = {};ze_pci_ext_properties_t pci_properties = {};diff --git a/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp b/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hppindex a214c8e2cb2..eee2c36c4aa 100644--- a/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_host_tensor.hpp@@ -13,8 +13,8 @@ namespace intel_npu {class ZeroHostTensor : public ov::ITensor {public:- ZeroHostTensor(std::shared_ptr<ov::IRemoteContext> context,- std::shared_ptr<ZeroInitStructsHolder> init_structs,+ ZeroHostTensor(const std::shared_ptr<ov::IRemoteContext>& context,+ const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ov::element::Type element_type,const ov::Shape& shape,const Config& config);diff --git a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hppindex 31248b58225..3efbdab666d 100644--- a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp@@ -63,7 +63,7 @@ private:* @param index The index corresponding to the position of the tensor inside the I/O structures.* @param isInput Used for identifying the structures to which the tensor belongs.*/- void set_tensor_data(const std::shared_ptr<ov::ITensor> tensor, const size_t index, const bool isInput);+ void set_tensor_data(const std::shared_ptr<ov::ITensor>& tensor, const size_t index, const bool isInput);/*** @brief Check the received remote tensor and copy it to the Level Zero tensor@@ -71,7 +71,9 @@ private:* @param index The index corresponding to the position of the tensor inside the I/O structures.* @param isInput Used for identifying the structures to which the tensor belongs.*/- void set_remote_tensor_data(const std::shared_ptr<ZeroRemoteTensor> tensor, const size_t index, const bool isInput);+ void set_remote_tensor_data(const std::shared_ptr<ZeroRemoteTensor>& tensor,+ const size_t index,+ const bool isInput);void check_network_precision(const ov::element::Type_t precision) const override;void create_pipeline();diff --git a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hppindex 92a473a9fc4..5b7f488d3eb 100644--- a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp@@ -25,7 +25,7 @@ public:const std::shared_ptr<IGraph>& graph,zeroProfiling::ProfilingPool& profiling_pool,zeroProfiling::ProfilingQuery& profiling_query,- std::shared_ptr<zeroProfiling::NpuInferProfiling> npu_profiling,+ const std::shared_ptr<zeroProfiling::NpuInferProfiling>& npu_profiling,const std::vector<std::vector<std::optional<TensorData>>>& inputTensorsData,const std::vector<std::optional<TensorData>>& outputTensorsData,size_t numberOfCommandLists,diff --git a/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp b/src/plugins/intel_npu/src/backend/include/zero_profiling.hppindex 17e263a7aaf..9b799f2b5ef 100644--- a/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_profiling.hpp@@ -10,8 +10,10 @@#include <climits>#include <map>+#include "intel_npu/common/igraph.hpp"#include "intel_npu/config/compiler.hpp"#include "intel_npu/utils/logger/logger.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"#include "intel_npu/utils/zero/zero_types.hpp"#include "openvino/runtime/profiling_info.hpp"@@ -23,31 +25,29 @@ using LayerStatistics = std::vector<ov::ProfilingInfo>;constexpr uint32_t POOL_SIZE = 1;struct ProfilingPool {- ProfilingPool(ze_graph_handle_t graph_handle,- uint32_t profiling_count,- 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) {}+ ProfilingPool(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,+ const std::shared_ptr<IGraph>& graph,+ uint32_t profiling_count)+ : _init_structs(init_structs),+ _graph(graph),+ _profiling_count(profiling_count) {}ProfilingPool(const ProfilingPool&) = delete;ProfilingPool& operator=(const ProfilingPool&) = delete;bool create();~ProfilingPool();- ze_graph_handle_t _graph_handle;+ std::shared_ptr<ZeroInitStructsHolder> _init_structs;+ std::shared_ptr<IGraph> _graph;const uint32_t _profiling_count;+ze_graph_profiling_pool_handle_t _handle = 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_curr_t& graph_profiling_ddi_table_ext)- : _index(index),- _device_handle(device_handle),- _graph_profiling_ddi_table_ext(graph_profiling_ddi_table_ext) {}+ ProfilingQuery(const std::shared_ptr<ZeroInitStructsHolder>& init_structs, uint32_t index)+ : _init_structs(init_structs),+ _index(index) {}ProfilingQuery(const ProfilingQuery&) = delete;ProfilingQuery& operator=(const ProfilingQuery&) = delete;void create(const ze_graph_profiling_pool_handle_t& profiling_pool);@@ -64,10 +64,10 @@ private:void getProfilingProperties(ze_device_profiling_data_properties_t* properties) const;void verifyProfilingProperties() const;+ std::shared_ptr<ZeroInitStructsHolder> _init_structs;const uint32_t _index;- ze_device_handle_t _device_handle;+ze_graph_profiling_query_handle_t _handle = nullptr;- ze_graph_profiling_dditable_ext_curr_t& _graph_profiling_ddi_table_ext;};extern template std::vector<uint8_t> ProfilingQuery::getData<uint8_t>() const;@@ -75,7 +75,7 @@ extern template std::vector<uint8_t> ProfilingQuery::getData<uint8_t>() const;using NpuInferStatistics = std::vector<ov::ProfilingInfo>;struct NpuInferProfiling final {- explicit NpuInferProfiling(ze_context_handle_t context, ze_device_handle_t device_handle, ov::log::Level loglevel);+ explicit NpuInferProfiling(const std::shared_ptr<ZeroInitStructsHolder>& init_structs, ov::log::Level loglevel);NpuInferProfiling(const NpuInferProfiling&) = delete;NpuInferProfiling& operator=(const NpuInferProfiling&) = delete;NpuInferProfiling(NpuInferProfiling&&) = delete;@@ -91,8 +91,7 @@ struct NpuInferProfiling final {void* npu_ts_infer_end = 0;private:- ze_context_handle_t _context = nullptr;- ze_device_handle_t _device_handle;+ std::shared_ptr<ZeroInitStructsHolder> _init_structs;ov::log::Level _loglevel;Logger _logger;ze_device_properties_t _dev_properties = {};diff --git a/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp b/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hppindex 5b08643704b..aabe5e9bb4e 100644--- a/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_remote_tensor.hpp@@ -16,8 +16,8 @@ namespace intel_npu {class ZeroRemoteTensor : public RemoteTensor {public:- ZeroRemoteTensor(std::shared_ptr<ov::IRemoteContext> context,- std::shared_ptr<ZeroInitStructsHolder> init_structs,+ ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,+ const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ov::element::Type& element_type,const ov::Shape& shape,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 6e16dde3b12..b982fd14ee0 100644--- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp@@ -15,7 +15,6 @@ using namespace intel_npu;ZeroDevice::ZeroDevice(const std::shared_ptr<ZeroInitStructsHolder>& initStructs): _initStructs(initStructs),- _graph_ddi_table_ext(_initStructs->getGraphDdiTable()),log("ZeroDevice", Logger::global().level()) {log.debug("ZeroDevice::ZeroDevice init");device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;@@ -121,9 +120,10 @@ uint32_t ZeroDevice::getMaxNumSlices() const {uint64_t ZeroDevice::getAllocMemSize() const {ze_graph_memory_query_t query{};- ze_result_t result =- _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query);- THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _graph_ddi_table_ext);+ ze_result_t result = _initStructs->getGraphDdiTable().pfnQueryContextMemory(_initStructs->getContext(),+ ZE_GRAPH_QUERY_MEMORY_DDR,+ &query);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _initStructs->getGraphDdiTable());return query.allocated;}@@ -132,9 +132,10 @@ uint64_t ZeroDevice::getTotalMemSize() const {#define LEGACY_MAX_MEM_ALLOC_SIZE_BYTES (2147483648) // 2GB in base-2ze_graph_memory_query_t query{};- ze_result_t result =- _graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query);- THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _graph_ddi_table_ext);+ ze_result_t result = _initStructs->getGraphDdiTable().pfnQueryContextMemory(_initStructs->getContext(),+ ZE_GRAPH_QUERY_MEMORY_DDR,+ &query);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _initStructs->getGraphDdiTable());// For drivers with graph_extension < 1.9 we report fixed 2GB max allocation size (old drivers don't support more)// For drivers with graph_extension > 1.9 we report the value they returndiff --git a/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cppindex e0f1094e67d..71d9c5f4b3c 100644--- a/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_host_tensor.cpp@@ -8,8 +8,8 @@namespace intel_npu {-ZeroHostTensor::ZeroHostTensor(std::shared_ptr<ov::IRemoteContext> context,- std::shared_ptr<ZeroInitStructsHolder> init_structs,+ZeroHostTensor::ZeroHostTensor(const std::shared_ptr<ov::IRemoteContext>& context,+ const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ov::element::Type element_type,const ov::Shape& shape,const Config& config)diff --git a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cppindex 1c5ceecfac1..88dfaf944a8 100644--- a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp@@ -167,10 +167,8 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&_levelZeroOutputTensors(_metadata.outputs.size(), nullptr),_inputTensorsData(_metadata.inputs.size(), std::vector<std::optional<TensorData>>(1, std::nullopt)),_outputTensorsData(_metadata.outputs.size(), std::nullopt),- _profilingPool(static_cast<ze_graph_handle_t>(_graph->get_handle()),- zeroProfiling::POOL_SIZE,- _initStructs->getProfilingDdiTable()),- _profilingQuery(0, _initStructs->getDevice(), _initStructs->getProfilingDdiTable()) {+ _profilingPool(_initStructs, _graph, zeroProfiling::POOL_SIZE),+ _profilingQuery(_initStructs, 0) {_logger.debug("ZeroInferRequest::ZeroInferRequest - SyncInferRequest");const std::vector<ArgumentDescriptor>& executorInputDescriptors = _graph->get_input_descriptors();const std::vector<ArgumentDescriptor>& executorOutputDescriptors = _graph->get_output_descriptors();@@ -178,9 +176,7 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&auto proftype = config.get<PROFILING_TYPE>();if (proftype == ov::intel_npu::ProfilingType::INFER) {_logger.debug("ZeroInferRequest::ZeroInferRequest - profiling type == ov::intel_npu::ProfilingType::INFER");- _npuProfiling = std::make_shared<zeroProfiling::NpuInferProfiling>(_initStructs->getContext(),- _initStructs->getDevice(),- _config.get<LOG_LEVEL>());+ _npuProfiling = std::make_shared<zeroProfiling::NpuInferProfiling>(_initStructs, _config.get<LOG_LEVEL>());}_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;@@ -296,7 +292,7 @@ void ZeroInferRequest::create_pipeline() {_logger.debug("ZeroInferRequest::create_pipeline - SyncInferRequest completed");}-void ZeroInferRequest::set_tensor_data(const std::shared_ptr<ov::ITensor> tensor,+void ZeroInferRequest::set_tensor_data(const std::shared_ptr<ov::ITensor>& tensor,const size_t index,const bool isInput) {OV_ITT_TASK_CHAIN(ZERO_SET_TENSOR, itt::domains::LevelZeroBackend, "set_tensor", "set_tensor_data");@@ -347,7 +343,7 @@ void ZeroInferRequest::set_tensor_data(const std::shared_ptr<ov::ITensor> tensor}}-void ZeroInferRequest::set_remote_tensor_data(const std::shared_ptr<ZeroRemoteTensor> tensor,+void ZeroInferRequest::set_remote_tensor_data(const std::shared_ptr<ZeroRemoteTensor>& tensor,const size_t index,const bool isInput) {OV_ITT_TASK_CHAIN(ZERO_SET_REMOTE_TENSOR, itt::domains::LevelZeroBackend, "set_tensor", "set_remote_tensor_data");diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cppindex 34eb71eaf11..c782c3e0684 100644--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp@@ -20,7 +20,7 @@ Pipeline::Pipeline(const Config& config,const std::shared_ptr<IGraph>& graph,zeroProfiling::ProfilingPool& profiling_pool,zeroProfiling::ProfilingQuery& profiling_query,- std::shared_ptr<zeroProfiling::NpuInferProfiling> npu_profiling,+ const std::shared_ptr<zeroProfiling::NpuInferProfiling>& npu_profiling,const std::vector<std::vector<std::optional<TensorData>>>& inputTensorsData,const std::vector<std::optional<TensorData>>& outputTensorsData,size_t numberOfCommandLists,@@ -30,7 +30,7 @@ Pipeline::Pipeline(const Config& config,_event_pool{initStructs->getDevice(),initStructs->getContext(),numberOfCommandLists ? static_cast<uint32_t>(numberOfCommandLists) : 1},- _npu_profiling(std::move(npu_profiling)),+ _npu_profiling(npu_profiling),_logger("Pipeline", _config.get<LOG_LEVEL>()) {OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "Zero_infer_request::Pipeline::Pipeline");_logger.debug("Pipeline - initialize started");@@ -45,9 +45,7 @@ Pipeline::Pipeline(const Config& config,_logger.debug("Pipeline - emplace_back _event_pool and _command_queue");for (size_t i = 0; i < numberOfCommandLists; i++) {_command_lists.emplace_back(- std::make_unique<CommandList>(initStructs->getDevice(),- initStructs->getContext(),- initStructs->getGraphDdiTable(),+ std::make_unique<CommandList>(initStructs,group_ordinal,initStructs->getMutableCommandListVersion() ? true : false));_events.emplace_back(std::make_unique<Event>(_event_pool.handle(), static_cast<uint32_t>(i)));diff --git a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp b/src/plugins/intel_npu/src/backend/src/zero_profiling.cppindex 52302b38df5..f85c2c5f713 100644--- a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp@@ -35,20 +35,21 @@ struct ZeProfilingTypeId<uint8_t> {};bool ProfilingPool::create() {- auto ret = _graph_profiling_ddi_table_ext.pfnProfilingPoolCreate(_graph_handle, _profiling_count, &_handle);+ auto ret =+ _init_structs->getProfilingDdiTable().pfnProfilingPoolCreate(_graph->get_handle(), _profiling_count, &_handle);return ((ZE_RESULT_SUCCESS == ret) && (_handle != nullptr));}ProfilingPool::~ProfilingPool() {if (_handle) {- _graph_profiling_ddi_table_ext.pfnProfilingPoolDestroy(_handle);+ _init_structs->getProfilingDdiTable().pfnProfilingPoolDestroy(_handle);}}void ProfilingQuery::create(const ze_graph_profiling_pool_handle_t& profiling_pool) {THROW_ON_FAIL_FOR_LEVELZERO("pfnProfilingQueryCreate",- _graph_profiling_ddi_table_ext.pfnProfilingQueryCreate(profiling_pool, _index, &_handle));+ _init_structs->getProfilingDdiTable().pfnProfilingQueryCreate(profiling_pool, _index, &_handle));}LayerStatistics ProfilingQuery::getLayerStatistics() const {@@ -59,7 +60,7 @@ LayerStatistics ProfilingQuery::getLayerStatistics() const {ProfilingQuery::~ProfilingQuery() {if (_handle) {- _graph_profiling_ddi_table_ext.pfnProfilingQueryDestroy(_handle);+ _init_structs->getProfilingDdiTable().pfnProfilingQueryDestroy(_handle);}}@@ -69,7 +70,7 @@ void ProfilingQuery::queryGetData(const ze_graph_profiling_type_t profilingType,if (_handle && pSize) {THROW_ON_FAIL_FOR_LEVELZERO("pfnProfilingQueryGetData",- _graph_profiling_ddi_table_ext.pfnProfilingQueryGetData(_handle, profilingType, pSize, pData));+ _init_structs->getProfilingDdiTable().pfnProfilingQueryGetData(_handle, profilingType, pSize, pData));}}@@ -95,7 +96,8 @@ void ProfilingQuery::getProfilingProperties(ze_device_profiling_data_properties_if (_handle && properties) {THROW_ON_FAIL_FOR_LEVELZERO("getProfilingProperties",- _graph_profiling_ddi_table_ext.pfnDeviceGetProfilingDataProperties(_device_handle, properties));+ _init_structs->getProfilingDdiTable().pfnDeviceGetProfilingDataProperties(_init_structs->getDevice(),+ properties));}}@@ -179,30 +181,29 @@ NpuInferStatistics NpuInferProfiling::getNpuInferStatistics() const {return npuPerfCounts;}-NpuInferProfiling::NpuInferProfiling(ze_context_handle_t context,- ze_device_handle_t device_handle,+NpuInferProfiling::NpuInferProfiling(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,ov::log::Level loglevel)- : _context(context),- _device_handle(device_handle),+ : _init_structs(init_structs),_loglevel(loglevel),_logger("InferProfiling", loglevel) {/// Fetch and store the device timer resolution_dev_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2;- THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", zeDeviceGetProperties(_device_handle, &_dev_properties));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",+ zeDeviceGetProperties(_init_structs->getDevice(), &_dev_properties));/// Request mem allocationsze_host_mem_alloc_desc_t desc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC,nullptr,ZE_HOST_MEM_ALLOC_FLAG_BIAS_CACHED};THROW_ON_FAIL_FOR_LEVELZERO("zeMemAllocHost",- zeMemAllocHost(_context,+ zeMemAllocHost(_init_structs->getContext(),&desc,sizeof(uint64_t),64,&npu_ts_infer_start)); // align to 64 bytes to match npu l2 cache line sizeTHROW_ON_FAIL_FOR_LEVELZERO("zeMemAllocHost",- zeMemAllocHost(_context,+ zeMemAllocHost(_init_structs->getContext(),&desc,sizeof(uint64_t),64,@@ -235,13 +236,13 @@ int64_t NpuInferProfiling::convertCCtoUS(int64_t val_cc) const {NpuInferProfiling::~NpuInferProfiling() {/// deallocate npu_ts_infer_start and npu_ts_infer_end, allocated externally by ze driverif (npu_ts_infer_start != nullptr) {- auto ze_ret = zeMemFree(_context, npu_ts_infer_start);+ auto ze_ret = zeMemFree(_init_structs->getContext(), npu_ts_infer_start);if (ZE_RESULT_SUCCESS != ze_ret) {_logger.error("zeMemFree on npu_ts_infer_start failed %#X", uint64_t(ze_ret));}}if (npu_ts_infer_end != nullptr) {- auto ze_ret = zeMemFree(_context, npu_ts_infer_end);+ auto ze_ret = zeMemFree(_init_structs->getContext(), npu_ts_infer_end);if (ZE_RESULT_SUCCESS != ze_ret) {_logger.error("zeMemFree on npu_ts_infer_end failed %#X", uint64_t(ze_ret));}diff --git a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cppindex 8419fec7a86..bb046b50f99 100644--- a/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_remote_tensor.cpp@@ -21,18 +21,18 @@ constexpr std::size_t STANDARD_PAGE_SIZE = 4096;namespace intel_npu {-ZeroRemoteTensor::ZeroRemoteTensor(std::shared_ptr<ov::IRemoteContext> context,- std::shared_ptr<ZeroInitStructsHolder> init_structs,+ZeroRemoteTensor::ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,+ const std::shared_ptr<ZeroInitStructsHolder>& init_structs,const ov::element::Type& element_type,const ov::Shape& shape,const Config& config,TensorType tensor_type,MemType mem_type,void* mem)- : RemoteTensor(std::move(context), element_type, shape),+ : RemoteTensor(context, element_type, shape),_config(config),_logger("ZeroRemoteContext", _config.get<LOG_LEVEL>()),- _init_structs(std::move(init_structs)),+ _init_structs(init_structs),_tensor_type(tensor_type),_mem_type(mem_type),_mem(mem) {diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/remote_tensor.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/remote_tensor.hppindex d485052c989..8a6edeb2e8d 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/remote_tensor.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/remote_tensor.hpp@@ -20,7 +20,7 @@ namespace intel_npu {*/class RemoteTensor : public ov::IRemoteTensor {public:- RemoteTensor(std::shared_ptr<ov::IRemoteContext> context,+ RemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,const ov::element::Type& element_type,const ov::Shape& shape);diff --git a/src/plugins/intel_npu/src/common/src/remote_tensor.cpp b/src/plugins/intel_npu/src/common/src/remote_tensor.cppindex 2d81de4aae6..a12ac7dca81 100644--- a/src/plugins/intel_npu/src/common/src/remote_tensor.cpp+++ b/src/plugins/intel_npu/src/common/src/remote_tensor.cpp@@ -10,10 +10,10 @@namespace intel_npu {-RemoteTensor::RemoteTensor(std::shared_ptr<ov::IRemoteContext> context,+RemoteTensor::RemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,const ov::element::Type& element_type,const ov::Shape& shape)- : _context(std::move(context)),+ : _context(context),_element_type(element_type),_shape(shape),_capacity(shape) {diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cppindex e5db5c561f7..84759bf802f 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_graph.cpp@@ -109,12 +109,10 @@ void DriverGraph::initialize(const Config& config) {turbo = config.get<TURBO>();}- _command_queue = std::make_shared<CommandQueue>(_zeroInitStruct->getDevice(),- _zeroInitStruct->getContext(),+ _command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),- _zeroInitStruct->getCommandQueueDdiTable(),- turbo,- groupOrdinal);+ groupOrdinal,+ turbo);if (config.has<WORKLOAD_TYPE>()) {set_workload_type(config.get<WORKLOAD_TYPE>());diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cppindex cb57844b709..8f60efd50af 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp@@ -104,12 +104,10 @@ void PluginGraph::initialize(const Config& config) {turbo = config.get<TURBO>();}- _command_queue = std::make_shared<CommandQueue>(_zeroInitStruct->getDevice(),- _zeroInitStruct->getContext(),+ _command_queue = std::make_shared<CommandQueue>(_zeroInitStruct,zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>()),- _zeroInitStruct->getCommandQueueDdiTable(),- turbo,- groupOrdinal);+ groupOrdinal,+ turbo);if (config.has<WORKLOAD_TYPE>()) {set_workload_type(config.get<WORKLOAD_TYPE>());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 095f470e15e..fad389ca30e 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@@ -173,17 +173,9 @@ void ZeGraphExtWrappers<TableExtension>::initialize_graph_through_command_list(zauto groupOrdinal = zeroUtils::findGroupOrdinal(_zeroInitStruct->getDevice(), deviceProperties);_logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list init start - create graph_command_list");- CommandList graph_command_list(_zeroInitStruct->getDevice(),- _zeroInitStruct->getContext(),- _zeroInitStruct->getGraphDdiTable(),- groupOrdinal);+ CommandList graph_command_list(_zeroInitStruct, groupOrdinal);_logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - create graph_command_queue");- CommandQueue graph_command_queue(_zeroInitStruct->getDevice(),- _zeroInitStruct->getContext(),- ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- _zeroInitStruct->getCommandQueueDdiTable(),- false,- groupOrdinal);+ CommandQueue graph_command_queue(_zeroInitStruct, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, groupOrdinal, false);_logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - create fence");Fence fence(graph_command_queue);diff --git a/src/plugins/intel_npu/src/plugin/include/remote_context.hpp b/src/plugins/intel_npu/src/plugin/include/remote_context.hppindex b6b8df59153..e0a9bb0d3f3 100644--- a/src/plugins/intel_npu/src/plugin/include/remote_context.hpp+++ b/src/plugins/intel_npu/src/plugin/include/remote_context.hpp@@ -16,7 +16,7 @@ namespace intel_npu {class RemoteContextImpl : public ov::IRemoteContext {public:- RemoteContextImpl(std::shared_ptr<const NPUBackends> backends, const Config& config);+ RemoteContextImpl(const std::shared_ptr<const NPUBackends>& backends, const Config& config);/*** @brief Returns name of a device on which underlying object is allocated.diff --git a/src/plugins/intel_npu/src/plugin/src/remote_context.cpp b/src/plugins/intel_npu/src/plugin/src/remote_context.cppindex 938057668a7..a5f2cfb0e53 100644--- a/src/plugins/intel_npu/src/plugin/src/remote_context.cpp+++ b/src/plugins/intel_npu/src/plugin/src/remote_context.cpp@@ -29,7 +29,7 @@ std::optional<Type> extract_object(const ov::AnyMap& params, const ov::Property<namespace intel_npu {-RemoteContextImpl::RemoteContextImpl(std::shared_ptr<const NPUBackends> backends, const Config& config)+RemoteContextImpl::RemoteContextImpl(const std::shared_ptr<const NPUBackends>& backends, const Config& config): _backends(backends),_config(config),_properties({l0_context(backends->getContext())}),diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hppindex afd6813a662..9b5b1b4540f 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp@@ -7,6 +7,7 @@#include <ze_api.h>#include "intel_npu/utils/logger/logger.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"#include "intel_npu/utils/zero/zero_types.hpp"#include "intel_npu/utils/zero/zero_utils.hpp"@@ -59,9 +60,7 @@ class CommandList {public:friend class CommandQueue;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,+ CommandList(const std::shared_ptr<ZeroInitStructsHolder>& initStructs,const uint32_t& group_ordinal,bool mtci_is_supported = false);CommandList(const CommandList&) = delete;@@ -85,12 +84,12 @@ 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;- uint64_t _command_id = 0;+ std::shared_ptr<ZeroInitStructsHolder> _initStructs;Logger _log;++ uint64_t _command_id = 0;+ ze_command_list_handle_t _handle = nullptr;};class Fence {@@ -118,12 +117,10 @@ private:class CommandQueue {public:CommandQueue() = delete;- CommandQueue(const ze_device_handle_t& device_handle,- const ze_context_handle_t& context,+ CommandQueue(const std::shared_ptr<ZeroInitStructsHolder>& initStructs,const ze_command_queue_priority_t& priority,- ze_command_queue_npu_dditable_ext_curr_t& command_queue_npu_dditable_ext,- bool turbo,- const uint32_t& group_ordinal);+ const uint32_t& group_ordinal,+ bool turbo = false);CommandQueue(const CommandQueue&) = delete;CommandQueue(CommandQueue&&) = delete;CommandQueue& operator=(const CommandQueue&) = delete;@@ -138,11 +135,11 @@ 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;+ std::shared_ptr<ZeroInitStructsHolder> _initStructs;Logger _log;++ ze_command_queue_handle_t _handle = nullptr;};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cppindex 32a497552fc..39bd92e7ecf 100644--- a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp@@ -53,17 +53,16 @@ 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,+CommandList::CommandList(const std::shared_ptr<ZeroInitStructsHolder>& initStructs,const uint32_t& group_ordinal,bool mtci_is_supported)- : _context(context),- _graph_ddi_table_ext(graph_ddi_table_ext),+ : _initStructs(initStructs),_log("CommandList", Logger::global().level()) {ze_mutable_command_list_exp_desc_t mutable_desc = {ZE_STRUCTURE_TYPE_MUTABLE_COMMAND_LIST_EXP_DESC, nullptr, 0};ze_command_list_desc_t desc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC, &mutable_desc, group_ordinal, 0};- THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListCreate", zeCommandListCreate(_context, device_handle, &desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeCommandListCreate",+ zeCommandListCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_handle));if (mtci_is_supported) {ze_mutable_command_id_exp_desc_t mutableCmdIdDesc = {ZE_STRUCTURE_TYPE_MUTABLE_COMMAND_ID_EXP_DESC,@@ -81,14 +80,15 @@ void CommandList::appendMemoryCopy(void* dst, const void* src, const std::size_tzeCommandListAppendMemoryCopy(_handle, dst, src, size, nullptr, 0, nullptr));}void CommandList::appendGraphInitialize(const ze_graph_handle_t& graph_handle) const {- ze_result_t result = _graph_ddi_table_ext.pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr);- THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphInitialize", result, _graph_ddi_table_ext);+ ze_result_t result =+ _initStructs->getGraphDdiTable().pfnAppendGraphInitialize(_handle, graph_handle, nullptr, 0, nullptr);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphInitialize", result, _initStructs->getGraphDdiTable());}void CommandList::appendGraphExecute(const ze_graph_handle_t& graph_handle,const ze_graph_profiling_query_handle_t& profiling_query_handle) const {- ze_result_t result =- _graph_ddi_table_ext.pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr);- THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphExecute", result, _graph_ddi_table_ext);+ ze_result_t result = _initStructs->getGraphDdiTable()+ .pfnAppendGraphExecute(_handle, graph_handle, profiling_query_handle, nullptr, 0, nullptr);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnAppendGraphExecute", result, _initStructs->getGraphDdiTable());}void CommandList::appendNpuTimestamp(uint64_t* timestamp_buff) const {THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendWriteGlobalTimestamp",@@ -121,20 +121,17 @@ void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_vzeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t));}-CommandQueue::CommandQueue(const ze_device_handle_t& device_handle,- const ze_context_handle_t& context,+CommandQueue::CommandQueue(const std::shared_ptr<ZeroInitStructsHolder>& initStructs,const ze_command_queue_priority_t& priority,- ze_command_queue_npu_dditable_ext_curr_t& command_queue_npu_dditable_ext,- bool turbo,- const uint32_t& group_ordinal)- : _context(context),- _command_queue_npu_dditable_ext(command_queue_npu_dditable_ext),+ const uint32_t& group_ordinal,+ bool turbo)+ : _initStructs(initStructs),_log("CommandQueue", Logger::global().level()) {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 (turbo) {- if (_command_queue_npu_dditable_ext.version()) {+ if (_initStructs->getCommandQueueDdiTable().version()) {ze_command_queue_desc_npu_ext_t turbo_cfg = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC_NPU_EXT, nullptr, turbo};queue_desc.pNext = &turbo_cfg;} else {@@ -142,8 +139,9 @@ CommandQueue::CommandQueue(const ze_device_handle_t& device_handle,}}- THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueCreate",- zeCommandQueueCreate(_context, device_handle, &queue_desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeCommandQueueCreate",+ zeCommandQueueCreate(_initStructs->getContext(), _initStructs->getDevice(), &queue_desc, &_handle));}void CommandQueue::executeCommandList(CommandList& command_list) const {THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists",@@ -155,9 +153,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.version()) {+ if (_initStructs->getCommandQueueDdiTable().version()) {THROW_ON_FAIL_FOR_LEVELZERO("zeSetWorkloadType",- _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType));+ _initStructs->getCommandQueueDdiTable().pfnSetWorkloadType(_handle, workloadType));} else {OPENVINO_THROW("The WorkloadType property is not supported by the current Driver Version!");}