diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp index dc000b99d7446b..82ababf21c147a 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp @@ -16,7 +16,7 @@ #include "intel_npu/config/config.hpp" #include "intel_npu/utils/logger/logger.hpp" #include "intel_npu/utils/zero/zero_init.hpp" -#include "ze_graph_ext_wrappers_interface.hpp" +#include "ze_graph_ext_wrappers.hpp" namespace intel_npu { @@ -54,7 +54,7 @@ class DriverCompilerAdapter final : public ICompilerAdapter { std::string serializeConfig(const Config& config, ze_graph_compiler_version_info_t compilerVersion) const; std::shared_ptr _zeroInitStruct; - std::shared_ptr _zeGraphExt; + std::shared_ptr _zeGraphExt; ze_device_graph_properties_t _deviceGraphProperties = {}; diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/driver_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/driver_graph.hpp index f7ea940cf9a160..0f426581687f65 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/driver_graph.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/driver_graph.hpp @@ -10,13 +10,13 @@ #include "intel_npu/common/igraph.hpp" #include "intel_npu/utils/zero/zero_init.hpp" -#include "ze_graph_ext_wrappers_interface.hpp" +#include "ze_graph_ext_wrappers.hpp" namespace intel_npu { class DriverGraph final : public IGraph { public: - DriverGraph(const std::shared_ptr& zeGraphExt, + DriverGraph(const std::shared_ptr& zeGraphExt, const std::shared_ptr& zeroInitStruct, ze_graph_handle_t graphHandle, NetworkMetadata metadata, @@ -37,7 +37,7 @@ class DriverGraph final : public IGraph { private: bool release_blob(const Config& config); - std::shared_ptr _zeGraphExt; + std::shared_ptr _zeGraphExt; std::shared_ptr _zeroInitStruct; Logger _logger; diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp index eab8a19627cd1c..8d2616884e7d5f 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp @@ -11,7 +11,7 @@ #include "intel_npu/utils/logger/logger.hpp" #include "intel_npu/utils/zero/zero_init.hpp" #include "openvino/runtime/so_ptr.hpp" -#include "ze_graph_ext_wrappers_interface.hpp" +#include "ze_graph_ext_wrappers.hpp" namespace intel_npu { @@ -28,7 +28,7 @@ class PluginCompilerAdapter final : public ICompilerAdapter { private: std::shared_ptr _zeroInitStruct; - std::shared_ptr _zeGraphExt; + std::shared_ptr _zeGraphExt; ov::SoPtr _compiler; Logger _logger; diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_graph.hpp index 1028112368e67f..2d7d9bfd429e47 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_graph.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_graph.hpp @@ -12,13 +12,13 @@ #include "intel_npu/icompiler.hpp" #include "intel_npu/utils/zero/zero_init.hpp" #include "openvino/runtime/so_ptr.hpp" -#include "ze_graph_ext_wrappers_interface.hpp" +#include "ze_graph_ext_wrappers.hpp" namespace intel_npu { class PluginGraph final : public IGraph { public: - PluginGraph(const std::shared_ptr& zeGraphExt, + PluginGraph(const std::shared_ptr& zeGraphExt, const ov::SoPtr& compiler, const std::shared_ptr& zeroInitStruct, ze_graph_handle_t graphHandle, @@ -38,7 +38,7 @@ class PluginGraph final : public IGraph { ~PluginGraph() override; private: - std::shared_ptr _zeGraphExt; + std::shared_ptr _zeGraphExt; std::shared_ptr _zeroInitStruct; const ov::SoPtr _compiler; diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp index 1bc58b153a48ff..3e8c17ad13db7e 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp +++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp @@ -10,42 +10,19 @@ #include #include +#include "intel_npu/network_metadata.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 "ze_graph_ext_wrappers_interface.hpp" namespace intel_npu { -#define NotSupportQuery(T) (T == ZE_GRAPH_EXT_VERSION_1_2) - -// ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy, -// pfnQueryNetworkGetSupportedLayers) -#define SupportAPIGraphQueryNetworkV1(T) (T == ZE_GRAPH_EXT_VERSION_1_3 || T == ZE_GRAPH_EXT_VERSION_1_4) - -// ext version >= 1.5, support API (pfnCreate2, pfnQueryNetworkCreate2, pfnQueryContextMemory) -#define SupportAPIGraphQueryNetworkV2(T) ((!NotSupportQuery(T) && !SupportAPIGraphQueryNetworkV1(T))) - -// For ext version >= 1.5, pfnCreate2 api is avaible -#define NotSupportGraph2(T) \ - (T == ZE_GRAPH_EXT_VERSION_1_2 || T == ZE_GRAPH_EXT_VERSION_1_3 || T == ZE_GRAPH_EXT_VERSION_1_4) - -// A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to -// "ze_graph_dditable_ext_1_6_t". -// See: E#117498 -#define NotSupportArgumentMetadata(T) \ - (T == ZE_GRAPH_EXT_VERSION_1_2 || T == ZE_GRAPH_EXT_VERSION_1_3 || T == ZE_GRAPH_EXT_VERSION_1_4 || \ - T == ZE_GRAPH_EXT_VERSION_1_5) - -#define UseCopyForNativeBinary(T) \ - (T == ZE_GRAPH_EXT_VERSION_1_2 || T == ZE_GRAPH_EXT_VERSION_1_3 || T == ZE_GRAPH_EXT_VERSION_1_4 || \ - T == ZE_GRAPH_EXT_VERSION_1_5 || T == ZE_GRAPH_EXT_VERSION_1_6) +using SerializedIR = std::pair>; /** * Adapter to use CiD through ZeroAPI */ -template -class ZeGraphExtWrappers final : public ZeGraphExtWrappersInterface { +class ZeGraphExtWrappers { public: ZeGraphExtWrappers(const std::shared_ptr& zeroInitStruct); ZeGraphExtWrappers(const ZeGraphExtWrappers&) = delete; @@ -53,105 +30,40 @@ class ZeGraphExtWrappers final : public ZeGraphExtWrappersInterface { ~ZeGraphExtWrappers(); std::unordered_set queryGraph(std::pair> serializedIR, - const std::string& buildFlags) const override; + const std::string& buildFlags) const; ze_graph_handle_t getGraphHandle(std::pair> serializedIR, const std::string& buildFlags, - const uint32_t& flags) const override; + const uint32_t& flags) const; - ze_graph_handle_t getGraphHandle(const std::vector& network) const override; + ze_graph_handle_t getGraphHandle(const std::vector& network) const; - NetworkMetadata getNetworkMeta(ze_graph_handle_t graphHandle) const override; + NetworkMetadata getNetworkMeta(ze_graph_handle_t graphHandle) const; - _ze_result_t destroyGraph(ze_graph_handle_t graphHandle) override; + _ze_result_t destroyGraph(ze_graph_handle_t graphHandle); void getGraphBinary(ze_graph_handle_t graphHandle, std::vector& blob, const uint8_t*& blobPtr, - size_t& blobSize) const override; + size_t& blobSize) const; - void setGraphArgumentValue(ze_graph_handle_t graphHandle, uint32_t argi_, const void* argv) const override; + void setGraphArgumentValue(ze_graph_handle_t graphHandle, uint32_t argi_, const void* argv) const; - void initializeGraph(ze_graph_handle_t graphHandle, const Config& config) const override; + void initializeGraph(ze_graph_handle_t graphHandle, const Config& config) const; private: - template = true> std::unordered_set getQueryResultFromSupportedLayers( ze_result_t result, ze_graph_query_network_handle_t& hGraphQueryNetwork) const; - template = true> void getMetadata(ze_graph_handle_t graphHandle, uint32_t index, std::vector& inputs, std::vector& outputs) const; - template = true> - void getMetadata(ze_graph_handle_t graphHandle, - uint32_t index, - std::vector& inputs, - std::vector& outputs) const; - - template = true> - void getNativeBinary(ze_graph_handle_t graphHandle, - std::vector& blob, - const uint8_t*& blobPtr, - size_t& blobSize) const; - - template = true> - void getNativeBinary(ze_graph_handle_t graphHandle, - std::vector& /* unusedBlob */, - const uint8_t*& blobPtr, - size_t& blobSize) const; - - template = true> - ze_result_t queryNetworkCreateV2(std::pair> serializedIR, - const std::string& buildFlags, - ze_graph_query_network_handle_t& hGraphQueryNetwork) const; - - // ext version >= 1.5, support API (pfnCreate2, pfnQueryNetworkCreate2, pfnQueryContextMemory) - template = true> - std::unordered_set queryImpl(std::pair> serializedIR, - const std::string& buildFlags) const; - - template = true> - ze_result_t queryNetworkCreateV1(std::pair> serializedIR, - const std::string& buildFlags, - ze_graph_query_network_handle_t& hGraphQueryNetwork) const; - - // ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy, - // pfnQueryNetworkGetSupportedLayers) - template = true> - std::unordered_set queryImpl(std::pair> serializedIR, - const std::string& buildFlags) const; - - // For ext version < 1.3 - template = true> - std::unordered_set queryImpl(std::pair> serializedIR, - const std::string& buildFlags) const; - - template = true> - void createGraph(std::pair> serializedIR, - const std::string& buildFlags, - const uint32_t& flags, - ze_graph_handle_t* graph) const; - - template = true> - void createGraph(std::pair> serializedIR, - const std::string& buildFlags, - const uint32_t& flags, - ze_graph_handle_t* graph) const; - void initialize_graph_through_command_list(ze_graph_handle_t graphHandle, const Config& config) const; std::shared_ptr _zeroInitStruct; + uint32_t _graphExtVersion; Logger _logger; }; diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers_interface.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers_interface.hpp deleted file mode 100644 index ac44f9853e11e3..00000000000000 --- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers_interface.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include "intel_npu/network_metadata.hpp" - -namespace intel_npu { - -using SerializedIR = std::pair>; - -class ZeGraphExtWrappersInterface { -public: - virtual std::unordered_set queryGraph(SerializedIR serializedIR, - const std::string& buildFlags) const = 0; - - virtual ze_graph_handle_t getGraphHandle(SerializedIR serializedIR, - const std::string& buildFlags, - const uint32_t& flags) const = 0; - - virtual ze_graph_handle_t getGraphHandle(const std::vector& network) const = 0; - - virtual NetworkMetadata getNetworkMeta(ze_graph_handle_t graphHandle) const = 0; - - virtual _ze_result_t destroyGraph(ze_graph_handle_t graphHandle) = 0; - - virtual void getGraphBinary(ze_graph_handle_t graphHandle, - std::vector& blob, - const uint8_t*& blobPtr, - size_t& blobSize) const = 0; - - virtual void setGraphArgumentValue(ze_graph_handle_t graphHandle, uint32_t argi_, const void* argv) const = 0; - - virtual void initializeGraph(ze_graph_handle_t graphHandle, const Config& config) const = 0; - - virtual ~ZeGraphExtWrappersInterface() = default; -}; - -} // namespace intel_npu diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp index b4da8a2bcc316b..f819ed73711cf2 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp @@ -155,29 +155,7 @@ DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_4: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_5: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_6: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_7: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_8: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - default: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - } + _zeGraphExt = std::make_shared(_zeroInitStruct); _logger.info("initialize DriverCompilerAdapter complete, using graphExtVersion: %d.%d", ZE_MAJOR_VERSION(graphExtVersion), 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.cpp index 84759bf802f1c1..e1f3990b835e8d 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 @@ -10,7 +10,7 @@ namespace intel_npu { -DriverGraph::DriverGraph(const std::shared_ptr& zeGraphExt, +DriverGraph::DriverGraph(const std::shared_ptr& zeGraphExt, const std::shared_ptr& zeroInitStruct, ze_graph_handle_t graphHandle, NetworkMetadata metadata, diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp index 73dd3817e24812..06d71fd1126c17 100644 --- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp +++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp @@ -70,29 +70,7 @@ PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_4: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_5: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_6: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_7: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - case ZE_GRAPH_EXT_VERSION_1_8: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - default: - _zeGraphExt = std::make_shared>(_zeroInitStruct); - break; - } + _zeGraphExt = std::make_shared(_zeroInitStruct); _logger.info("initialize PluginCompilerAdapter complete, using graphExtVersion: %d.%d", ZE_MAJOR_VERSION(graphExtVersion), 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.cpp index 8f60efd50af75c..c99069a0a9760f 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 @@ -10,7 +10,7 @@ namespace intel_npu { -PluginGraph::PluginGraph(const std::shared_ptr& zeGraphExt, +PluginGraph::PluginGraph(const std::shared_ptr& zeGraphExt, const ov::SoPtr& compiler, const std::shared_ptr& zeroInitStruct, ze_graph_handle_t graphHandle, diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp index fad389ca30e0c7..f6366a2509747b 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 @@ -14,6 +14,25 @@ #include "intel_npu/utils/zero/zero_wrappers.hpp" #include "openvino/core/model.hpp" +#define NotSupportQuery(T) (T <= ZE_GRAPH_EXT_VERSION_1_2) + +// ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy, +// pfnQueryNetworkGetSupportedLayers) +#define SupportAPIGraphQueryNetworkV1(T) (T == ZE_GRAPH_EXT_VERSION_1_3 || T == ZE_GRAPH_EXT_VERSION_1_4) + +// ext version >= 1.5, support API (pfnCreate2, pfnQueryNetworkCreate2, pfnQueryContextMemory) +#define SupportAPIGraphQueryNetworkV2(T) ((!NotSupportQuery(T) && !SupportAPIGraphQueryNetworkV1(T))) + +// For ext version >= 1.5, pfnCreate2 api is avaible +#define NotSupportGraph2(T) (T < ZE_GRAPH_EXT_VERSION_1_5) + +// A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to +// "ze_graph_dditable_ext_1_6_t". +// See: E#117498 +#define NotSupportArgumentMetadata(T) (T < ZE_GRAPH_EXT_VERSION_1_6) + +#define UseCopyForNativeBinary(T) (T < ZE_GRAPH_EXT_VERSION_1_7) + namespace { ov::element::Type_t toOVElementType(const ze_graph_argument_precision_t zeElementType) { @@ -63,19 +82,28 @@ ov::element::Type_t toOVElementType(const ze_graph_argument_precision_t zeElemen namespace intel_npu { -template -ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr& zeroInitStruct) +ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr& zeroInitStruct) : _zeroInitStruct(zeroInitStruct), - _logger("ZeGraphExtWrappers", Logger::global().level()) {} + _graphExtVersion(zeroInitStruct->getGraphDdiTable().version()), + _logger("ZeGraphExtWrappers", Logger::global().level()) { + _logger.info("Graph ext version used by zero wrapper: %d.%d", + ZE_MAJOR_VERSION(_graphExtVersion), + ZE_MINOR_VERSION(_graphExtVersion)); + _logger.debug("capabilities:"); + _logger.debug("-SupportQuery: %d", !NotSupportQuery(_graphExtVersion)); + _logger.debug("-SupportAPIGraphQueryNetworkV1: %d", SupportAPIGraphQueryNetworkV1(_graphExtVersion)); + _logger.debug("-SupportAPIGraphQueryNetworkV2 :%d", SupportAPIGraphQueryNetworkV2(_graphExtVersion)); + _logger.debug("-SupportpfnCreate2 :%d", !NotSupportGraph2(_graphExtVersion)); + _logger.debug("-SupportArgumentMetadata :%d", !NotSupportArgumentMetadata(_graphExtVersion)); + _logger.debug("-UseCopyForNativeBinary :%d", UseCopyForNativeBinary(_graphExtVersion)); +} -template -ZeGraphExtWrappers::~ZeGraphExtWrappers() { - _logger.debug("ZeGraphExtWrappers obj destroyed"); +ZeGraphExtWrappers::~ZeGraphExtWrappers() { + _logger.debug("Obj destroyed"); } -template -_ze_result_t ZeGraphExtWrappers::destroyGraph(ze_graph_handle_t graphHandle) { - _logger.debug("destroyGraph - pfnDestroy graphHandle"); +_ze_result_t ZeGraphExtWrappers::destroyGraph(ze_graph_handle_t graphHandle) { + _logger.debug("destroyGraph - perfrom pfnDestroy"); auto result = _zeroInitStruct->getGraphDdiTable().pfnDestroy(graphHandle); if (ZE_RESULT_SUCCESS != result) { @@ -87,73 +115,62 @@ _ze_result_t ZeGraphExtWrappers::destroyGraph(ze_graph_handle_t return result; } -template -template > -void ZeGraphExtWrappers::getNativeBinary(ze_graph_handle_t graphHandle, - std::vector& blob, - const uint8_t*& blobPtr, - size_t& blobSize) const { - // Get blob size first - auto result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary(graphHandle, &blobSize, nullptr); - blob.resize(blobSize); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", - result, - _zeroInitStruct->getGraphDdiTable()); - - // Get blob data - result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary(graphHandle, &blobSize, blob.data()); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob data, Failed to compile network.", - result, - _zeroInitStruct->getGraphDdiTable()); - - blobPtr = blob.data(); -} - -template -template > -void ZeGraphExtWrappers::getNativeBinary(ze_graph_handle_t graphHandle, - std::vector& /* unusedBlob */, - const uint8_t*& blobPtr, - size_t& blobSize) const { - // Get blob ptr and size - auto result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary2(graphHandle, &blobSize, &blobPtr); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", - result, - _zeroInitStruct->getGraphDdiTable()); -} - -template -void ZeGraphExtWrappers::getGraphBinary(ze_graph_handle_t graphHandle, - std::vector& blob, - const uint8_t*& blobPtr, - size_t& blobSize) const { +void ZeGraphExtWrappers::getGraphBinary(ze_graph_handle_t graphHandle, + std::vector& blob, + const uint8_t*& blobPtr, + size_t& blobSize) const { if (graphHandle == nullptr) { OPENVINO_THROW("Graph handle is null"); } - _logger.info("ZeGraphExtWrappers getGraphBinary get blob from graphHandle"); - - getNativeBinary(graphHandle, blob, blobPtr, blobSize); + _logger.debug("getGraphBinary - get blob from graphHandle"); + + if (UseCopyForNativeBinary(_graphExtVersion)) { + // Get blob size first + _logger.debug("getGraphBinary - perfrom pfnGetNativeBinary to get size"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary(graphHandle, &blobSize, nullptr); + blob.resize(blobSize); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", + result, + _zeroInitStruct->getGraphDdiTable()); + + // Get blob data + _logger.debug("getGraphBinary - perfrom pfnGetNativeBinary to get data"); + result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary(graphHandle, &blobSize, blob.data()); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob data, Failed to compile network.", + result, + _zeroInitStruct->getGraphDdiTable()); + + blobPtr = blob.data(); + } else { + // Get blob ptr and size + _logger.debug("getGraphBinary - perfrom pfnGetNativeBinary2 to get size and data"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnGetNativeBinary2(graphHandle, &blobSize, &blobPtr); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetNativeBinary get blob size, Failed to compile network.", + result, + _zeroInitStruct->getGraphDdiTable()); + } } -template -void ZeGraphExtWrappers::setGraphArgumentValue(ze_graph_handle_t graphHandle, - uint32_t argi, - const void* argv) const { +void ZeGraphExtWrappers::setGraphArgumentValue(ze_graph_handle_t graphHandle, uint32_t argi, const void* argv) const { + _logger.debug("setGraphArgumentValue - perform pfnSetArgumentValue"); auto result = _zeroInitStruct->getGraphDdiTable().pfnSetArgumentValue(graphHandle, argi, argv); THROW_ON_FAIL_FOR_LEVELZERO_EXT("zeGraphSetArgumentValue", result, _zeroInitStruct->getGraphDdiTable()); } -template -void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graphHandle, const Config& config) const { +void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graphHandle, const Config& config) const { if (_zeroInitStruct->getGraphDdiTable().version() < ZE_GRAPH_EXT_VERSION_1_8) { + _logger.debug("Use initialize_graph_through_command_list for ext version smaller than 1.8"); initialize_graph_through_command_list(graphHandle, config); } else { + _logger.debug("Initialize graph based on graph properties for ext version larger than 1.8"); ze_graph_properties_2_t properties = {}; properties.stype = ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES; + _logger.debug("initializeGraph - perfrom pfnGetProperties2"); _zeroInitStruct->getGraphDdiTable().pfnGetProperties2(graphHandle, &properties); if (properties.initStageRequired & ZE_GRAPH_STAGE_INITIALIZE) { + _logger.debug("initializeGraph - perfrom pfnGraphInitialize"); _zeroInitStruct->getGraphDdiTable().pfnGraphInitialize(graphHandle); } @@ -163,32 +180,31 @@ void ZeGraphExtWrappers::initializeGraph(ze_graph_handle_t graph } } -template -void ZeGraphExtWrappers::initialize_graph_through_command_list(ze_graph_handle_t graphHandle, - const Config& config) const { +void ZeGraphExtWrappers::initialize_graph_through_command_list(ze_graph_handle_t graphHandle, + const Config& config) const { ze_device_properties_t deviceProperties = {}; deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES; THROW_ON_FAIL_FOR_LEVELZERO("zeDeviceGetProperties", zeDeviceGetProperties(_zeroInitStruct->getDevice(), &deviceProperties)); auto groupOrdinal = zeroUtils::findGroupOrdinal(_zeroInitStruct->getDevice(), deviceProperties); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list init start - create graph_command_list"); + _logger.debug("initialize_graph_through_command_list init start - create graph_command_list"); CommandList graph_command_list(_zeroInitStruct, groupOrdinal); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - create graph_command_queue"); + _logger.debug("initialize_graph_through_command_list - create graph_command_queue"); CommandQueue graph_command_queue(_zeroInitStruct, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, groupOrdinal, false); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - create fence"); + _logger.debug("initialize_graph_through_command_list - create fence"); Fence fence(graph_command_queue); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - performing appendGraphInitialize"); + _logger.debug("initialize_graph_through_command_list - performing appendGraphInitialize"); graph_command_list.appendGraphInitialize(graphHandle); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - closing graph command list"); + _logger.debug("initialize_graph_through_command_list - closing graph command list"); graph_command_list.close(); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - performing executeCommandList"); + _logger.debug("initialize_graph_through_command_list - performing executeCommandList"); graph_command_queue.executeCommandList(graph_command_list, fence); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - performing hostSynchronize"); + _logger.debug("initialize_graph_through_command_list - performing hostSynchronize"); fence.hostSynchronize(); - _logger.debug("ZeGraphExtWrappers::initialize_graph_through_command_list - hostSynchronize completed"); + _logger.debug("initialize_graph_through_command_list - hostSynchronize completed"); } // Parse the result string of query from foramt to unordered_set of string @@ -210,102 +226,17 @@ static std::unordered_set parseQueryResult(std::vector& data) return result; } -// For ext version < 1.3, query is unsupported, return empty result and add debug log here -template -template > -std::unordered_set ZeGraphExtWrappers::queryImpl( - std::pair>, - const std::string&) const { - _logger.info("queryImpl - Driver version is less than 1.3, queryNetwork is unsupported."); - return std::unordered_set(); -} - -// For ext version == 1.3 && == 1.4 -template -template > -ze_result_t ZeGraphExtWrappers::queryNetworkCreateV1( - std::pair> serializedIR, - const std::string& buildFlags, - ze_graph_query_network_handle_t& hGraphQueryNetwork) const { - ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str()}; - - // Create querynetwork handle - ze_result_t result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &hGraphQueryNetwork); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("queryNetworkCreateV1", result, _zeroInitStruct->getGraphDdiTable()); - - return result; -} - -// For ext version == 1.3 && == 1.4, query is supported, calling querynetwork api in _zeroInitStruct->getGraphDdiTable() -template -template > -std::unordered_set ZeGraphExtWrappers::queryImpl( - std::pair> serializedIR, - const std::string& buildFlags) const { - _logger.info("queryImpl - Calling queryNetwork of 1.3 version."); - - ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; - - auto result = queryNetworkCreateV1(std::move(serializedIR), buildFlags, hGraphQueryNetwork); - - return getQueryResultFromSupportedLayers(result, hGraphQueryNetwork); -} - -// For ext version >= 1.5 -template -template > -ze_result_t ZeGraphExtWrappers::queryNetworkCreateV2( - std::pair> serializedIR, - const std::string& buildFlags, - ze_graph_query_network_handle_t& hGraphQueryNetwork) const { - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - ZE_GRAPH_FLAG_NONE}; - - // Create querynetwork handle - _logger.debug("queryNetworkCreateV2 - performing pfnQueryNetworkCreate2"); - ze_result_t result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - &hGraphQueryNetwork); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("queryNetworkCreateV2", result, _zeroInitStruct->getGraphDdiTable()); - - return result; -} - -// For ext version >= 1.5 -template -template > -std::unordered_set ZeGraphExtWrappers::queryImpl( - std::pair> serializedIR, - const std::string& buildFlags) const { - _logger.debug("queryImpl - Calling queryNetwork of 1.5 version."); - - ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; - - auto result = queryNetworkCreateV2(std::move(serializedIR), buildFlags, hGraphQueryNetwork); - - return getQueryResultFromSupportedLayers(result, hGraphQueryNetwork); -} - -template -template > -std::unordered_set ZeGraphExtWrappers::getQueryResultFromSupportedLayers( +std::unordered_set ZeGraphExtWrappers::getQueryResultFromSupportedLayers( ze_result_t result, ze_graph_query_network_handle_t& hGraphQueryNetwork) const { + if (NotSupportQuery(_graphExtVersion)) { + OPENVINO_THROW("pfnQueryNetworkGetSupportedLayers not supported for ", + ZE_MAJOR_VERSION(_graphExtVersion), + ".", + ZE_MINOR_VERSION(_graphExtVersion)); + } // Get the size of query result + _logger.debug("getQueryResultFromSupportLayers - perfrom pfnQueryNetworkGetSupportedLayers to get size"); size_t size = 0; result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkGetSupportedLayers get size of query result", @@ -313,6 +244,7 @@ std::unordered_set ZeGraphExtWrappers::getQueryResu _zeroInitStruct->getGraphDdiTable()); // Get the result data of query + _logger.debug("getQueryResultFromSupportLayers - perfrom pfnQueryNetworkGetSupportedLayers to get data"); std::vector supportedLayers(size); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, @@ -321,80 +253,117 @@ std::unordered_set ZeGraphExtWrappers::getQueryResu result, _zeroInitStruct->getGraphDdiTable()); + _logger.debug("getQueryResultFromSupportLayers - perfrom pfnQueryNetworkDestroy"); result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkDestroy(hGraphQueryNetwork); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkDestroy", result, _zeroInitStruct->getGraphDdiTable()); return parseQueryResult(supportedLayers); } -template -std::unordered_set ZeGraphExtWrappers::queryGraph( - std::pair> serializedIR, - const std::string& buildFlags) const { - return queryImpl(std::move(serializedIR), buildFlags); -} - -// For ext version <1.5, calling pfnCreate api in _zeroInitStruct->getGraphDdiTable() -template -template > -void ZeGraphExtWrappers::createGraph(std::pair> serializedIR, - const std::string& buildFlags, - const uint32_t& /*flags*/, - ze_graph_handle_t* graph) const { - ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str()}; - - _logger.debug("createGraph - performing pfnCreate"); - // Create querynetwork handle - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - graph); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); +std::unordered_set ZeGraphExtWrappers::queryGraph(std::pair> serializedIR, + const std::string& buildFlags) const { + // ext version >= 1.5, support API (pfnCreate2, pfnQueryNetworkCreate2, pfnQueryContextMemory) + // ext version == 1.3 && 1.4, support API (pfnQueryNetworkCreate, pfnQueryNetworkDestroy, + // pfnQueryNetworkGetSupportedLayers) + // For ext version < 1.3, query is not supported + ze_result_t result = ZE_RESULT_SUCCESS; + if (NotSupportQuery(_graphExtVersion)) { + // For ext version < 1.3, query is unsupported, return empty result and add debug log here + _logger.warning("queryGraph - Driver version is less than 1.3, queryNetwork is unsupported."); + return std::unordered_set(); + } else if (SupportAPIGraphQueryNetworkV1(_graphExtVersion)) { + // For ext version == 1.3 && == 1.4, query is supported, calling querynetwork api in + // _zeroInitStruct->getGraphDdiTable() + ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; + + // For ext version == 1.3 && == 1.4 + ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str()}; + + // Create querynetwork handle + _logger.debug("For ext of 1.3 and 1.4 - perform pfnQueryNetworkCreate"); + result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate", result, _zeroInitStruct->getGraphDdiTable()); + + return getQueryResultFromSupportedLayers(result, hGraphQueryNetwork); + } else if (SupportAPIGraphQueryNetworkV2(_graphExtVersion)) { + // For ext version >= 1.5 + ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr; + + // For ext version >= 1.5 + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + ZE_GRAPH_FLAG_NONE}; + + // Create querynetwork handle + _logger.debug("For ext larger than 1.4 - perform pfnQueryNetworkCreate2"); + result = _zeroInitStruct->getGraphDdiTable().pfnQueryNetworkCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &hGraphQueryNetwork); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryNetworkCreate2", result, _zeroInitStruct->getGraphDdiTable()); + + return getQueryResultFromSupportedLayers(result, hGraphQueryNetwork); + } + _logger.warning("queryGraph - Driver version is %d.%d, queryNetwork is unsupported.", + ZE_MAJOR_VERSION(_graphExtVersion), + ZE_MINOR_VERSION(_graphExtVersion)); + return std::unordered_set(); } -// For ext version >= 1.5, calling pfnCreate2 api in _zeroInitStruct->getGraphDdiTable() -template -template > -void ZeGraphExtWrappers::createGraph(std::pair> serializedIR, +ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle(std::pair> serializedIR, const std::string& buildFlags, - const uint32_t& flags, - ze_graph_handle_t* graph) const { - ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, - nullptr, - ZE_GRAPH_FORMAT_NGRAPH_LITE, - serializedIR.first, - serializedIR.second.get(), - buildFlags.c_str(), - flags}; - - _logger.debug("createGraph - performing pfnCreate2"); - // Create querynetwork handle - auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), - _zeroInitStruct->getDevice(), - &desc, - graph); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); -} - -template -ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle( - std::pair> serializedIR, - const std::string& buildFlags, - const uint32_t& flags) const { + const uint32_t& flags) const { ze_graph_handle_t graphHandle; - - createGraph(std::move(serializedIR), buildFlags, flags, &graphHandle); - + if (NotSupportGraph2(_graphExtVersion)) { + // For ext version <1.5, calling pfnCreate api in _zeroInitStruct->getGraphDdiTable() + ze_graph_desc_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str()}; + + _logger.debug("getGraphHandle - perform pfnCreate"); + // Create querynetwork handle + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate", result, _zeroInitStruct->getGraphDdiTable()); + } else { + // For ext version >= 1.5, calling pfnCreate2 api in _zeroInitStruct->getGraphDdiTable() + ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES, + nullptr, + ZE_GRAPH_FORMAT_NGRAPH_LITE, + serializedIR.first, + serializedIR.second.get(), + buildFlags.c_str(), + flags}; + + _logger.debug("getGraphHandle - perform pfnCreate2"); + // Create querynetwork handle + auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate2(_zeroInitStruct->getContext(), + _zeroInitStruct->getDevice(), + &desc, + &graphHandle); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnCreate2", result, _zeroInitStruct->getGraphDdiTable()); + } return graphHandle; } -template -ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle(const std::vector& network) const { +ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle(const std::vector& network) const { ze_graph_handle_t graphHandle; if (network.empty()) { @@ -408,6 +377,7 @@ ze_graph_handle_t ZeGraphExtWrappers::getGraphHandle(const std:: network.data(), nullptr}; + _logger.debug("getGraphHandle - perform pfnCreate"); auto result = _zeroInitStruct->getGraphDdiTable().pfnCreate(_zeroInitStruct->getContext(), _zeroInitStruct->getDevice(), &desc, @@ -473,87 +443,74 @@ static IODescriptor getIODescriptor(const ze_graph_argument_properties_3_t& arg, metadata.has_value() ? std::optional(shapeFromIRModel) : std::nullopt}; } -template -template > -void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle, - uint32_t index, - std::vector& inputs, - std::vector& outputs) const { - ze_graph_argument_properties_3_t arg; - auto result = _zeroInitStruct->getGraphDdiTable().pfnGetArgumentProperties3(graphHandle, index, &arg); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _zeroInitStruct->getGraphDdiTable()); - - switch (arg.type) { - case ZE_GRAPH_ARGUMENT_TYPE_INPUT: { - inputs.push_back(getIODescriptor(arg, std::nullopt)); - } break; - case ZE_GRAPH_ARGUMENT_TYPE_OUTPUT: { - outputs.push_back(getIODescriptor(arg, std::nullopt)); - } break; - default: { - OPENVINO_THROW("Invalid ze_graph_argument_type_t found in ze_graph_argument_properties_3_t object: ", arg.type); - } - } -} - -template -template > -void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle, - uint32_t index, - std::vector& inputs, - std::vector& outputs) const { - ze_graph_argument_properties_3_t arg; - auto result = _zeroInitStruct->getGraphDdiTable().pfnGetArgumentProperties3(graphHandle, index, &arg); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _zeroInitStruct->getGraphDdiTable()); +void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle, + uint32_t index, + std::vector& inputs, + std::vector& outputs) const { + if (NotSupportArgumentMetadata(_graphExtVersion)) { + ze_graph_argument_properties_3_t arg; + _logger.debug("getMetadata - perfrom pfnGetArgumentProperties3"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnGetArgumentProperties3(graphHandle, index, &arg); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _zeroInitStruct->getGraphDdiTable()); + + switch (arg.type) { + case ZE_GRAPH_ARGUMENT_TYPE_INPUT: { + inputs.push_back(getIODescriptor(arg, std::nullopt)); + } break; + case ZE_GRAPH_ARGUMENT_TYPE_OUTPUT: { + outputs.push_back(getIODescriptor(arg, std::nullopt)); + } break; + default: { + OPENVINO_THROW("Invalid ze_graph_argument_type_t found in ze_graph_argument_properties_3_t object: ", + arg.type); + } + } + } else { + ze_graph_argument_properties_3_t arg; + _logger.debug("getMetadata - perfrom pfnGetArgumentProperties3"); + auto result = _zeroInitStruct->getGraphDdiTable().pfnGetArgumentProperties3(graphHandle, index, &arg); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetArgumentProperties3", result, _zeroInitStruct->getGraphDdiTable()); - std::optional optionalMetadata = std::nullopt; + std::optional optionalMetadata = std::nullopt; - if (!isStateInputName(arg.name) && !isStateOutputName(arg.name) && !isShapeTensorName(arg.name)) { - ze_graph_argument_metadata_t metadata; - result = _zeroInitStruct->getGraphDdiTable().pfnGraphGetArgumentMetadata(graphHandle, index, &metadata); - THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGraphGetArgumentMetadata", result, _zeroInitStruct->getGraphDdiTable()); + if (!isStateInputName(arg.name) && !isStateOutputName(arg.name) && !isShapeTensorName(arg.name)) { + _logger.debug("getMetadata - perfrom pfnGetArgumentMetadata"); + ze_graph_argument_metadata_t metadata; + result = _zeroInitStruct->getGraphDdiTable().pfnGraphGetArgumentMetadata(graphHandle, index, &metadata); + THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGraphGetArgumentMetadata", result, _zeroInitStruct->getGraphDdiTable()); - optionalMetadata = std::optional(metadata); - } + optionalMetadata = std::optional(metadata); + } - switch (arg.type) { - case ZE_GRAPH_ARGUMENT_TYPE_INPUT: { - inputs.push_back(getIODescriptor(arg, optionalMetadata)); - } break; - case ZE_GRAPH_ARGUMENT_TYPE_OUTPUT: { - outputs.push_back(getIODescriptor(arg, optionalMetadata)); - } break; - default: { - OPENVINO_THROW("Invalid ze_graph_argument_type_t found in ze_graph_argument_properties_3_t object: ", arg.type); - } + switch (arg.type) { + case ZE_GRAPH_ARGUMENT_TYPE_INPUT: { + inputs.push_back(getIODescriptor(arg, optionalMetadata)); + } break; + case ZE_GRAPH_ARGUMENT_TYPE_OUTPUT: { + outputs.push_back(getIODescriptor(arg, optionalMetadata)); + } break; + default: { + OPENVINO_THROW("Invalid ze_graph_argument_type_t found in ze_graph_argument_properties_3_t object: ", + arg.type); + } + } } } -template -NetworkMetadata ZeGraphExtWrappers::getNetworkMeta(ze_graph_handle_t graphHandle) const { +NetworkMetadata ZeGraphExtWrappers::getNetworkMeta(ze_graph_handle_t graphHandle) const { ze_graph_properties_t graphProperties{}; + _logger.debug("getNetworkMeta - perfrom pfnGetProperties"); auto result = _zeroInitStruct->getGraphDdiTable().pfnGetProperties(graphHandle, &graphProperties); THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnGetProperties", result, _zeroInitStruct->getGraphDdiTable()); - NetworkMetadata meta; - for (uint32_t index = 0; index < graphProperties.numGraphArgs; ++index) { getMetadata(graphHandle, index, meta.inputs, meta.outputs); } // TODO: support this information in CiD [track: E#33479] meta.numStreams = 1; meta.bindRelatedDescriptors(); - return meta; } -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; -template class ZeGraphExtWrappers; - } // namespace intel_npu diff --git a/src/plugins/intel_npu/thirdparty/level-zero-ext b/src/plugins/intel_npu/thirdparty/level-zero-ext index a6487cc2c5da9a..a63155ae4e64fe 160000 --- a/src/plugins/intel_npu/thirdparty/level-zero-ext +++ b/src/plugins/intel_npu/thirdparty/level-zero-ext @@ -1 +1 @@ -Subproject commit a6487cc2c5da9aa13db9e005a320a1b6a0ee5919 +Subproject commit a63155ae4e64feaaa6931f4696c2e2e699063875