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] Add pfn build log to pfn-related function (#26772)
Shaojie Zhu5e5c987cc3f9
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 c4860a83d9e..48aad52010a 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@@ -10,11 +10,11 @@#include "intel_npu/common/npu.hpp"#include "intel_npu/common/sync_infer_request.hpp"#include "intel_npu/utils/logger/logger.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "zero_executor.hpp"#include "zero_pipeline.hpp"#include "zero_profiling.hpp"#include "zero_remote_tensor.hpp"-#include "zero_utils.hpp"#include "zero_wrappers.hpp"namespace intel_npu {diff --git a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hppindex 4160a2ca979..62c8481d28a 100644--- a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp@@ -4,10 +4,10 @@#pragma once+#include "intel_npu/utils/zero/zero_utils.hpp"#include "zero_executor.hpp"#include "zero_memory.hpp"#include "zero_profiling.hpp"-#include "zero_utils.hpp"#include "zero_wrappers.hpp"namespace intel_npu {diff --git a/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp b/src/plugins/intel_npu/src/backend/include/zero_wrappers.hppindex 12a745e42e3..854bd88a7e4 100644--- a/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp+++ b/src/plugins/intel_npu/src/backend/include/zero_wrappers.hpp@@ -8,8 +8,8 @@#include <ze_graph_ext.h>#include "intel_npu/utils/logger/logger.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "zero_types.hpp"-#include "zero_utils.hpp"namespace intel_npu {class CommandList;diff --git a/src/plugins/intel_npu/src/backend/src/zero_device.cpp b/src/plugins/intel_npu/src/backend/src/zero_device.cppindex 7fd0eaf31b1..4a849462a8a 100644--- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp@@ -6,11 +6,11 @@#include "intel_npu/common/itt.hpp"#include "intel_npu/utils/zero/zero_api.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "zero_executor.hpp"#include "zero_host_tensor.hpp"#include "zero_infer_request.hpp"#include "zero_remote_tensor.hpp"-#include "zero_utils.hpp"using namespace intel_npu;@@ -20,8 +20,8 @@ ZeroDevice::ZeroDevice(const std::shared_ptr<ZeroInitStructsHolder>& initStructslog("ZeroDevice", Logger::global().level()) {log.debug("ZeroDevice::ZeroDevice init");device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;- zeroUtils::throwOnFail("zeDeviceGetProperties",- zeDeviceGetProperties(_initStructs->getDevice(), &device_properties));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",+ zeDeviceGetProperties(_initStructs->getDevice(), &device_properties));// Query PCI information// Older drivers do not have this implementend. Linux driver returns NOT_IMPLEMENTED, while windows driver returns@@ -62,7 +62,7 @@ ZeroDevice::ZeroDevice(const std::shared_ptr<ZeroInitStructsHolder>& initStructsstd::vector<ze_command_queue_group_properties_t> command_group_properties;uint32_t command_queue_group_count = 0;// Discover all command queue groups- zeroUtils::throwOnFail(+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetCommandQueueGroupProperties",zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(), &command_queue_group_count, nullptr));@@ -74,10 +74,10 @@ ZeroDevice::ZeroDevice(const std::shared_ptr<ZeroInitStructsHolder>& initStructsprop.pNext = nullptr;}- zeroUtils::throwOnFail("zeDeviceGetCommandQueueGroupProperties",- zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(),- &command_queue_group_count,- command_group_properties.data()));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetCommandQueueGroupProperties",+ zeDeviceGetCommandQueueGroupProperties(_initStructs->getDevice(),+ &command_queue_group_count,+ command_group_properties.data()));// Find the corresponding command queue group.log.debug("ZeroDevice::ZeroDevice - findGroupOrdinal");@@ -138,17 +138,19 @@ uint32_t ZeroDevice::getMaxNumSlices() const {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));+ 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);+return query.allocated;}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));+ 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);+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 2d6779aed56..32da2b2e0e4 100644--- a/src/plugins/intel_npu/src/backend/src/zero_executor.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_executor.cpp@@ -14,10 +14,10 @@#include "intel_npu/common/itt.hpp"#include "intel_npu/config/common.hpp"#include "intel_npu/prefix.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "openvino/runtime/properties.hpp"#include "ze_command_queue_npu_ext.h"#include "zero_device.hpp"-#include "zero_utils.hpp"using namespace intel_npu;@@ -50,10 +50,9 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& i_networkDesc->compiledNetwork.size(),_networkDesc->compiledNetwork.data(),nullptr};-- zeroUtils::throwOnFail(- "pfnCreate",- _graph_ddi_table_ext.pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph));+ ze_result_t result =+ _graph_ddi_table_ext.pfnCreate(_initStructs->getContext(), _initStructs->getDevice(), &desc, &_graph);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graph_ddi_table_ext);} else {_logger.debug("reuse graph handle created from compiler");@@ -65,7 +64,9 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& ize_graph_properties_t props{};props.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES;- zeroUtils::throwOnFail("pfnGetProperties", _graph_ddi_table_ext.pfnGetProperties(_graph, &props));+ ze_result_t result = _graph_ddi_table_ext.pfnGetProperties(_graph, &props);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties", result, _graph_ddi_table_ext);+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 "@@ -77,8 +78,8 @@ ZeroExecutor::ZeroExecutor(const std::shared_ptr<const ZeroInitStructsHolder>& ifor (uint32_t index = 0; index < props.numGraphArgs; ++index) {ze_graph_argument_properties_3_t arg3{};arg3.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES;- zeroUtils::throwOnFail("pfnGetArgumentProperties3",- _graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3));+ ze_result_t result = _graph_ddi_table_ext.pfnGetArgumentProperties3(_graph, index, &arg3);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graph_ddi_table_ext);if (arg3.type == ZE_GRAPH_ARGUMENT_TYPE_INPUT) {_input_descriptors.push_back(ArgumentDescriptor{arg3, index});@@ -163,7 +164,10 @@ 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_));+ ze_result_t result = _graph_ddi_table_ext.pfnSetArgumentValue(_graph, argi_, argv_);+ if (ZE_RESULT_SUCCESS != result) {+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("zeGraphSetArgumentValue", result, _graph_ddi_table_ext);+ }}void ZeroExecutor::mutexLock() const {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 7a4754fb0bd..0a55945872b 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@@ -188,8 +188,8 @@ ZeroInferRequest::ZeroInferRequest(const std::shared_ptr<ZeroInitStructsHolder>&}_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;- zeroUtils::throwOnFail("zeDeviceGetProperties",- zeDeviceGetProperties(_executor->getInitStructs()->getDevice(), &_properties));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",+ zeDeviceGetProperties(_executor->getInitStructs()->getDevice(), &_properties));_outputAllocator = std::make_shared<const zeroMemory::HostMemAllocator>(_initStructs);_inputAllocator =diff --git a/src/plugins/intel_npu/src/backend/src/zero_init.cpp b/src/plugins/intel_npu/src/backend/src/zero_init.cppindex 17b916f232a..44a48714dda 100644--- a/src/plugins/intel_npu/src/backend/src/zero_init.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_init.cpp@@ -6,9 +6,9 @@#include "intel_npu/common/itt.hpp"#include "intel_npu/utils/zero/zero_api.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "ze_api.h"#include "ze_command_queue_npu_ext.h"-#include "zero_utils.hpp"#ifdef _WIN32namespace {@@ -54,13 +54,13 @@ static std::tuple<uint32_t, std::string> queryDriverExtensionVersion(ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder", Logger::global().level()) {OV_ITT_SCOPED_TASK(itt::domains::LevelZeroBackend, "ZeroInitStructsHolder::ZeroInitStructsHolder");log.debug("ZeroInitStructsHolder - performing zeInit on VPU only");- zeroUtils::throwOnFail("zeInit", zeInit(ZE_INIT_FLAG_VPU_ONLY));+ THROW_ON_FAIL_FOR_LEVELZERO("zeInit", zeInit(ZE_INIT_FLAG_VPU_ONLY));uint32_t drivers = 0;- zeroUtils::throwOnFail("zeDriverGet", zeDriverGet(&drivers, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGet", zeDriverGet(&drivers, nullptr));std::vector<ze_driver_handle_t> all_drivers(drivers);- zeroUtils::throwOnFail("zeDriverGet", zeDriverGet(&drivers, all_drivers.data()));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGet", zeDriverGet(&drivers, all_drivers.data()));// Get our target driverdriver_properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;@@ -79,7 +79,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",// Check L0 API versionze_api_version_t ze_drv_api_version = {};- zeroUtils::throwOnFail("zeDriverGetApiVersion", zeDriverGetApiVersion(driver_handle, &ze_drv_api_version));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetApiVersion", zeDriverGetApiVersion(driver_handle, &ze_drv_api_version));if (ZE_MAJOR_VERSION(ZE_API_VERSION_CURRENT) != ZE_MAJOR_VERSION(ze_drv_api_version)) {OPENVINO_THROW("Incompatibility between NPU plugin and driver! ",@@ -97,13 +97,13 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",}uint32_t count = 0;- zeroUtils::throwOnFail("zeDriverGetExtensionProperties",- zeDriverGetExtensionProperties(driver_handle, &count, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionProperties",+ zeDriverGetExtensionProperties(driver_handle, &count, nullptr));std::vector<ze_driver_extension_properties_t> extProps;extProps.resize(count);- zeroUtils::throwOnFail("zeDriverGetExtensionProperties",- zeDriverGetExtensionProperties(driver_handle, &count, extProps.data()));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionProperties",+ zeDriverGetExtensionProperties(driver_handle, &count, extProps.data()));// Query our graph extension versionstd::string graph_ext_name;@@ -148,7 +148,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",// Load our command queue extensionze_command_queue_npu_dditable_ext_last_t* _command_queue_npu_dditable_ext = nullptr;if (command_queue_ext_version) {- zeroUtils::throwOnFail(+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionFunctionAddress " + command_queue_ext_name,zeDriverGetExtensionFunctionAddress(driver_handle,command_queue_ext_name.c_str(),@@ -161,10 +161,10 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",// Load our graph extensionze_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)));+ THROW_ON_FAIL_FOR_LEVELZERO("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, graph_ext_version);@@ -189,7 +189,7 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",// Load our profiling extensionze_graph_profiling_dditable_ext_t* _graph_profiling_ddi_table_ext = nullptr;- zeroUtils::throwOnFail(+ THROW_ON_FAIL_FOR_LEVELZERO("zeDriverGetExtensionFunctionAddress",zeDriverGetExtensionFunctionAddress(driver_handle,"ZE_extension_profiling_data",@@ -200,11 +200,11 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",uint32_t device_count = 1;// Get our target device- zeroUtils::throwOnFail("zeDeviceGet", zeDeviceGet(driver_handle, &device_count, &device_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGet", zeDeviceGet(driver_handle, &device_count, &device_handle));// Create context - share between the compiler and the backendze_context_desc_t context_desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, 0, 0};- zeroUtils::throwOnFail("zeContextCreate", zeContextCreate(driver_handle, &context_desc, &context));+ THROW_ON_FAIL_FOR_LEVELZERO("zeContextCreate", zeContextCreate(driver_handle, &context_desc, &context));log.debug("ZeroInitStructsHolder initialize complete");}diff --git a/src/plugins/intel_npu/src/backend/src/zero_memory.cpp b/src/plugins/intel_npu/src/backend/src/zero_memory.cppindex 2faa22503eb..a12960c8b0a 100644--- a/src/plugins/intel_npu/src/backend/src/zero_memory.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_memory.cpp@@ -5,7 +5,7 @@#include "zero_memory.hpp"#include "intel_npu/utils/zero/zero_api.hpp"-#include "zero_utils.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"namespace intel_npu {namespace zeroMemory {diff --git a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp b/src/plugins/intel_npu/src/backend/src/zero_profiling.cppindex 525ffb2ce96..52302b38df5 100644--- a/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_profiling.cpp@@ -9,8 +9,8 @@#include "intel_npu/config/compiler.hpp"#include "intel_npu/profiling.hpp"#include "intel_npu/utils/zero/zero_api.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "zero_profiling.hpp"-#include "zero_utils.hpp"namespace intel_npu {namespace zeroProfiling {@@ -46,8 +46,9 @@ ProfilingPool::~ProfilingPool() {}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));+ THROW_ON_FAIL_FOR_LEVELZERO(+ "pfnProfilingQueryCreate",+ _graph_profiling_ddi_table_ext.pfnProfilingQueryCreate(profiling_pool, _index, &_handle));}LayerStatistics ProfilingQuery::getLayerStatistics() const {@@ -66,7 +67,7 @@ void ProfilingQuery::queryGetData(const ze_graph_profiling_type_t profilingType,uint32_t* pSize,uint8_t* pData) const {if (_handle && pSize) {- zeroUtils::throwOnFail(+ THROW_ON_FAIL_FOR_LEVELZERO("pfnProfilingQueryGetData",_graph_profiling_ddi_table_ext.pfnProfilingQueryGetData(_handle, profilingType, pSize, pData));}@@ -92,7 +93,7 @@ template std::vector<uint8_t> ProfilingQuery::getData<uint8_t>() const;void ProfilingQuery::getProfilingProperties(ze_device_profiling_data_properties_t* properties) const {if (_handle && properties) {- zeroUtils::throwOnFail(+ THROW_ON_FAIL_FOR_LEVELZERO("getProfilingProperties",_graph_profiling_ddi_table_ext.pfnDeviceGetProfilingDataProperties(_device_handle, properties));}@@ -187,23 +188,25 @@ NpuInferProfiling::NpuInferProfiling(ze_context_handle_t context,_logger("InferProfiling", loglevel) {/// Fetch and store the device timer resolution_dev_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2;- zeroUtils::throwOnFail("zeDeviceGetProperties", zeDeviceGetProperties(_device_handle, &_dev_properties));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", zeDeviceGetProperties(_device_handle, &_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};- zeroUtils::throwOnFail("zeMemAllocHost",- zeMemAllocHost(_context,- &desc,- sizeof(uint64_t),- 64,- &npu_ts_infer_start)); // align to 64 bytes to match npu l2 cache line size- zeroUtils::throwOnFail("zeMemAllocHost",- zeMemAllocHost(_context,- &desc,- sizeof(uint64_t),- 64,- &npu_ts_infer_end)); // alight to 64 bytes to match npu l2 cache line size+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeMemAllocHost",+ zeMemAllocHost(_context,+ &desc,+ sizeof(uint64_t),+ 64,+ &npu_ts_infer_start)); // align to 64 bytes to match npu l2 cache line size+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeMemAllocHost",+ zeMemAllocHost(_context,+ &desc,+ sizeof(uint64_t),+ 64,+ &npu_ts_infer_end)); // alight to 64 bytes to match npu l2 cache line size}void NpuInferProfiling::sampleNpuTimestamps() {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 e95b14c8777..8419fec7a86 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@@ -8,8 +8,8 @@#include "intel_npu/config/common.hpp"#include "intel_npu/utils/zero/zero_api.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "openvino/core/type/element_iterator.hpp"-#include "zero_utils.hpp"using namespace ov::intel_npu;@@ -37,7 +37,8 @@ ZeroRemoteTensor::ZeroRemoteTensor(std::shared_ptr<ov::IRemoteContext> context,_mem_type(mem_type),_mem(mem) {_ze_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;- zeroUtils::throwOnFail("zeDeviceGetProperties", zeDeviceGetProperties(_init_structs->getDevice(), &_ze_properties));+ THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties",+ zeDeviceGetProperties(_init_structs->getDevice(), &_ze_properties));const auto byte_size = ov::element::get_memory_size(_element_type, shape_size(_shape));@@ -97,8 +98,9 @@ void ZeroRemoteTensor::allocate(const size_t bytes) {} else {desc = {ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, nullptr, 0};}- zeroUtils::throwOnFail("zeMemAllocHost",- zeMemAllocHost(_init_structs->getContext(), &desc, size, STANDARD_PAGE_SIZE, &_data));+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeMemAllocHost",+ zeMemAllocHost(_init_structs->getContext(), &desc, size, STANDARD_PAGE_SIZE, &_data));break;}case MemType::SHARED_BUF: {@@ -116,13 +118,13 @@ void ZeroRemoteTensor::allocate(const size_t bytes) {_mem,nullptr};ze_device_mem_alloc_desc_t desc = {ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC, &memory_import, 0, 0};- zeroUtils::throwOnFail("zeMemAllocDevice",- zeMemAllocDevice(_init_structs->getContext(),- &desc,- bytes,- STANDARD_PAGE_SIZE,- _init_structs->getDevice(),- &_data));+ THROW_ON_FAIL_FOR_LEVELZERO("zeMemAllocDevice",+ zeMemAllocDevice(_init_structs->getContext(),+ &desc,+ bytes,+ STANDARD_PAGE_SIZE,+ _init_structs->getDevice(),+ &_data));#else// in the case of Linux platforms memory could be changed after allocation - using zeMemAllocHost for importing// memory@@ -131,8 +133,9 @@ void ZeroRemoteTensor::allocate(const size_t bytes) {ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF,static_cast<int>(reinterpret_cast<intptr_t>(_mem))};ze_host_mem_alloc_desc_t desc = {.pNext = &memory_import};- zeroUtils::throwOnFail("zeMemAllocHost",- zeMemAllocHost(_init_structs->getContext(), &desc, bytes, STANDARD_PAGE_SIZE, &_data));+ THROW_ON_FAIL_FOR_LEVELZERO(+ "zeMemAllocHost",+ zeMemAllocHost(_init_structs->getContext(), &desc, bytes, STANDARD_PAGE_SIZE, &_data));#endifbreak;}diff --git a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cppindex e793dc7378d..2de6cb2d3c4 100644--- a/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_wrappers.cpp@@ -19,8 +19,8 @@ EventPool::EventPool(ze_device_handle_t device_handle,nullptr,ZE_EVENT_POOL_FLAG_HOST_VISIBLE,event_count};- zeroUtils::throwOnFail("zeEventPoolCreate",- zeEventPoolCreate(context, &event_pool_desc, 1, &device_handle, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeEventPoolCreate",+ zeEventPoolCreate(context, &event_pool_desc, 1, &device_handle, &_handle));}EventPool::~EventPool() {auto result = zeEventPoolDestroy(_handle);@@ -32,25 +32,25 @@ EventPool::~EventPool() {Event::Event(const ze_event_pool_handle_t& event_pool, uint32_t event_index, const Config& config): _log("Event", config.get<LOG_LEVEL>()) {ze_event_desc_t event_desc = {ZE_STRUCTURE_TYPE_EVENT_DESC, nullptr, event_index, 0, 0};- zeroUtils::throwOnFail("zeEventCreate", zeEventCreate(event_pool, &event_desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeEventCreate", zeEventCreate(event_pool, &event_desc, &_handle));}void Event::AppendSignalEvent(CommandList& command_list) const {- zeroUtils::throwOnFail("zeCommandListAppendSignalEvent",- zeCommandListAppendSignalEvent(command_list.handle(), _handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendSignalEvent",+ zeCommandListAppendSignalEvent(command_list.handle(), _handle));}void Event::AppendWaitOnEvent(CommandList& command_list) {- zeroUtils::throwOnFail("zeCommandListAppendWaitOnEvents",- zeCommandListAppendWaitOnEvents(command_list.handle(), 1, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendWaitOnEvents",+ zeCommandListAppendWaitOnEvents(command_list.handle(), 1, &_handle));}void Event::AppendEventReset(CommandList& command_list) const {- zeroUtils::throwOnFail("zeCommandListAppendEventReset",- zeCommandListAppendEventReset(command_list.handle(), _handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendEventReset",+ zeCommandListAppendEventReset(command_list.handle(), _handle));}void Event::hostSynchronize() const {- zeroUtils::throwOnFail("zeEventHostSynchronize", zeEventHostSynchronize(_handle, UINT64_MAX));+ THROW_ON_FAIL_FOR_LEVELZERO("zeEventHostSynchronize", zeEventHostSynchronize(_handle, UINT64_MAX));}void Event::reset() const {- zeroUtils::throwOnFail("zeEventHostReset", zeEventHostReset(_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeEventHostReset", zeEventHostReset(_handle));}Event::~Event() {auto result = zeEventDestroy(_handle);@@ -70,42 +70,42 @@ CommandList::CommandList(const ze_device_handle_t& device_handle,_log("CommandList", config.get<LOG_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};- zeroUtils::throwOnFail("zeCommandListCreate", zeCommandListCreate(_context, device_handle, &desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListCreate", zeCommandListCreate(_context, device_handle, &desc, &_handle));if (mtci_is_supported) {ze_mutable_command_id_exp_desc_t mutableCmdIdDesc = {ZE_STRUCTURE_TYPE_MUTABLE_COMMAND_ID_EXP_DESC,nullptr,ZE_MUTABLE_COMMAND_EXP_FLAG_GRAPH_ARGUMENT};- zeroUtils::throwOnFail("zeCommandListGetNextCommandIdExp",- zeCommandListGetNextCommandIdExp(_handle, &mutableCmdIdDesc, &_command_id));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListGetNextCommandIdExp",+ zeCommandListGetNextCommandIdExp(_handle, &mutableCmdIdDesc, &_command_id));}}void CommandList::reset() const {- zeroUtils::throwOnFail("zeCommandListReset", zeCommandListReset(_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListReset", zeCommandListReset(_handle));}void CommandList::appendMemoryCopy(void* dst, const void* src, const std::size_t size) const {- zeroUtils::throwOnFail("zeCommandListAppendMemoryCopy",- zeCommandListAppendMemoryCopy(_handle, dst, src, size, nullptr, 0, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendMemoryCopy",+ zeCommandListAppendMemoryCopy(_handle, dst, src, size, nullptr, 0, nullptr));}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));+ 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);}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));+ 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);}void CommandList::appendNpuTimestamp(uint64_t* timestamp_buff) const {- zeroUtils::throwOnFail("zeCommandListAppendWriteGlobalTimestamp",- zeCommandListAppendWriteGlobalTimestamp(_handle, timestamp_buff, nullptr, 0, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendWriteGlobalTimestamp",+ zeCommandListAppendWriteGlobalTimestamp(_handle, timestamp_buff, nullptr, 0, nullptr));}void CommandList::appendBarrier() const {- zeroUtils::throwOnFail("zeCommandListAppendBarrier", zeCommandListAppendBarrier(_handle, nullptr, 0, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListAppendBarrier", zeCommandListAppendBarrier(_handle, nullptr, 0, nullptr));}void CommandList::close() const {- zeroUtils::throwOnFail("zeCommandListClose", zeCommandListClose(_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListClose", zeCommandListClose(_handle));}CommandList::~CommandList() {auto result = zeCommandListDestroy(_handle);@@ -124,8 +124,8 @@ void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_v&desc,0};- zeroUtils::throwOnFail("zeCommandListUpdateMutableCommandsExp",- zeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListUpdateMutableCommandsExp",+ zeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t));}CommandQueue::CommandQueue(const ze_device_handle_t& device_handle,@@ -148,22 +148,22 @@ CommandQueue::CommandQueue(const ze_device_handle_t& device_handle,OPENVINO_THROW("Turbo is not supported by the current driver");}}- zeroUtils::throwOnFail("zeCommandQueueCreate",- zeCommandQueueCreate(_context, device_handle, &queue_desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueCreate",+ zeCommandQueueCreate(_context, device_handle, &queue_desc, &_handle));}void CommandQueue::executeCommandList(CommandList& command_list) const {- zeroUtils::throwOnFail("zeCommandQueueExecuteCommandLists",- zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, nullptr));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists",+ zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, nullptr));}void CommandQueue::executeCommandList(CommandList& command_list, Fence& fence) const {- zeroUtils::throwOnFail("zeCommandQueueExecuteCommandLists",- zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, fence.handle()));+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandQueueExecuteCommandLists",+ zeCommandQueueExecuteCommandLists(_handle, 1, &command_list._handle, fence.handle()));}void CommandQueue::setWorkloadType(ze_command_queue_workload_type_t workloadType) const {if (_command_queue_npu_dditable_ext.version()) {- zeroUtils::throwOnFail("zeSetWorkloadType",- _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType));+ THROW_ON_FAIL_FOR_LEVELZERO("zeSetWorkloadType",+ _command_queue_npu_dditable_ext.pfnSetWorkloadType(_handle, workloadType));} else {OPENVINO_THROW("The WorkloadType property is not supported by the current Driver Version!");}@@ -178,13 +178,13 @@ CommandQueue::~CommandQueue() {Fence::Fence(const CommandQueue& command_queue, const Config& config) : _log("Fence", config.get<LOG_LEVEL>()) {ze_fence_desc_t fence_desc = {ZE_STRUCTURE_TYPE_FENCE_DESC, nullptr, 0};- zeroUtils::throwOnFail("zeFenceCreate", zeFenceCreate(command_queue.handle(), &fence_desc, &_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeFenceCreate", zeFenceCreate(command_queue.handle(), &fence_desc, &_handle));}void Fence::reset() const {- zeroUtils::throwOnFail("zeFenceReset", zeFenceReset(_handle));+ THROW_ON_FAIL_FOR_LEVELZERO("zeFenceReset", zeFenceReset(_handle));}void Fence::hostSynchronize() const {- zeroUtils::throwOnFail("zeFenceHostSynchronize", zeFenceHostSynchronize(_handle, UINT64_MAX));+ THROW_ON_FAIL_FOR_LEVELZERO("zeFenceHostSynchronize", zeFenceHostSynchronize(_handle, UINT64_MAX));}Fence::~Fence() {auto result = zeFenceDestroy(_handle);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 d681e43fa5b..658f138a72c 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@@ -18,9 +18,6 @@ namespace driverCompilerAdapter {using SerializedIR = std::pair<size_t, std::shared_ptr<uint8_t>>;-#define NotSupportLogHandle(T) \- (std::is_same<T, ze_graph_dditable_ext_1_2_t>::value || std::is_same<T, ze_graph_dditable_ext_1_3_t>::value)-#define NotSupportQuery(T) (std::is_same<T, ze_graph_dditable_ext_1_2_t>::value)// ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy,@@ -186,14 +183,6 @@ private:const uint32_t& flags,ze_graph_handle_t* graph) const;- template <typename T = TableExtension, typename std::enable_if_t<!NotSupportLogHandle(T), bool> = true>- std::string getLatestBuildError() const;-- template <typename T = TableExtension, typename std::enable_if_t<NotSupportLogHandle(T), bool> = true>- std::string getLatestBuildError() const {- return "";- }-private:ze_driver_handle_t _driverHandle = nullptr;ze_device_handle_t _deviceHandle = nullptr;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 8d3afb4aa51..47bc7611d13 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@@ -376,29 +376,15 @@ void LevelZeroCompilerInDriver<TableExtension>::getNativeBinary(ze_graph_dditabl// Get blob size firstauto result = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, nullptr);blob.resize(blobSize);-- OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,- "Failed to compile network. L0 pfnGetNativeBinary get blob size",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- ". ",- getLatestBuildError());+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.",+ result,+ _graphDdiTableExt);// Get blob dataresult = _graphDdiTableExt.pfnGetNativeBinary(graphHandle, &blobSize, blob.data());-- OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,- "Failed to compile network. L0 pfnGetNativeBinary get blob data",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- ". ",- getLatestBuildError());+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob data, Failed to compile network.",+ result,+ _graphDdiTableExt);blobPtr = blob.data();}@@ -412,16 +398,9 @@ void LevelZeroCompilerInDriver<TableExtension>::getNativeBinary(ze_graph_dditablsize_t& blobSize) const {// Get blob ptr and sizeauto result = _graphDdiTableExt.pfnGetNativeBinary2(graphHandle, &blobSize, &blobPtr);-- OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,- "Failed to compile network. L0 pfnGetNativeBinary get blob size",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- ". ",- getLatestBuildError());+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.",+ result,+ _graphDdiTableExt);}template <typename TableExtension>@@ -667,6 +646,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndQuery// Create querynetwork handleze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate(_context, _deviceHandle, &desc, &hGraphQueryNetwork);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("seriazlideIRModelAndQueryNetworkCreateV1", result, _graphDdiTableExt);return result;}@@ -681,14 +661,7 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::queryze_device_graph_properties_t deviceGraphProperties{};auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnDeviceGetGraphProperties",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt);ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr;@@ -729,15 +702,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);-- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 seriazlideIRModelAndQueryNetworkCreateV2",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("seriazlideIRModelAndQueryNetworkCreateV2", result, _graphDdiTableExt);return result;}@@ -752,14 +717,7 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::queryze_device_graph_properties_t deviceGraphProperties{};auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnDeviceGetGraphProperties",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt);ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr;@@ -777,26 +735,14 @@ template <typename T, std::enable_if_t<!NotSupportQuery(T), bool>>std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQueryResultFromSupportedLayers(ze_result_t result,ze_graph_query_network_handle_t& hGraphQueryNetwork) const {- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 getQueryResultFromSupportedLayers",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }-// Get the size of query resultsize_t size = 0;result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr);if (ZE_RESULT_SUCCESS != result) {_graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);- OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get size of query result",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get size of query result",+ result,+ _graphDdiTableExt);}// Get the result data of query@@ -804,23 +750,13 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQuresult = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, supportedLayers.data());if (ZE_RESULT_SUCCESS != result) {_graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);- OPENVINO_THROW("L0 pfnQueryNetworkGetSupportedLayers get result data of query",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get result data of query",+ result,+ _graphDdiTableExt);}result = _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnQueryNetworkDestroy",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkDestroy", result, _graphDdiTableExt);return parseQueryResult(supportedLayers);}@@ -862,8 +798,12 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grapserializedIR.second.get(),buildFlags.c_str()};+ _logger.debug("createGraph - performing pfnCreate");// Create querynetwork handle- return _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph);+ auto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graphDdiTableExt);++ return result;}// For ext version >= 1.5, calling pfnCreate2 api in _graphDdiTableExt@@ -885,14 +825,7 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grap_logger.debug("createGraph - performing pfnCreate2");// Create querynetwork handleauto result = _graphDdiTableExt.pfnCreate2(_context, _deviceHandle, &desc, graph);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnCreate2",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _graphDdiTableExt);return result;}@@ -926,14 +859,6 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndCreat_logger.info("compileIR Using extension version: %s", typeid(TableExtension).name());ze_result_t result = createGraph(format, serializedIR, buildFlags, flags, &graphHandle);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("Failed to create graph. L0 createGraph",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }return result;}@@ -944,30 +869,15 @@ NetworkDescription LevelZeroCompilerInDriver<TableExtension>::compile(const std:ze_device_graph_properties_t deviceGraphProperties{};auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &deviceGraphProperties);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("Failed to compile network. L0 pfnDeviceGetGraphProperties",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties, Failed to compile network.",+ result,+ _graphDdiTableExt);// Graph handle should be used only in scope of compile / parse functions.ze_graph_handle_t graphHandle;result = seriazlideIRModelAndCreateGraph(model, config, deviceGraphProperties, graphHandle);- OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,- "Failed to compile network. L0 createGraph",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- ". ",- getLatestBuildError());-auto networkMeta = getNetworkMeta(graphHandle);networkMeta.name = model->get_friendly_name();@@ -996,14 +906,8 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::parse(const std::vectauto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, &graphHandle);OV_ITT_TASK_NEXT(PARSE_BLOB, "_graphDdiTableExt");- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnCreate",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _graphDdiTableExt);+} else {OPENVINO_THROW("Empty blob");}@@ -1023,15 +927,8 @@ uint32_t LevelZeroCompilerInDriver<TableExtension>::getSupportedOpsetVersion() cze_device_graph_properties_t graphProperties;auto result = _graphDdiTableExt.pfnDeviceGetGraphProperties(_deviceHandle, &graphProperties);+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnDeviceGetGraphProperties", result, _graphDdiTableExt);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnDeviceGetGraphProperties",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }const auto maxOpsetVersion = graphProperties.maxOVOpsetVersionSupported;_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);_logger.debug("getSupportedOpset end");@@ -1102,14 +999,7 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_exstd::vector<IODescriptor>& outputs) const {ze_graph_argument_properties_3_t arg;auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnGetArgumentProperties3",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graphDdiTableExt);switch (arg.type) {case ZE_GRAPH_ARGUMENT_TYPE_INPUT: {@@ -1133,28 +1023,14 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_exstd::vector<IODescriptor>& outputs) const {ze_graph_argument_properties_3_t arg;auto result = graphDdiTableExt.pfnGetArgumentProperties3(graphHandle, index, &arg);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnGetArgumentProperties3",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _graphDdiTableExt);std::optional<ze_graph_argument_metadata_t> optionalMetadata = std::nullopt;if (!isStateInputName(arg.name) && !isStateOutputName(arg.name) && !isShapeTensorName(arg.name)) {ze_graph_argument_metadata_t metadata;result = graphDdiTableExt.pfnGraphGetArgumentMetadata(graphHandle, index, &metadata);- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnGraphGetArgumentMetadata",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGraphGetArgumentMetadata", result, _graphDdiTableExt);optionalMetadata = std::optional(metadata);}@@ -1177,15 +1053,7 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::getNetworkMeta(ze_graze_graph_properties_t graphProperties{};auto result = _graphDdiTableExt.pfnGetProperties(graphHandle, &graphProperties);-- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 pfnGetProperties",- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result));- }+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties", result, _graphDdiTableExt);NetworkMetadata meta;@@ -1201,42 +1069,6 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::getNetworkMeta(ze_grareturn meta;}-template <typename TableExtension>-template <typename T, typename std::enable_if_t<!NotSupportLogHandle(T), bool>>-std::string LevelZeroCompilerInDriver<TableExtension>::getLatestBuildError() const {- _logger.debug("getLatestBuildError start");-- // Get log size- uint32_t size = 0;- // Null graph handle to get erro log- 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!");- return "";- }-- if (size <= 0) {- // The failure will not break normal execution, only warning here- _logger.warning("getLatestBuildError No error log stored in driver when error "- "detected, may not be compiler issue!");- return "";- }-- // Get log content- std::string logContent{};- logContent.resize(size);- 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 "- "content of latest error log!");- return "";- }- _logger.debug("getLatestBuildError end");- return logContent;-}-template class LevelZeroCompilerInDriver<ze_graph_dditable_ext_1_2_t>;template class LevelZeroCompilerInDriver<ze_graph_dditable_ext_1_3_t>;template class LevelZeroCompilerInDriver<ze_graph_dditable_ext_1_4_t>;diff --git a/src/plugins/intel_npu/src/backend/include/zero_utils.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hppsimilarity index 65%rename from src/plugins/intel_npu/src/backend/include/zero_utils.hpprename to src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hppindex 4df4a9c502b..044fd1415c8 100644--- a/src/plugins/intel_npu/src/backend/include/zero_utils.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp@@ -11,40 +11,39 @@#include "intel_npu/config/runtime.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "intel_npu/utils/zero/zero_result.hpp"+#include "zero_types.hpp"namespace intel_npu {namespace zeroUtils {-static inline void throwOnFail(const std::string& step, const ze_result_t result) {- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 ",- step,- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- " - ",- ze_result_to_description(result));+#define THROW_ON_FAIL_FOR_LEVELZERO_EXT(step, result, graph_ddi_table_ext) \+ if (ZE_RESULT_SUCCESS != result) { \+ OPENVINO_THROW("L0 ", \+ step, \+ " result: ", \+ ze_result_to_string(result), \+ ", code 0x", \+ std::hex, \+ uint64_t(result), \+ " - ", \+ ze_result_to_description(result), \+ " . ", \+ intel_npu::zeroUtils::getLatestBuildError(graph_ddi_table_ext)); \}-}-static inline void throwOnFail(const std::string& step, const ze_result_t result, const std::string& hintOnError) {- if (ZE_RESULT_SUCCESS != result) {- OPENVINO_THROW("L0 ",- step,- " result: ",- ze_result_to_string(result),- ", code 0x",- std::hex,- uint64_t(result),- " - ",- ze_result_to_description(result),- ". ",- hintOnError);+#define THROW_ON_FAIL_FOR_LEVELZERO(step, result) \+ if (ZE_RESULT_SUCCESS != result) { \+ OPENVINO_THROW("L0 ", \+ step, \+ " result: ", \+ ze_result_to_string(result), \+ ", code 0x", \+ std::hex, \+ uint64_t(result), \+ " - ", \+ ze_result_to_description(result)); \}-}static inline ze_command_queue_priority_t toZeQueuePriority(const ov::hint::Priority& val) {switch (val) {@@ -215,5 +214,45 @@ static inline uint32_t findGroupOrdinal(return 0;}+static inline std::string getLatestBuildError(ze_graph_dditable_ext_curr_t& _graph_ddi_table_ext) {+ Logger _logger("LevelZeroUtils", Logger::global().level());+ _logger.debug("getLatestBuildError start");++ uint32_t graphDdiExtVersion = _graph_ddi_table_ext.version();+ if (graphDdiExtVersion >= ZE_GRAPH_EXT_VERSION_1_4) {+ // Get log size+ uint32_t size = 0;+ // Null graph handle to get error log+ auto result = _graph_ddi_table_ext.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!");+ return "";+ }++ if (size <= 0) {+ // The failure will not break normal execution, only warning here+ _logger.warning("getLatestBuildError No error log stored in driver when error "+ "detected, may not be compiler issue!");+ return "";+ }++ // Get log content+ std::string logContent{};+ logContent.resize(size);+ result = _graph_ddi_table_ext.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 "+ "content of latest error log!");+ return "";+ }+ _logger.debug("getLatestBuildError end");+ return logContent;+ } else {+ return "";+ }+}+} // namespace zeroUtils} // namespace intel_npu