Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Refactor serializedIr methods (#34283)

Bogdan Pereanu7ec9db4ccf53
diff --git a/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
index eb2142bf2a2..bd074cca224 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_dynamic_pipeline.cpp
@@ -366,7 +366,7 @@ std::vector<ov::ProfilingInfo> DynamicPipeline::get_profiling_info() const {
}
_logger.debug("InferRequest::get_profiling_info complete with compiler->process_profiling_output().");
- return _graph->process_profiling_output(_profiling_query->getData<uint8_t>(), _config);
+ return _graph->process_profiling_output(_profiling_query->getData<uint8_t>());
}
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
index de219c91420..5ae703179b2 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
@@ -358,7 +358,7 @@ std::vector<ov::ProfilingInfo> Pipeline::get_profiling_info() const {
// For plugin compiler retreive raw profiling data from backend and delegate
// processing to the compiler
_logger.debug("InferRequest::get_profiling_info complete with compiler->process_profiling_output().");
- return _graph->process_profiling_output(_profiling_query->getData<uint8_t>(), _config);
+ return _graph->process_profiling_output(_profiling_query->getData<uint8_t>());
} else {
_logger.debug("InferRequest::get_profiling_info complete with _profiling_query.getLayerStatistics().");
return _profiling_query->getLayerStatistics();
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
index dc5c1f0304f..8133c8feaad 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
@@ -8,6 +8,7 @@
#include <mutex>
#include <vector>
+#include "intel_npu/common/filtered_config.hpp"
#include "intel_npu/network_metadata.hpp"
#include "intel_npu/utils/zero/zero_wrappers.hpp"
#include "openvino/runtime/itensor.hpp"
@@ -30,15 +31,14 @@ public:
*/
virtual std::pair<uint64_t, std::optional<std::vector<uint64_t>>> export_blob(std::ostream& stream) const;
- virtual std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
- const Config& config) const;
+ virtual std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData) const;
virtual void set_argument_value(uint32_t id, const void* data) const;
virtual void set_argument_value_with_strides(uint32_t id,
const void* data,
const std::vector<size_t>& strides) const;
- virtual void initialize(const Config& config);
+ virtual void initialize(const FilteredConfig& config);
virtual ~IGraph() = default;
diff --git a/src/plugins/intel_npu/src/common/src/igraph.cpp b/src/plugins/intel_npu/src/common/src/igraph.cpp
index 034d82ee140..918a3821b3f 100644
--- a/src/plugins/intel_npu/src/common/src/igraph.cpp
+++ b/src/plugins/intel_npu/src/common/src/igraph.cpp
@@ -12,7 +12,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> IGraph::export_blob(st
OPENVINO_THROW("export_blob not implemented");
}
-std::vector<ov::ProfilingInfo> IGraph::process_profiling_output(const std::vector<uint8_t>&, const Config&) const {
+std::vector<ov::ProfilingInfo> IGraph::process_profiling_output(const std::vector<uint8_t>&) const {
OPENVINO_THROW("process_profiling_output not implemented");
}
@@ -24,7 +24,7 @@ void IGraph::set_argument_value_with_strides(uint32_t, const void*, const std::v
OPENVINO_THROW("set_argument_value_with_strides not implemented");
}
-void IGraph::initialize(const Config&) {
+void IGraph::initialize(const FilteredConfig&) {
OPENVINO_THROW("initialize not implemented");
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
index 3a7654f5cbe..1cc676acd17 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp
@@ -28,7 +28,7 @@ public:
* including config options related to compilation
* @return a shared pointer on an object implementing NetworkDescription interface
*/
- NetworkDescription compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const;
+ NetworkDescription compile(const std::shared_ptr<const ov::Model>& model, const FilteredConfig& config) const;
/**
* @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in
@@ -37,7 +37,7 @@ public:
* part.
*/
std::vector<std::shared_ptr<NetworkDescription>> compileWsOneShot(const std::shared_ptr<ov::Model>& model,
- const Config& config) const;
+ const FilteredConfig& config) const;
/**
* @brief Sequential compilation of Init(s) and Main
*
@@ -53,7 +53,7 @@ public:
* Plugin does not know total numbers of Init schedules
*/
NetworkDescription compileWsIterative(const std::shared_ptr<ov::Model>& model,
- const Config& config,
+ const FilteredConfig& config,
size_t callNumber) const;
/**
* @brief Returns information about supported layers of the network passed
@@ -62,7 +62,7 @@ public:
* including config options related to compilation
* @returns SupportedOpsMap structure with information about supported layers
*/
- ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const;
+ ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const FilteredConfig& config) const;
/**
* @brief Parses already compiled network to extract meta information:
@@ -73,7 +73,7 @@ public:
* since the network is already compiled
* @return a shared pointer on an object implementing NetworkDescription interface
*/
- NetworkMetadata parse(const std::vector<uint8_t>& network, const Config& config) const;
+ NetworkMetadata parse(const std::vector<uint8_t>& network, const FilteredConfig& config) const;
/**
* @brief Returns the compiler version
@@ -84,8 +84,7 @@ public:
uint32_t get_version() const;
std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
- const std::vector<uint8_t>& network,
- const intel_npu::Config& config) const;
+ const std::vector<uint8_t>& network) const;
bool get_supported_options(std::vector<char>& options) const;
@@ -100,7 +99,7 @@ private:
* @note Storing the "WeightlessCacheAttribute" is necessary if the "weights separation" flow is being used.
*/
NetworkDescription compile(const std::shared_ptr<const ov::Model>& model,
- const Config& config,
+ const FilteredConfig& config,
const bool storeWeightlessCacheAttributeFlag) const;
vcl_log_handle_t _logHandle = nullptr;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
index b0e8f4501a1..d95a5b1e1d1 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/custom_stream_buffer.hpp
@@ -7,7 +7,7 @@
#include <algorithm>
#include <streambuf>
-namespace intel_npu::driver_compiler_utils {
+namespace intel_npu::compiler_utils {
/**
* @brief Counter stream buffer, just counts the written bytes.
@@ -84,4 +84,4 @@ private:
OutputIt writeIt;
};
-} // namespace intel_npu::driver_compiler_utils
+} // namespace intel_npu::compiler_utils
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 a0e76ea5ed3..a37733d0fb5 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
@@ -10,7 +10,6 @@
#include "intel_npu/config/config.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
-#include "vcl_serializer.hpp"
#include "ze_graph_ext_wrappers.hpp"
namespace intel_npu {
@@ -40,6 +39,10 @@ public:
uint32_t get_version() const override;
private:
+ bool isCompilerOptionSupported(const FilteredConfig& config,
+ const ze_graph_compiler_version_info_t& compilerVersion,
+ const std::string& optionName) const;
+
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp
index 5eeb3331de0..e375b9ce714 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp
@@ -108,13 +108,12 @@ public:
DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,
std::optional<ov::Tensor> blob,
bool blobAllocatedByPlugin,
- const Config& config,
+ const FilteredConfig& config,
const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr});
std::pair<uint64_t, std::optional<std::vector<uint64_t>>> export_blob(std::ostream& stream) const override;
- std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
- const Config& config) const override;
+ std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData) const override;
void set_argument_value(uint32_t argi, const void* argv) const override;
@@ -124,7 +123,7 @@ public:
ze_graph_handle_t get_handle() const override;
- void initialize(const Config& config) override;
+ void initialize(const FilteredConfig& config) override;
~DynamicGraph() override;
@@ -163,7 +162,7 @@ public:
std::optional<bool> is_profiling_blob() const override;
private:
- bool release_blob(const Config& config);
+ bool release_blob(const FilteredConfig& config);
std::optional<size_t> determine_batch_size();
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
index 20c35acac62..35cfedfad47 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
@@ -23,22 +23,21 @@ public:
const GraphDescriptor& graphDesc,
NetworkMetadata metadata,
std::optional<ov::Tensor> blob,
- const Config& config,
+ const FilteredConfig& config,
const bool blobIsPersistent = false,
const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr},
const bool calledFromWeightlessGraph = false);
std::pair<uint64_t, std::optional<std::vector<uint64_t>>> export_blob(std::ostream& stream) const override;
- std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
- const Config& config) const override;
+ std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData) const override;
void set_argument_value(uint32_t id, const void* data) const override;
void set_argument_value_with_strides(uint32_t id,
const void* data,
const std::vector<size_t>& strides) const override;
- void initialize(const Config& config) override;
+ void initialize(const FilteredConfig& config) override;
const NetworkMetadata& get_metadata() const override;
ze_graph_handle_t get_handle() const override;
@@ -66,7 +65,7 @@ public:
~Graph() override;
protected:
- bool release_blob(const Config& config);
+ bool release_blob(const FilteredConfig& config);
std::optional<size_t> determine_batch_size();
std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/vcl_serializer.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
similarity index 84%
rename from src/plugins/intel_npu/src/compiler_adapter/include/vcl_serializer.hpp
rename to src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
index ccf48bbbc0a..cfced7b6532 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/vcl_serializer.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp
@@ -5,14 +5,14 @@
#pragma once
#include <ze_graph_ext.h>
+#include <functional>
#include <iostream>
#include <string>
-#include "intel_npu/config/config.hpp"
+#include "intel_npu/common/filtered_config.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "openvino/core/model.hpp"
#include "openvino/pass/manager.hpp"
-#include "ze_graph_ext.h"
namespace intel_npu {
@@ -23,10 +23,10 @@ struct SerializedIR {
};
/**
- * @brief Contain all required transformation on OpenVINO model in case for external compiler usage and
- * providing forward compatibility (OV model with opset N+M, external compiler with opset N)
+ * @brief Contain all required transformation on OpenVINO model and providing forward compatibility (OV model with opset
+ * N+M, external compiler with opset N)
*/
-namespace driver_compiler_utils {
+namespace compiler_utils {
/**
* @brief Serializes the model using a format supported by the "VCL" interface.
@@ -65,9 +65,9 @@ SerializedIR serializeIR(const std::shared_ptr<const ov::Model>& model,
*/
std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const bool useIndices);
-std::string serializeConfig(const Config& config,
- ze_graph_compiler_version_info_t compilerVersion,
- bool turboSupported = false);
+std::string serializeConfig(const FilteredConfig& config,
+ const ze_graph_compiler_version_info_t& compilerVersion,
+ const std::function<bool(const std::string&)>& isOptionSupportedByCompiler);
-} // namespace driver_compiler_utils
+} // namespace compiler_utils
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp
index c6d6d516480..3d69d72bedf 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp
@@ -31,7 +31,7 @@ public:
std::vector<NetworkMetadata> initMetadata,
std::optional<std::vector<ov::Tensor>> initBlobs,
std::shared_ptr<const ov::Model>&& model,
- const Config& config,
+ const FilteredConfig& config,
const bool blobIsPersistent = false,
const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr});
@@ -44,7 +44,7 @@ public:
* @brief The same operations performed within "Graph::initialize", but for all handles. In addition to this, the
* init schedules are run and the result of this is set as inputs to the main compiled model.
*/
- void initialize(const Config& config) override;
+ void initialize(const FilteredConfig& config) override;
// TODO: public for multi-threaded execution
struct InputData {
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 bbc27a55936..04abd6de88c 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
@@ -7,10 +7,16 @@
#include <ze_api.h>
#include <ze_graph_ext.h>
+#include <memory>
+#include <optional>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
#include "intel_npu/network_metadata.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
-#include "vcl_serializer.hpp"
+#include "model_serializer.hpp"
namespace intel_npu {
@@ -45,8 +51,15 @@ public:
std::string getCompilerSupportedOptions() const;
- bool isOptionSupported(std::string optName, std::optional<std::string> optValue = std::nullopt) const;
- bool isTurboOptionSupported(const ze_graph_compiler_version_info_t& compilerVersion) const;
+ /**
+ * @brief Checks whether the specified driver/compiler option is supported by the driver.
+ * @param optName The name of the option to check.
+ * @param optValue The value of the option to check (optional).
+ * @return `true` if the option is supported, `false` if it is not supported,
+ * and `std::nullopt` if the option-support query itself is not supported.
+ */
+ std::optional<bool> isOptionSupported(std::string optName,
+ std::optional<std::string> optValue = std::nullopt) const;
/**
* @brief Tells us whether or not the driver is able to receive and take into account a hash of the model instead of
@@ -82,6 +95,7 @@ private:
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
uint32_t _graphExtVersion;
+ bool _isCompilerOptionQuerySupported;
Logger _logger;
};
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
index 5bfb3fd1930..e07e6ca6b2f 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp
@@ -11,10 +11,10 @@
#include "intel_npu/npu_private_properties.hpp"
#include "intel_npu/profiling.hpp"
#include "intel_npu/utils/utils.hpp"
+#include "model_serializer.hpp"
#include "openvino/runtime/make_tensor.hpp"
#include "openvino/util/file_util.hpp"
#include "openvino/util/shared_object.hpp"
-#include "vcl_serializer.hpp"
#include "weightless_utils.hpp"
#include "ze_graph_ext_wrappers.hpp"
@@ -383,12 +383,13 @@ std::shared_ptr<void> VCLCompilerImpl::getLinkedLibrary() const {
return VCLApi::getInstance()->getLibrary();
}
-NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const {
+NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model,
+ const FilteredConfig& config) const {
return compile(model, config, false);
}
NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model,
- const Config& config,
+ const FilteredConfig& config,
const bool storeWeightlessCacheAttributeFlag) const {
_logger.debug("compile start");
@@ -404,29 +405,27 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- const FilteredConfig* filteredConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (filteredConfig == nullptr) {
- OPENVINO_THROW("config is not FilteredConfig");
- }
- FilteredConfig updatedConfig = *filteredConfig;
bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, updatedConfig);
+ useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, config);
_logger.debug("serialize IR method is %s",
useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
- auto serializedIR = driver_compiler_utils::serializeIR(model,
- compilerVersion,
- maxOpsetVersion,
- useBaseModelSerializer,
- false,
- storeWeightlessCacheAttributeFlag);
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ useBaseModelSerializer,
+ false,
+ storeWeightlessCacheAttributeFlag);
std::string buildFlags;
+ const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
+ return is_option_supported(optionName);
+ };
+
_logger.debug("create build flags");
- buildFlags += driver_compiler_utils::serializeIOInfo(model, true);
+ buildFlags += compiler_utils::serializeIOInfo(model, true);
buildFlags += " ";
- buildFlags += driver_compiler_utils::serializeConfig(updatedConfig,
- compilerVersion,
- is_option_supported(ov::intel_npu::turbo.name()));
+ buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
+
_logger.debug("final build flags to compiler: %s", buildFlags.c_str());
vcl_executable_desc_t exeDesc = {serializedIR.buffer.get(),
@@ -475,7 +474,7 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
std::vector<std::shared_ptr<NetworkDescription>> VCLCompilerImpl::compileWsOneShot(
const std::shared_ptr<ov::Model>& model,
- const Config& config) const {
+ const FilteredConfig& config) const {
_logger.debug("compileWsOneShot start");
const auto maxOpsetVersion = _compilerProperties.supportedOpsets;
@@ -486,29 +485,22 @@ std::vector<std::shared_ptr<NetworkDescription>> VCLCompilerImpl::compileWsOneSh
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- const FilteredConfig* filteredConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (filteredConfig == nullptr) {
- OPENVINO_THROW("config is not FilteredConfig");
- }
- FilteredConfig updatedConfig = *filteredConfig;
bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer({7, 5}, updatedConfig);
+ useBaseModelSerializer = isUseBaseModelSerializer({7, 5}, config);
_logger.debug("serialize IR method is %s",
useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
- auto serializedIR = driver_compiler_utils::serializeIR(model,
- compilerVersion,
- maxOpsetVersion,
- useBaseModelSerializer,
- false,
- true);
+ auto serializedIR =
+ compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer, false, true);
std::string buildFlags;
+ const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
+ return is_option_supported(optionName);
+ };
+
_logger.debug("create build flags");
- buildFlags += driver_compiler_utils::serializeIOInfo(model, true);
+ buildFlags += compiler_utils::serializeIOInfo(model, true);
buildFlags += " ";
- buildFlags += driver_compiler_utils::serializeConfig(updatedConfig,
- compilerVersion,
- is_option_supported(ov::intel_npu::turbo.name()));
+ buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("final build flags to compiler: %s", buildFlags.c_str());
vcl_executable_desc_t exeDesc = {serializedIR.buffer.get(),
@@ -540,26 +532,22 @@ std::vector<std::shared_ptr<NetworkDescription>> VCLCompilerImpl::compileWsOneSh
}
NetworkDescription VCLCompilerImpl::compileWsIterative(const std::shared_ptr<ov::Model>& model,
- const Config& config,
+ const FilteredConfig& config,
size_t callNumber) const {
_logger.debug("compileWsIterative start");
- const FilteredConfig* filteredConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (filteredConfig == nullptr) {
- OPENVINO_THROW("config is not FilteredConfig");
- }
- FilteredConfig updatedConfig = *filteredConfig;
+ FilteredConfig updatedConfig = config;
updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber)}});
return compile(model, updatedConfig, true);
}
-intel_npu::NetworkMetadata VCLCompilerImpl::parse(const std::vector<uint8_t>& network, const Config& config) const {
+intel_npu::NetworkMetadata VCLCompilerImpl::parse(const std::vector<uint8_t>& network,
+ const FilteredConfig& config) const {
// VCL returns empty metadata. In plugin adapter, use driver metadata instead.
OPENVINO_THROW_NOT_IMPLEMENTED("VCL does not support parse.");
}
std::vector<ov::ProfilingInfo> VCLCompilerImpl::process_profiling_output(const std::vector<uint8_t>& profData,
- const std::vector<uint8_t>& network,
- const intel_npu::Config& config) const {
+ const std::vector<uint8_t>& network) const {
_logger.debug("process_profiling_output start");
vcl_profiling_handle_t profilingHandle;
@@ -606,7 +594,8 @@ uint32_t VCLCompilerImpl::get_version() const {
return ZE_MAKE_VERSION(_compilerProperties.version.major, _compilerProperties.version.minor);
}
-ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model>& model, const Config& config) const {
+ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model>& model,
+ const FilteredConfig& config) const {
_logger.debug("query start");
/// Check the linked vcl version whether supported in plugin
@@ -620,22 +609,17 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model
ze_graph_compiler_version_info_t compilerVersion;
compilerVersion.major = _compilerProperties.version.major;
compilerVersion.minor = _compilerProperties.version.minor;
- const FilteredConfig* filteredConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (filteredConfig == nullptr) {
- OPENVINO_THROW("config is not FilteredConfig");
- }
- FilteredConfig updatedConfig = *filteredConfig;
bool useBaseModelSerializer = true;
- useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, updatedConfig);
+ useBaseModelSerializer = isUseBaseModelSerializer(usedVersion, config);
_logger.debug("serialize IR method is %s",
useBaseModelSerializer ? "base vcl serializer" : "vcl serializer (not copy weights)");
- auto serializedIR =
- driver_compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer);
+ auto serializedIR = compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer);
std::string buildFlags;
- buildFlags += driver_compiler_utils::serializeConfig(updatedConfig,
- compilerVersion,
- is_option_supported(ov::intel_npu::turbo.name()));
+ const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {
+ return is_option_supported(optionName);
+ };
+ buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("queryImpl build flags : %s", buildFlags.c_str());
vcl_query_handle_t queryHandle;
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 6a1286ad14f..a4f4ed4a925 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
@@ -4,6 +4,7 @@
#include "driver_compiler_adapter.hpp"
+#include <functional>
#include <string_view>
#include "graph.hpp"
@@ -12,8 +13,8 @@
#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "mem_usage.hpp"
+#include "model_serializer.hpp"
#include "openvino/core/model.hpp"
-#include "vcl_serializer.hpp"
#include "weightless_graph.hpp"
#include "weightless_utils.hpp"
@@ -66,21 +67,24 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con
_logger.debug("serialize IR");
- auto serializedIR = driver_compiler_utils::serializeIR(model,
- compilerVersion,
- maxOpsetVersion,
- useBaseModelSerializer(config),
- _zeGraphExt->isPluginModelHashSupported());
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ useBaseModelSerializer(config),
+ _zeGraphExt->isPluginModelHashSupported());
std::string buildFlags;
const bool useIndices = !((compilerVersion.major < 5) || (compilerVersion.major == 5 && compilerVersion.minor < 9));
+ const auto isOptionSupportedByCompiler = std::bind(&DriverCompilerAdapter::isCompilerOptionSupported,
+ this,
+ std::cref(config),
+ std::cref(compilerVersion),
+ std::placeholders::_1);
_logger.debug("build flags");
- buildFlags += driver_compiler_utils::serializeIOInfo(model, useIndices);
+ buildFlags += compiler_utils::serializeIOInfo(model, useIndices);
buildFlags += " ";
- buildFlags += driver_compiler_utils::serializeConfig(config,
- compilerVersion,
- _zeGraphExt->isTurboOptionSupported(compilerVersion));
+ buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("compileIR Build flags : %s", buildFlags.c_str());
@@ -114,6 +118,8 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
compilerVersion.minor);
}
+ FilteredConfig updatedConfig = config;
+
const auto maxOpsetVersion = _compilerProperties.maxOVOpsetVersionSupported;
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
@@ -124,22 +130,17 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
}
_logger.debug("serialize IR");
- auto serializedIR = driver_compiler_utils::serializeIR(model,
- compilerVersion,
- maxOpsetVersion,
- useBaseModelSerializer(config),
- true,
- _zeGraphExt->isPluginModelHashSupported());
+ auto serializedIR = compiler_utils::serializeIR(model,
+ compilerVersion,
+ maxOpsetVersion,
+ useBaseModelSerializer(updatedConfig),
+ true,
+ _zeGraphExt->isPluginModelHashSupported());
std::string buildFlags;
const bool useIndices = !((compilerVersion.major < 5) || (compilerVersion.major == 5 && compilerVersion.minor < 9));
- const std::string serializedIOInfo = driver_compiler_utils::serializeIOInfo(model, useIndices);
- const FilteredConfig* plgConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (plgConfig == nullptr) {
- OPENVINO_THROW("config is not FilteredConfig");
- }
- FilteredConfig updatedConfig = *plgConfig;
+ const std::string serializedIOInfo = compiler_utils::serializeIOInfo(model, useIndices);
// WS v3 is based on a stateless compiler. We'll use a separate config entry for informing the compiler the index of
// the current call iteration.
@@ -154,6 +155,13 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
if (_logger.level() >= ov::log::Level::INFO) {
compile_model_mem_start = get_peak_memory_usage();
}
+
+ const auto isOptionSupportedByCompiler = std::bind(&DriverCompilerAdapter::isCompilerOptionSupported,
+ this,
+ std::cref(updatedConfig),
+ std::cref(compilerVersion),
+ std::placeholders::_1);
+
while (true) {
_logger.debug("compileWS iteration %d", callNumber);
updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber++)}});
@@ -161,9 +169,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
_logger.debug("build flags");
buildFlags = serializedIOInfo;
buildFlags += " ";
- buildFlags += driver_compiler_utils::serializeConfig(updatedConfig,
- compilerVersion,
- _zeGraphExt->isTurboOptionSupported(compilerVersion));
+ buildFlags += compiler_utils::serializeConfig(updatedConfig, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("compile start");
// If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching
@@ -272,10 +278,15 @@ ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov:
_logger.debug("serialize IR");
auto serializedIR =
- driver_compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer(config));
+ compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer(config));
+ const auto isOptionSupportedByCompiler = std::bind(&DriverCompilerAdapter::isCompilerOptionSupported,
+ this,
+ std::cref(config),
+ std::cref(compilerVersion),
+ std::placeholders::_1);
std::string buildFlags;
- buildFlags += driver_compiler_utils::serializeConfig(config, compilerVersion);
+ buildFlags += compiler_utils::serializeConfig(config, compilerVersion, isOptionSupportedByCompiler);
_logger.debug("queryImpl build flags : %s", buildFlags.c_str());
ov::SupportedOpsMap result;
@@ -313,7 +324,28 @@ std::vector<std::string> DriverCompilerAdapter::get_supported_options() const {
}
bool DriverCompilerAdapter::is_option_supported(std::string optName, std::optional<std::string> optValue) const {
- return _zeGraphExt->isOptionSupported(std::move(optName), std::move(optValue));
+ auto isOptionSupported = _zeGraphExt->isOptionSupported(std::move(optName), std::move(optValue));
+ return isOptionSupported.value_or(false);
+}
+
+bool DriverCompilerAdapter::isCompilerOptionSupported(const FilteredConfig& config,
+ const ze_graph_compiler_version_info_t& compilerVersion,
+ const std::string& optionName) const {
+ if (!config.hasOpt(optionName)) {
+ return false;
+ }
+
+ const std::optional<bool> isSupported = _zeGraphExt->isOptionSupported(optionName);
+ if (isSupported.has_value()) {
+ return isSupported.value();
+ }
+
+ uint32_t compilerOptSupportValue = config.getOpt(optionName).compilerSupportVersion();
+ uint32_t majorCompilerOptSupportValue = ZE_MAJOR_VERSION(compilerOptSupportValue);
+ uint32_t minorCompilerOptSupportValue = ZE_MINOR_VERSION(compilerOptSupportValue);
+ return (compilerVersion.major > majorCompilerOptSupportValue) ||
+ ((compilerVersion.major == majorCompilerOptSupportValue) &&
+ (compilerVersion.minor >= minorCompilerOptSupportValue));
}
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
index 43bc505a6ac..b2e544bda73 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
@@ -404,7 +404,7 @@ void DynamicGraphImpl::predictOutputShape(std::vector<MemRefType>& inputDescript
DynamicGraph::DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,
std::optional<ov::Tensor> blob,
bool blobAllocatedByPlugin,
- const Config& config,
+ const FilteredConfig& config,
const ov::SoPtr<VCLCompilerImpl>& compiler)
: _zeroInitStruct(zeroInitStruct),
_blob(std::move(blob)),
@@ -518,8 +518,7 @@ void DynamicGraph::set_workload_type(const ov::WorkloadType workloadType) const
_commandQueue->setWorkloadType(zeWorkloadType);
}
-std::vector<ov::ProfilingInfo> DynamicGraph::process_profiling_output(const std::vector<uint8_t>& profData,
- const Config& config) const {
+std::vector<ov::ProfilingInfo> DynamicGraph::process_profiling_output(const std::vector<uint8_t>& profData) const {
if (_compiler == nullptr) {
OPENVINO_THROW("Profiling post-processing is not supported.");
}
@@ -527,7 +526,7 @@ std::vector<ov::ProfilingInfo> DynamicGraph::process_profiling_output(const std:
std::vector<uint8_t> blob(_blob->get_byte_size());
blob.assign(reinterpret_cast<const uint8_t*>(_blob->data()),
reinterpret_cast<const uint8_t*>(_blob->data()) + _blob->get_byte_size());
- return _compiler->process_profiling_output(profData, blob, config);
+ return _compiler->process_profiling_output(profData, blob);
}
void DynamicGraph::set_argument_value(uint32_t argi, const void* argv) const {
@@ -555,7 +554,7 @@ ze_graph_handle_t DynamicGraph::get_handle() const {
return nullptr;
}
-void DynamicGraph::initialize(const Config& config) {
+void DynamicGraph::initialize(const FilteredConfig& config) {
_logger.debug("Graph initialize start");
if (!_impl) {
@@ -616,7 +615,7 @@ void DynamicGraph::initialize(const Config& config) {
_init_completed = true;
}
-bool DynamicGraph::release_blob(const Config& config) {
+bool DynamicGraph::release_blob(const FilteredConfig& config) {
_logger.warning("Release blob is skipped, no handle for DynamicGraph");
return false;
};
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
index 3d120ed18fc..02b89772d6b 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -18,7 +18,7 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,
const GraphDescriptor& graphDesc,
NetworkMetadata metadata,
std::optional<ov::Tensor> blob,
- const Config& config,
+ const FilteredConfig& config,
const bool blobIsPersistent,
const ov::SoPtr<VCLCompilerImpl>& compiler,
const bool calledFromWeightlessGraph)
@@ -138,8 +138,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> Graph::export_blob(std
return std::make_pair(size, std::nullopt);
}
-std::vector<ov::ProfilingInfo> Graph::process_profiling_output(const std::vector<uint8_t>& profData,
- const Config& config) const {
+std::vector<ov::ProfilingInfo> Graph::process_profiling_output(const std::vector<uint8_t>& profData) const {
if (_compiler == nullptr) {
OPENVINO_THROW("Profiling post-processing is not supported.");
}
@@ -147,7 +146,7 @@ std::vector<ov::ProfilingInfo> Graph::process_profiling_output(const std::vector
std::vector<uint8_t> blob(_blob->get_byte_size());
blob.assign(reinterpret_cast<const uint8_t*>(_blob->data()),
reinterpret_cast<const uint8_t*>(_blob->data()) + _blob->get_byte_size());
- return _compiler->process_profiling_output(profData, blob, config);
+ return _compiler->process_profiling_output(profData, blob);
}
void Graph::set_argument_value(uint32_t id, const void* data) const {
@@ -164,7 +163,7 @@ void Graph::set_argument_value_with_strides(uint32_t id, const void* data, const
_zeGraphExt->setGraphArgumentValueWithStrides(_graphDesc, id, data, strides);
}
-void Graph::initialize(const Config& config) {
+void Graph::initialize(const FilteredConfig& config) {
_logger.debug("Graph initialize start");
if (_zeGraphExt == nullptr || _graphDesc._handle == nullptr || _zeroInitStruct == nullptr) {
@@ -221,7 +220,7 @@ void Graph::initialize(const Config& config) {
_init_completed = true;
}
-bool Graph::release_blob(const Config& config) {
+bool Graph::release_blob(const FilteredConfig& config) {
if ((_zeGraphExt != nullptr && _zeGraphExt->isBlobDataImported(_graphDesc)) || _blobIsPersistent ||
_blob == std::nullopt || _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8) ||
config.get<PERF_COUNT>()) {
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/vcl_serializer.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
similarity index 96%
rename from src/plugins/intel_npu/src/compiler_adapter/src/vcl_serializer.cpp
rename to src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
index 9030c8c1ace..8bc5663b628 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/vcl_serializer.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#include "vcl_serializer.hpp"
+#include "model_serializer.hpp"
#include <cstdint>
#include <istream>
@@ -205,7 +205,7 @@ void storeWeightlessCacheAttribute(const std::shared_ptr<ov::Model>& model) {
} // namespace
-namespace intel_npu::driver_compiler_utils {
+namespace intel_npu::compiler_utils {
/**
* @brief Interface to be used by the serialization algorithms.
@@ -591,21 +591,15 @@ std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const
outputsPrecisionSS.str() + VALUES_SEPARATOR.data() + outputsLayoutSS.str();
}
-std::string serializeConfig(const Config& config,
- ze_graph_compiler_version_info_t compilerVersion,
- bool turboSupported) {
+std::string serializeConfig(const FilteredConfig& config,
+ const ze_graph_compiler_version_info_t& compilerVersion,
+ const std::function<bool(const std::string&)>& isOptionSupportedByCompiler) {
Logger logger("serializeConfig", Logger::global().level());
std::string content = {};
- const FilteredConfig* plgConfig = dynamic_cast<const FilteredConfig*>(&config);
- if (plgConfig != nullptr) {
- content += plgConfig->toStringForCompiler();
- content += plgConfig->toStringForCompilerInternal();
- } else {
- logger.warning("Failed to cast Config to FilteredConfig. Exporting all configs");
- content += config.toString();
- }
+ content += config.toStringForCompiler();
+ content += config.toStringForCompilerInternal();
logger.debug("Original content of config: %s", content.c_str());
@@ -678,20 +672,25 @@ std::string serializeConfig(const Config& config,
getStringReplacement(ov::intel_npu::LegacyPriority::HIGH));
}
- // Special case for compiler Turbo
+ // Special cases
+ const auto& removeOptionIfUnsupported = [&](const std::string& optionName) {
+ if (std::regex_search(content, std::regex(optionName))) {
+ const bool optionSupported =
+ isOptionSupportedByCompiler != nullptr ? isOptionSupportedByCompiler(optionName) : false;
+ if (!optionSupported) {
+ std::ostringstream optionStr;
+ optionStr << optionName << KEY_VALUE_SEPARATOR << VALUE_DELIMITER << "\\S+" << VALUE_DELIMITER;
+ logger.info("%s property is not supported by this compiler. Removing from parameters",
+ optionName.c_str());
+ content = std::regex_replace(content, std::regex(optionStr.str()), "");
+ }
+ }
+ };
+
// NPU_TURBO is a special option in the sense that by default it is a driver-setting, but certain compilers
// support and make use of it too If we have turbo in the config string, we check if compiler supports it. If it
// doesn't support it, we remove it
- if (std::regex_search(content, std::regex("NPU_TURBO"))) {
- if (!turboSupported) {
- std::ostringstream turbostr;
- turbostr << ov::intel_npu::turbo.name() << KEY_VALUE_SEPARATOR << VALUE_DELIMITER << "\\S+"
- << VALUE_DELIMITER;
- logger.info("NPU_TURBO property is not supported by this compiler. Removing from "
- "parameters");
- content = std::regex_replace(content, std::regex(turbostr.str()), "");
- }
- }
+ removeOptionIfUnsupported(ov::intel_npu::turbo.name());
// FINAL step to convert prefixes of remaining params, to ensure backwards compatibility
// From 5.0.0, driver compiler start to use NPU_ prefix, the old version uses VPU_ prefix
@@ -709,4 +708,4 @@ std::string serializeConfig(const Config& config,
return "--config " + content;
}
-} // namespace intel_npu::driver_compiler_utils
+} // namespace intel_npu::compiler_utils
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
index 865c89b7a2f..f17c2cfcf76 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
@@ -156,7 +156,7 @@ WeightlessGraph::WeightlessGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGr
std::vector<NetworkMetadata> initMetadata,
std::optional<std::vector<ov::Tensor>> initBlobs,
std::shared_ptr<const ov::Model>&& model,
- const Config& config,
+ const FilteredConfig& config,
const bool blobIsPersistent,
const ov::SoPtr<VCLCompilerImpl>& compiler)
: Graph(zeGraphExt,
@@ -275,7 +275,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> WeightlessGraph::expor
return std::make_pair(totalBlobSize, initSizes);
}
-void WeightlessGraph::initialize(const Config& config) {
+void WeightlessGraph::initialize(const FilteredConfig& config) {
if (_zeGraphExt == nullptr || _graphDesc._handle == nullptr || _zeroInitStruct == nullptr) {
// To ensure that does not throw an issue when subsequently calling `_zeroInitStruct->getDevice()`
return;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
index 04b849389db..e623fd1c09c 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
@@ -133,6 +133,18 @@ ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr<ZeroInitStructsHold
_logger.info("Graph ext version used by zero wrapper: %d.%d",
ZE_MAJOR_VERSION(_graphExtVersion),
ZE_MINOR_VERSION(_graphExtVersion));
+
+ _isCompilerOptionQuerySupported = (_graphExtVersion >= ZE_MAKE_VERSION(1, 11));
+#ifdef _WIN32
+ if (_isCompilerOptionQuerySupported) {
+ // Windows driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here
+ _isCompilerOptionQuerySupported =
+ _zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(_zeroInitStruct->getDevice(),
+ ZE_NPU_DRIVER_OPTIONS,
+ "NO_THROW_ON_UNSUPPORTED_FEATURE",
+ nullptr) == ZE_RESULT_SUCCESS;
+ }
+#endif
}
ZeGraphExtWrappers::~ZeGraphExtWrappers() {
@@ -557,20 +569,11 @@ NetworkMetadata ZeGraphExtWrappers::getNetworkMeta(GraphDescriptor& graphDescrip
std::string ZeGraphExtWrappers::getCompilerSupportedOptions() const {
// Early exit if api is not supported
- if (_graphExtVersion < ZE_MAKE_VERSION(1, 11)) {
+ if (!_isCompilerOptionQuerySupported) {
+ _logger.debug("Compiler options query is not supported by the driver - skipping!");
return {};
}
-#ifdef _WIN32
- // Driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here
- if (_zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(_zeroInitStruct->getDevice(),
- ZE_NPU_DRIVER_OPTIONS,
- "NO_THROW_ON_UNSUPPORTED_FEATURE",
- nullptr) != ZE_RESULT_SUCCESS) {
- return {};
- }
-#endif
-
// 1. ask driver for size of compiler supported options list
_logger.debug("pfnCompilerGetSupportedOptions - obtain string size");
size_t str_size = 0;
@@ -614,22 +617,14 @@ std::string ZeGraphExtWrappers::getCompilerSupportedOptions() const {
return {};
}
-bool ZeGraphExtWrappers::isOptionSupported(std::string optName, std::optional<std::string> optValue) const {
+std::optional<bool> ZeGraphExtWrappers::isOptionSupported(std::string optName,
+ std::optional<std::string> optValue) const {
// Early exit if api is not supported
- if (_graphExtVersion < ZE_MAKE_VERSION(1, 11)) {
- return false;
+ if (!_isCompilerOptionQuerySupported) {
+ _logger.debug("Compiler option query is not supported by the driver - skipping!");
+ return std::nullopt;
}
-#ifdef _WIN32
- // Driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here
- if (_zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(_zeroInitStruct->getDevice(),
- ZE_NPU_DRIVER_OPTIONS,
- "NO_THROW_ON_UNSUPPORTED_FEATURE",
- nullptr) != ZE_RESULT_SUCCESS) {
- return false;
- }
-#endif
-
const char* optname_ch = optName.c_str();
const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;
auto result = _zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(_zeroInitStruct->getDevice(),
@@ -647,40 +642,6 @@ bool ZeGraphExtWrappers::isOptionSupported(std::string optName, std::optional<st
return false;
}
-bool ZeGraphExtWrappers::isTurboOptionSupported(const ze_graph_compiler_version_info_t& compilerVersion) const {
- auto checkCompilerVersion = [](const ze_graph_compiler_version_info_t& compilerVersion) {
- if ((compilerVersion.major < 7) || (compilerVersion.major == 7 && compilerVersion.minor < 21)) {
- return false;
- }
-
- return true;
- };
-
- if (_graphExtVersion < ZE_MAKE_VERSION(1, 11)) {
- return checkCompilerVersion(compilerVersion);
- }
-
-#ifdef _WIN32
- // Driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here
- if (_zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(_zeroInitStruct->getDevice(),
- ZE_NPU_DRIVER_OPTIONS,
- "NO_THROW_ON_UNSUPPORTED_FEATURE",
- nullptr) != ZE_RESULT_SUCCESS) {
- return checkCompilerVersion(compilerVersion);
- }
-#endif
-
- bool is_supported = false;
- try {
- is_supported = isOptionSupported("NPU_TURBO");
- } catch (...) {
- // mute it, not critical
- is_supported = false;
- }
-
- return is_supported;
-}
-
bool ZeGraphExtWrappers::isPluginModelHashSupported() const {
return _graphExtVersion > ZE_MAKE_VERSION(1, 13);
}
diff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
index 53a85ec088a..cec4e77f354 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/custom_stream.cpp
@@ -8,12 +8,12 @@
#include "common/npu_test_env_cfg.hpp"
#include "common_test_utils/node_builders/constant.hpp"
#include "intel_npu/config/options.hpp"
+#include "model_serializer.hpp"
#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
#include "openvino/core/runtime_attribute.hpp"
#include "openvino/opsets/opset11.hpp"
#include "openvino/pass/serialize.hpp"
#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
-#include "vcl_serializer.hpp"
using CompilationParams = std::tuple<std::string, // Device name
ov::AnyMap // Config
@@ -121,8 +121,7 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelWeightsCopy) {
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, true));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, true));
// If the size changes significantly, then investigation may be required
ASSERT_TRUE(serializedModel.size > SERIALIZED_MODEL_THRESHOLD_ALL_WEIGHTS_COPY);
}
@@ -132,8 +131,7 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, TestLargeModelNoWeightsCopy) {
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
// If the size changes significantly, then investigation may be required
ASSERT_TRUE(serializedModel.size < SERIALIZED_MODEL_THRESHOLD_NO_WEIGHTS_COPY);
@@ -147,12 +145,11 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckHashPresence) {
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false));
ASSERT_FALSE(serializedModel.hash.has_value());
EXPECT_NO_THROW(serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true));
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true));
ASSERT_TRUE(serializedModel.hash.has_value());
}
@@ -165,14 +162,12 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckWeightlessCacheAttributePr
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false));
ASSERT_FALSE(model->has_rt_info("ws_bin_offset_1"));
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, false, true));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, false, true));
// Follows the contract established with the driver-compiler adapter. Predefined prefix + a topological ID of the
// Constant node
ASSERT_TRUE(model->has_rt_info("ws_bin_offset_1"));
@@ -186,16 +181,14 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckWeightlessCacheAttributeCh
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashNoWCA = serializedModel.hash.value();
model = createModelWithLargeWeights(true);
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, true));
ASSERT_FALSE(hashNoWCA == serializedModel.hash.value());
}
@@ -208,30 +201,23 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckPluginHashIgnoresOnlyNonde
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel = ::intel_npu::driver_compiler_utils::serializeIR(model->clone(),
- dummyCompilerVersion,
- 11,
- false,
- true,
- false));
+ EXPECT_NO_THROW(
+ serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false, true, false));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashNoAttribute = serializedModel.hash.value();
model->input().get_node()->get_rt_info()[TestNonDeterministicAttribute::get_type_info_static()] =
TestNonDeterministicAttribute();
- EXPECT_NO_THROW(serializedModel = ::intel_npu::driver_compiler_utils::serializeIR(model->clone(),
- dummyCompilerVersion,
- 11,
- false,
- true,
- false));
+ EXPECT_NO_THROW(
+ serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model->clone(), dummyCompilerVersion, 11, false, true, false));
ASSERT_TRUE(hashNoAttribute == serializedModel.hash.value());
model->input().get_node()->get_rt_info()[TestDeterministicAttribute::get_type_info_static()] =
TestDeterministicAttribute();
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 11, false, true, false));
ASSERT_FALSE(hashNoAttribute == serializedModel.hash.value());
}
@@ -243,20 +229,18 @@ TEST_P(DriverCompilerAdapterCustomStreamTestNPU, CheckSameModelDifferentInstance
const ze_graph_compiler_version_info_t dummyCompilerVersion{0, 0};
::intel_npu::SerializedIR serializedModel;
- EXPECT_NO_THROW(serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model,
- dummyCompilerVersion,
- 10, // Triggers an additional pass
- false,
- true,
- false));
+ EXPECT_NO_THROW(serializedModel = ::intel_npu::compiler_utils::serializeIR(model,
+ dummyCompilerVersion,
+ 10, // Triggers an additional pass
+ false,
+ true,
+ false));
ASSERT_TRUE(serializedModel.hash.has_value());
const uint64_t hashFirstInstance = serializedModel.hash.value();
model = createModelWithLargeWeights();
- EXPECT_NO_THROW(
- serializedModel =
- ::intel_npu::driver_compiler_utils::serializeIR(model, dummyCompilerVersion, 10, false, true, false));
+ EXPECT_NO_THROW(serializedModel =
+ ::intel_npu::compiler_utils::serializeIR(model, dummyCompilerVersion, 10, false, true, false));
ASSERT_TRUE(hashFirstInstance == serializedModel.hash.value());
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp
index aac511e963c..9276f4e474a 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp
@@ -27,4 +27,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
::testing::ValuesIn(emptyConfigsTests),
graphExtVersions),
ZeroGraphTest::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
+ IsOptionSupported,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(emptyConfigsTests),
+ graphExtVersions),
+ ZeroGraphTest::getTestCaseName);
+
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
index 93ad912aac1..5f300c87ebd 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
@@ -15,8 +15,8 @@
#include "intel_npu/utils/zero/zero_mem.hpp"
#include "intel_npu/utils/zero/zero_mem_pool.hpp"
#include "intel_npu/utils/zero/zero_utils.hpp"
+#include "model_serializer.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
-#include "vcl_serializer.hpp"
#include "ze_graph_ext_wrappers.hpp"
#include "zero_init_mock.hpp"
@@ -78,8 +78,6 @@ public:
protected:
void SetUp() override {
- using namespace ::driver_compiler_utils;
-
SKIP_IF_CURRENT_TEST_IS_DISABLED();
std::tie(targetDevice, configuration, graphExtVersion) = this->GetParam();
@@ -103,7 +101,7 @@ protected:
auto compilerProperties = zeroInitStruct->getCompilerProperties();
const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported;
serializedIR =
- driver_compiler_utils::serializeIR(model, compilerProperties.compilerVersion, maxOpsetVersion, true);
+ ::intel_npu::compiler_utils::serializeIR(model, compilerProperties.compilerVersion, maxOpsetVersion, true);
}
bool bypassUmdCache() {
@@ -130,7 +128,7 @@ protected:
std::shared_ptr<ZeGraphExtWrappers> zeGraphExt;
ov::AnyMap configuration;
- SerializedIR serializedIR;
+ ::intel_npu::SerializedIR serializedIR;
GraphDescriptor graphDescriptor;
std::shared_ptr<ov::Model> model;
@@ -372,4 +370,28 @@ TEST_P(ZeroGraphTest, CheckNoThrowOnUnsupportedFeature) {
}
#endif
+using IsOptionSupported = ZeroGraphTest;
+
+TEST_P(IsOptionSupported, PropertyNotSupportedByDriver) {
+ std::optional<bool> isOptionSupportedResult;
+ OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("FAKE_OPTION"));
+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {
+ ASSERT_FALSE(isOptionSupportedResult.has_value());
+ } else {
+ ASSERT_TRUE(isOptionSupportedResult.has_value());
+ ASSERT_FALSE(isOptionSupportedResult.value());
+ }
+}
+
+TEST_P(IsOptionSupported, PropertySupportedByDriver) {
+ std::optional<bool> isOptionSupportedResult;
+ OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("PERFORMANCE_HINT"));
+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {
+ ASSERT_FALSE(isOptionSupportedResult.has_value());
+ } else {
+ ASSERT_TRUE(isOptionSupportedResult.has_value());
+ ASSERT_TRUE(isOptionSupportedResult.value());
+ }
+}
+
} // namespace ov::test::behavior