Skip to content

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

[NPU] Avoid loading the compiler library in model_import() (#34392)

Bogdan Pereanue0bd04c7f974
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 5ae703179b2..762909981fd 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
@@ -354,14 +354,16 @@ std::vector<ov::ProfilingInfo> Pipeline::get_profiling_info() const {
return _npu_profiling->getNpuInferStatistics();
}
/// PROFILING_TYPE = MODEL or undefined = fallback to model profiling
- if (_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PLUGIN) {
+ if (_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER) {
+ _logger.debug("InferRequest::get_profiling_info complete with _profiling_query.getLayerStatistics().");
+ return _profiling_query->getLayerStatistics();
+ } else if (_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PLUGIN) {
// 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>());
} else {
- _logger.debug("InferRequest::get_profiling_info complete with _profiling_query.getLayerStatistics().");
- return _profiling_query->getLayerStatistics();
+ OPENVINO_THROW("Cannot get profiling info, unknown compiler type");
}
}
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp
new file mode 100644
index 00000000000..8e362452225
--- /dev/null
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/compiler_adapter_factory.hpp
@@ -0,0 +1,30 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <atomic>
+#include <memory>
+#include <optional>
+#include <string_view>
+
+#include "intel_npu/common/icompiler_adapter.hpp"
+#include "intel_npu/common/npu.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
+
+namespace intel_npu {
+
+class CompilerAdapterFactory final {
+public:
+ ov::intel_npu::CompilerType determineAppropriateCompilerTypeBasedOnPlatform(std::string_view platform) const;
+
+ std::unique_ptr<ICompilerAdapter> getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,
+ ov::intel_npu::CompilerType& compilerType,
+ std::string_view platform) const;
+
+private:
+ inline static std::atomic<bool> _pluginCompilerIsPresent{true};
+};
+
+} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
index f47f1798534..8830ebf6174 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
@@ -31,25 +31,6 @@ public:
virtual std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model,
const FilteredConfig& config) const = 0;
- /**
- * @brief Parses the provided binary objects and returns a wrapper over the resulted L0 handles. The model may also
- * be loaded on the device depending on the provided configuration (if "NPU_DEFER_WEIGHTS_LOAD" is off).
- *
- * @param mainBlob The core binary object to be parsed and used to build the "Graph" object.
- * @param config Used to influence the downstream flow of the implementation based on preferences.
- * @param initBlobs Optional. If provided, the "weights separation" flow is enabled and the binary objects
- * corresponding to the init schedules will be parsed as well.
- * @param model Optional, but required if "initBlobs" is provided. The "ov::Model" object is leveraged in the
- * "weights separation" implementation in order to extract the buffers of the weights.
- * @return A wrapper over the corresponding L0 graph handles (multiple only if "initBlobs" has been provided). This
- * wrapper further details the compiled model and brings it in a state closer to execution.
- */
- virtual std::shared_ptr<IGraph> parse(
- const ov::Tensor& mainBlob,
- const FilteredConfig& config,
- const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,
- std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const = 0;
-
virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const = 0;
virtual uint32_t get_version() const = 0;
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp
new file mode 100644
index 00000000000..62bb850d220
--- /dev/null
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp
@@ -0,0 +1,36 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "intel_npu/common/filtered_config.hpp"
+#include "intel_npu/common/igraph.hpp"
+
+namespace intel_npu {
+
+class IParser {
+public:
+ /**
+ * @brief Parses the provided binary objects and returns a wrapper over the resulted L0 handles. The model may also
+ * be loaded on the device depending on the provided configuration (if "NPU_DEFER_WEIGHTS_LOAD" is off).
+ *
+ * @param mainBlob The core binary object to be parsed and used to build the "Graph" object.
+ * @param config Used to influence the downstream flow of the implementation based on preferences.
+ * @param initBlobs Optional. If provided, the "weights separation" flow is enabled and the binary objects
+ * corresponding to the init schedules will be parsed as well.
+ * @param model Optional, but required if "initBlobs" is provided. The "ov::Model" object is leveraged in the
+ * "weights separation" implementation in order to extract the buffers of the weights.
+ * @return A wrapper over the corresponding L0 graph handles (multiple only if "initBlobs" has been provided). This
+ * wrapper further details the compiled model and brings it in a state closer to execution.
+ */
+ virtual std::shared_ptr<IGraph> parse(
+ const ov::Tensor& mainBlob,
+ const FilteredConfig& config,
+ const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,
+ std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const = 0;
+
+ virtual ~IParser() = default;
+};
+
+} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/parser_factory.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/parser_factory.hpp
new file mode 100644
index 00000000000..9616f9d9336
--- /dev/null
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/parser_factory.hpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "intel_npu/common/iparser.hpp"
+#include "intel_npu/utils/zero/zero_init.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
+
+namespace intel_npu {
+
+class ParserFactory final {
+public:
+ std::unique_ptr<IParser> getParser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStructs) const;
+};
+
+} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_adapter_factory.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_adapter_factory.hpp
deleted file mode 100644
index b10d6ebb623..00000000000
--- a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_adapter_factory.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-
-#include "driver_compiler_adapter.hpp"
-#include "intel_npu/common/icompiler_adapter.hpp"
-#include "intel_npu/common/npu.hpp"
-#include "intel_npu/config/config.hpp"
-#include "intel_npu/config/options.hpp"
-#include "plugin_compiler_adapter.hpp"
-
-namespace intel_npu {
-
-class CompilerAdapterFactory final {
-public:
- ov::intel_npu::CompilerType determinteAppropriateCompilerTypeBasedOnPlatform(std::string_view platform) const {
- if (platform == ov::intel_npu::Platform::NPU4000 || platform == ov::intel_npu::Platform::NPU5010) {
- return ov::intel_npu::CompilerType::PLUGIN;
- }
-
- return ov::intel_npu::CompilerType::DRIVER;
- }
-
- std::unique_ptr<ICompilerAdapter> getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,
- ov::intel_npu::CompilerType& compilerType,
- std::string_view platform) const {
- if (compilerType == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- if (engineBackend != nullptr) {
- compilerType = determinteAppropriateCompilerTypeBasedOnPlatform(platform);
- if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
- if (_pluginCompilerIsPresent) {
- try {
- return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs());
- } catch (...) {
- _pluginCompilerIsPresent = false;
- compilerType = ov::intel_npu::CompilerType::DRIVER;
- }
- } else {
- // plugin compiler isn't present, fallback to driver compiler
- compilerType = ov::intel_npu::CompilerType::DRIVER;
- }
- }
- } else {
- // device isn't available, offline compilation only
- compilerType = ov::intel_npu::CompilerType::PLUGIN;
- }
- }
-
- if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
- if (engineBackend == nullptr) {
- return std::make_unique<PluginCompilerAdapter>(nullptr);
- }
-
- return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs());
- } else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {
- if (engineBackend == nullptr || engineBackend->getDevice() == nullptr) {
- OPENVINO_THROW(
- "Could not find a NPU device. Using driver compiler requires a valid device to be present in "
- "the system.");
- }
-
- // It is required to check if the device is compatible with the provided platform, as the driver compiler
- // will be used.
- auto deviceName = engineBackend->getDevice()->getName();
- if (deviceName != platform && deviceName != "AUTO_DETECT") {
- OPENVINO_THROW("Could not find a valid NPU device for the provided configuration.");
- }
-
- return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs());
- } else {
- OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");
- }
- }
-
-private:
- inline static std::atomic<bool> _pluginCompilerIsPresent{true};
-};
-
-} // namespace intel_npu
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 5dbe01ca8f7..8603cd0b913 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
@@ -23,12 +23,6 @@ public:
std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const FilteredConfig& config) const override;
- std::shared_ptr<IGraph> parse(
- const ov::Tensor& mainBlob,
- const FilteredConfig& config,
- const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,
- std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const override;
-
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const override;
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 e375b9ce714..23a16a35724 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
@@ -6,7 +6,6 @@
#include <ze_graph_ext.h>
-#include "compiler_impl.hpp"
#include "intel_npu/common/idynamic_graph.hpp"
#include "intel_npu/network_metadata.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
@@ -108,8 +107,7 @@ public:
DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,
std::optional<ov::Tensor> blob,
bool blobAllocatedByPlugin,
- const FilteredConfig& config,
- const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr});
+ const FilteredConfig& config);
std::pair<uint64_t, std::optional<std::vector<uint64_t>>> export_blob(std::ostream& stream) const override;
@@ -195,7 +193,6 @@ private:
*/
std::optional<std::size_t> _batchSize = std::nullopt;
- const ov::SoPtr<VCLCompilerImpl> _compiler;
Logger _logger;
std::unique_ptr<Impl> _impl;
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 35cfedfad47..038046149e7 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
@@ -8,7 +8,6 @@
#include <ze_graph_ext.h>
-#include "compiler_impl.hpp"
#include "intel_npu/common/igraph.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "openvino/runtime/so_ptr.hpp"
@@ -25,7 +24,6 @@ public:
std::optional<ov::Tensor> blob,
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;
@@ -95,7 +93,6 @@ protected:
*/
std::optional<std::size_t> _batchSize = std::nullopt;
- const ov::SoPtr<VCLCompilerImpl> _compiler;
Logger _logger;
};
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp
new file mode 100644
index 00000000000..1097d29ced5
--- /dev/null
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp
@@ -0,0 +1,34 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+// Compiler Interface
+
+#pragma once
+
+#include "intel_npu/common/iparser.hpp"
+#include "intel_npu/utils/logger/logger.hpp"
+#include "intel_npu/utils/zero/zero_init.hpp"
+#include "openvino/core/model.hpp"
+#include "ze_graph_ext_wrappers.hpp"
+
+namespace intel_npu {
+
+class Parser final : public IParser {
+public:
+ Parser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct);
+
+ std::shared_ptr<IGraph> parse(
+ const ov::Tensor& mainBlob,
+ const FilteredConfig& config,
+ const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,
+ std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const override;
+
+private:
+ std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
+ std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;
+
+ Logger _logger;
+};
+
+} // namespace intel_npu
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 41a48d7c3a0..77208296b31 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
@@ -24,12 +24,6 @@ public:
std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const FilteredConfig& config) const override;
- std::shared_ptr<IGraph> parse(
- const ov::Tensor& mainBlob,
- const FilteredConfig& config,
- const std::optional<std::vector<ov::Tensor>>& initBlobs = std::nullopt,
- std::optional<std::shared_ptr<const ov::Model>>&& model = std::nullopt) const override;
-
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const override;
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 3d69d72bedf..0521364e5e8 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
@@ -6,7 +6,6 @@
#pragma once
-#include "compiler_impl.hpp"
#include "graph.hpp"
#include "intel_npu/utils/zero/zero_host_tensor.hpp"
#include "openvino/op/constant.hpp"
@@ -32,8 +31,7 @@ public:
std::optional<std::vector<ov::Tensor>> initBlobs,
std::shared_ptr<const ov::Model>&& model,
const FilteredConfig& config,
- const bool blobIsPersistent = false,
- const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr});
+ const bool blobIsPersistent = false);
/**
* @brief The main schedule along with the weights initialization ones are exported.
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp
new file mode 100644
index 00000000000..3826563cc61
--- /dev/null
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_adapter_factory.cpp
@@ -0,0 +1,72 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_npu/common/compiler_adapter_factory.hpp"
+
+#include "driver_compiler_adapter.hpp"
+#include "intel_npu/npu_private_properties.hpp"
+#include "plugin_compiler_adapter.hpp"
+
+namespace intel_npu {
+
+ov::intel_npu::CompilerType CompilerAdapterFactory::determineAppropriateCompilerTypeBasedOnPlatform(
+ std::string_view platform) const {
+ if (platform == ov::intel_npu::Platform::NPU4000 || platform == ov::intel_npu::Platform::NPU5010) {
+ return ov::intel_npu::CompilerType::PLUGIN;
+ }
+
+ return ov::intel_npu::CompilerType::DRIVER;
+}
+
+std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,
+ ov::intel_npu::CompilerType& compilerType,
+ std::string_view platform) const {
+ if (compilerType == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
+ if (engineBackend != nullptr) {
+ compilerType = determineAppropriateCompilerTypeBasedOnPlatform(platform);
+ if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
+ if (_pluginCompilerIsPresent) {
+ try {
+ return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs());
+ } catch (...) {
+ _pluginCompilerIsPresent = false;
+ compilerType = ov::intel_npu::CompilerType::DRIVER;
+ }
+ } else {
+ // plugin compiler isn't present, fallback to driver compiler
+ compilerType = ov::intel_npu::CompilerType::DRIVER;
+ }
+ }
+ } else {
+ // device isn't available, offline compilation only
+ compilerType = ov::intel_npu::CompilerType::PLUGIN;
+ }
+ }
+
+ if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
+ if (engineBackend == nullptr) {
+ return std::make_unique<PluginCompilerAdapter>(nullptr);
+ }
+
+ return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs());
+ } else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {
+ if (engineBackend == nullptr || engineBackend->getDevice() == nullptr) {
+ OPENVINO_THROW("Could not find an NPU device. The driver compiler requires a valid device to be present in "
+ "the system.");
+ }
+
+ // It is required to check if the device is compatible with the provided platform, as the driver compiler
+ // will be used.
+ auto deviceName = engineBackend->getDevice()->getName();
+ if (deviceName != platform && deviceName != "AUTO_DETECT") {
+ OPENVINO_THROW("Could not find a valid NPU device for the provided configuration.");
+ }
+
+ return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs());
+ } else {
+ OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");
+ }
+}
+
+} // 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 6788803e151..ad99fc45425 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
@@ -214,60 +214,6 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
config);
}
-std::shared_ptr<IGraph> DriverCompilerAdapter::parse(const ov::Tensor& mainBlob,
- const FilteredConfig& config,
- const std::optional<std::vector<ov::Tensor>>& initBlobs,
- std::optional<std::shared_ptr<const ov::Model>>&& model) const {
- OV_ITT_TASK_CHAIN(PARSE_BLOB, itt::domains::NPUPlugin, "DriverCompilerAdapter", "parse");
-
- _logger.debug("parse start");
- auto mainGraphDesc = _zeGraphExt->getGraphDescriptor(mainBlob.data(), mainBlob.get_byte_size());
- _logger.debug("parse end");
-
- OV_ITT_TASK_NEXT(PARSE_BLOB, "getNetworkMeta");
- auto networkMeta = _zeGraphExt->getNetworkMeta(mainGraphDesc);
-
- // exporting the blob when we get it from cache or ov::hint::compiled_blob property
- // shall be available
- const bool blobIsPersistent = config.has<COMPILED_BLOB>() ? true
- : config.has<LOADED_FROM_CACHE>() ? config.get<LOADED_FROM_CACHE>()
- : false;
-
- if (!initBlobs.has_value()) {
- return std::make_shared<Graph>(_zeGraphExt,
- _zeroInitStruct,
- mainGraphDesc,
- std::move(networkMeta),
- mainBlob,
- config,
- blobIsPersistent);
- }
-
- // The presence of init schedules means weights separation has been enabled at compilation time. Use a specific
- // "Graph" object as wrapper over all L0 handles.
- std::vector<GraphDescriptor> initGraphDescriptors;
- std::vector<NetworkMetadata> initMetadata;
-
- for (const auto& initBlob : initBlobs.value()) {
- auto initGraphDesc = _zeGraphExt->getGraphDescriptor(initBlob.data(), initBlob.get_byte_size());
-
- initGraphDescriptors.push_back(initGraphDesc);
- initMetadata.push_back(_zeGraphExt->getNetworkMeta(initGraphDesc));
- }
-
- return std::make_shared<WeightlessGraph>(_zeGraphExt,
- _zeroInitStruct,
- mainGraphDesc,
- std::move(networkMeta),
- mainBlob,
- initGraphDescriptors,
- std::move(initMetadata),
- initBlobs,
- std::move(model.value()),
- config,
- blobIsPersistent);
-}
-
ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,
const FilteredConfig& config) const {
OV_ITT_TASK_CHAIN(query_BLOB, itt::domains::NPUPlugin, "DriverCompilerAdapter", "query");
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 b2e544bda73..dbd2f70cb0c 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
@@ -7,6 +7,8 @@
#include <iostream>
#include <iterator>
+#include "compiler_impl.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/config/options.hpp"
#include "intel_npu/prefix.hpp"
#include "intel_npu/utils/utils.hpp"
@@ -404,12 +406,10 @@ void DynamicGraphImpl::predictOutputShape(std::vector<MemRefType>& inputDescript
DynamicGraph::DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,
std::optional<ov::Tensor> blob,
bool blobAllocatedByPlugin,
- const FilteredConfig& config,
- const ov::SoPtr<VCLCompilerImpl>& compiler)
+ const FilteredConfig& config)
: _zeroInitStruct(zeroInitStruct),
_blob(std::move(blob)),
_blobAllocatedByPlugin(blobAllocatedByPlugin),
- _compiler(compiler),
_logger("DynamicGraph", config.get<LOG_LEVEL>()) {
_logger.info("Create DynamicGraph");
if (!config.get<CREATE_EXECUTOR>() || config.get<DEFER_WEIGHTS_LOAD>()) {
@@ -519,14 +519,13 @@ void DynamicGraph::set_workload_type(const ov::WorkloadType workloadType) 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.");
- }
+ auto compiler = VCLCompilerImpl::getInstance();
+ OPENVINO_ASSERT(compiler != nullptr, "VCL compiler is nullptr");
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);
+ return compiler->process_profiling_output(profData, blob);
}
void DynamicGraph::set_argument_value(uint32_t argi, const void* argv) const {
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 02b89772d6b..02d9bdd854b 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -6,6 +6,7 @@
#include <iterator>
+#include "compiler_impl.hpp"
#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/utils.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
@@ -20,7 +21,6 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,
std::optional<ov::Tensor> blob,
const FilteredConfig& config,
const bool blobIsPersistent,
- const ov::SoPtr<VCLCompilerImpl>& compiler,
const bool calledFromWeightlessGraph)
: IGraph(),
_zeGraphExt(zeGraphExt),
@@ -29,7 +29,6 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,
_metadata(std::move(metadata)),
_blob(std::move(blob)),
_blobIsPersistent(blobIsPersistent),
- _compiler(compiler),
_logger("Graph", config.get<LOG_LEVEL>()) {
if (!config.get<CREATE_EXECUTOR>() || config.get<DEFER_WEIGHTS_LOAD>()) {
_logger.info("Graph initialize is deferred from the \"Graph\" constructor");
@@ -139,14 +138,13 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> Graph::export_blob(std
}
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.");
- }
+ auto compiler = VCLCompilerImpl::getInstance();
+ OPENVINO_ASSERT(compiler != nullptr, "Profiling post-processing requires the NPU plugin compiler library");
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);
+ return compiler->process_profiling_output(profData, blob);
}
void Graph::set_argument_value(uint32_t id, const void* data) const {
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp
new file mode 100644
index 00000000000..2449e024475
--- /dev/null
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp
@@ -0,0 +1,111 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "parser.hpp"
+
+#include "dynamic_graph.hpp"
+#include "graph.hpp"
+#include "intel_npu/common/itt.hpp"
+#include "intel_npu/config/options.hpp"
+#include "weightless_graph.hpp"
+
+namespace intel_npu {
+
+Parser::Parser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)
+ : _zeroInitStruct(zeroInitStruct),
+ _logger("Parser", Logger::global().level()) {
+ _logger.info("initialize Parser start");
+
+ _zeGraphExt = std::make_shared<ZeGraphExtWrappers>(_zeroInitStruct);
+
+ OPENVINO_ASSERT(_zeGraphExt != nullptr,
+ "Failed to create ZeGraphExtWrappers in Parser. Please check if the driver is properly installed.");
+}
+
+std::shared_ptr<IGraph> Parser::parse(const ov::Tensor& mainBlob,
+ const FilteredConfig& config,
+ const std::optional<std::vector<ov::Tensor>>& initBlobs,
+ std::optional<std::shared_ptr<const ov::Model>>&& model) const {
+ OV_ITT_TASK_CHAIN(PARSE_BLOB, itt::domains::NPUPlugin, "Parser", "parse");
+
+#ifdef NPU_PLUGIN_DEVELOPER_BUILD
+ const void* data = mainBlob.data();
+ size_t size = mainBlob.get_byte_size();
+ std::string header;
+ if (size >= 20) {
+ header.assign(static_cast<const char*>(data), 20);
+ } else {
+ header.assign(static_cast<const char*>(data), size);
+ }
+ if (header.find("ELF") == std::string::npos) {
+ _logger.debug("Create graph for LLVM IR!");
+ return std::make_shared<DynamicGraph>(_zeroInitStruct, mainBlob, true, config);
+ }
+#endif
+
+ GraphDescriptor mainGraphDesc;
+ NetworkMetadata mainNetworkMetadata;
+
+ _logger.debug("main schedule parse start");
+ OV_ITT_TASK_NEXT(PARSE_BLOB, "getMainGraphDescriptor");
+ mainGraphDesc = _zeGraphExt->getGraphDescriptor(mainBlob.data(), mainBlob.get_byte_size());
+
+ OV_ITT_TASK_NEXT(PARSE_BLOB, "getNetworkMetaMainGraph");
+ mainNetworkMetadata = _zeGraphExt->getNetworkMeta(mainGraphDesc);
+ _logger.debug("main schedule parse end");
+ if (model.has_value()) {
+ mainNetworkMetadata.name = model.value()->get_friendly_name();
+ } else {
+ _logger.debug("networkMeta name is empty in parse!");
+ }
+
+ // exporting the blob when we get it from cache or ov::hint::compiled_blob property
+ // shall be available
+ const bool blobIsPersistent = config.has<COMPILED_BLOB>() ? true
+ : config.has<LOADED_FROM_CACHE>() ? config.get<LOADED_FROM_CACHE>()
+ : false;
+
+ if (!initBlobs.has_value()) {
+ return std::make_shared<Graph>(_zeGraphExt,
+ _zeroInitStruct,
+ mainGraphDesc,
+ std::move(mainNetworkMetadata),
+ mainBlob,
+ config,
+ blobIsPersistent);
+ }
+
+ // The presence of init schedules means weights separation has been enabled at compilation time. Use a specific
+ // "Graph" object as wrapper over all L0 handles.
+ std::vector<GraphDescriptor> initGraphDescriptors;
+ std::vector<NetworkMetadata> initNetworkMetadata;
+
+ _logger.debug("inits schedule parse start");
+ for (const auto& initBlob : initBlobs.value()) {
+ OV_ITT_TASK_NEXT(PARSE_BLOB, "getInitGraphDescriptor");
+ auto initGraphDesc = _zeGraphExt->getGraphDescriptor(initBlob.data(), initBlob.get_byte_size());
+ OV_ITT_TASK_NEXT(PARSE_BLOB, "getNetworkMetaInitGraph");
+ auto initNetworkMeta = _zeGraphExt->getNetworkMeta(initGraphDesc);
+
+ initGraphDescriptors.push_back(initGraphDesc);
+ initNetworkMetadata.push_back(std::move(initNetworkMeta));
+ }
+ _logger.debug("inits schedule parse end");
+
+ OPENVINO_ASSERT(model.has_value(), "Model is required for parsing weightless blobs.");
+
+ return std::make_shared<WeightlessGraph>(_zeGraphExt,
+ _zeroInitStruct,
+ mainGraphDesc,
+ std::move(mainNetworkMetadata),
+ mainBlob,
+ initGraphDescriptors,
+ std::move(initNetworkMetadata),
+ initBlobs,
+ std::move(model.value()),
+ config,
+ blobIsPersistent);
+}
+
+} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/parser_factory.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/parser_factory.cpp
new file mode 100644
index 00000000000..77597670d46
--- /dev/null
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser_factory.cpp
@@ -0,0 +1,19 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_npu/common/parser_factory.hpp"
+
+#include "parser.hpp"
+
+namespace intel_npu {
+
+std::unique_ptr<IParser> ParserFactory::getParser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStructs) const {
+ OPENVINO_ASSERT(
+ zeroInitStructs != nullptr,
+ "Could not find an NPU device. The driver compiler requires a valid device to be present in the system.");
+
+ return std::make_unique<Parser>(zeroInitStructs);
+}
+
+} // namespace intel_npu
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 256669be8c7..eda35fa8c83 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
@@ -73,7 +73,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<con
if (config.get<COMPILATION_MODE>() == "HostCompile") {
// no _compiler::parse call is required. networkmetadata will be obtained in DynamicGraph constructor
_logger.debug("blob is not ELF format, create graph for LLVM IR!");
- return std::make_shared<DynamicGraph>(_zeroInitStruct, std::move(tensor), true, config, _compiler);
+ return std::make_shared<DynamicGraph>(_zeroInitStruct, std::move(tensor), true, config);
}
GraphDescriptor graphDesc;
@@ -102,8 +102,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<con
std::move(networkMeta),
std::move(tensor),
config,
- /* persistentBlob = */ true, // exporting the blob shall be available in such a scenario
- _compiler);
+ /* persistentBlob = */ true); // exporting the blob shall be available in such a scenario
}
std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Model>&& model,
@@ -250,94 +249,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Mod
tensorsInits,
std::move(model),
localConfig,
- /* persistentBlob = */ true, // exporting the blob shall be available in such a scenario
- _compiler);
-}
-
-std::shared_ptr<IGraph> PluginCompilerAdapter::parse(const ov::Tensor& mainBlob,
- const FilteredConfig& config,
- const std::optional<std::vector<ov::Tensor>>& initBlobs,
- std::optional<std::shared_ptr<const ov::Model>>&& model) const {
- OV_ITT_TASK_CHAIN(PARSE_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "parse");
-
- const void* data = mainBlob.data();
- size_t size = mainBlob.get_byte_size();
- std::string header;
- if (size >= 20) {
- header.assign(static_cast<const char*>(data), 20);
- } else {
- header.assign(static_cast<const char*>(data), size);
- }
- if (header.find("ELF") == std::string::npos) {
- // no _compiler::parse call is required. networkmetadata will be obtained in DynamicGraph constructor
- _logger.debug("blob is not ELF format, create graph for LLVM IR!");
- return std::make_shared<DynamicGraph>(_zeroInitStruct, std::move(mainBlob), true, config, _compiler);
- } else {
- _logger.debug("blob is ELF format, create graph for elf blob!");
- }
-
- GraphDescriptor mainGraphDesc;
- NetworkMetadata mainNetworkMetadata;
-
- if (_zeGraphExt) {
- _logger.debug("parse start");
- mainGraphDesc = _zeGraphExt->getGraphDescriptor(mainBlob.data(), mainBlob.get_byte_size());
- mainNetworkMetadata = _zeGraphExt->getNetworkMeta(mainGraphDesc);
- _logger.debug("main schedule parse end");
- if (model) {
- mainNetworkMetadata.name = model.value()->get_friendly_name();
- } else {
- _logger.info("networkMeta name is empty in parse!");
- }
- } else {
- _logger.warning("no zeGraphExt, metadata is empty from vcl compiler.");
- }
-
- // exporting the blob when we get it from cache or ov::hint::compiled_blob property
- // shall be available
- const bool blobIsPersistent = config.has<COMPILED_BLOB>() ? true
- : config.has<LOADED_FROM_CACHE>() ? config.get<LOADED_FROM_CACHE>()
- : false;
-
- if (!initBlobs.has_value()) {
- return std::make_shared<Graph>(_zeGraphExt,
- _zeroInitStruct,
- mainGraphDesc,
- std::move(mainNetworkMetadata),
- mainBlob,
- config,
- blobIsPersistent,
- _compiler);
- }
-
- // The presence of init schedules means weights separation has been enabled at compilation time. Use a specific
- // "Graph" object as wrapper over all L0 handles.
- std::vector<GraphDescriptor> initGraphDescriptors;
- std::vector<NetworkMetadata> initNetworkMetadata;
-
- for (const auto& initBlob : initBlobs.value()) {
- if (_zeGraphExt) {
- auto initGraphDesc = _zeGraphExt->getGraphDescriptor(initBlob.data(), initBlob.get_byte_size());
- auto initNetworkMeta = _zeGraphExt->getNetworkMeta(initGraphDesc);
-
- initGraphDescriptors.push_back(initGraphDesc);
- initNetworkMetadata.push_back(std::move(initNetworkMeta));
- }
- }
-
- _logger.debug("init schedules parse end");
- return std::make_shared<WeightlessGraph>(_zeGraphExt,
- _zeroInitStruct,
- mainGraphDesc,
- std::move(mainNetworkMetadata),
- mainBlob,
- initGraphDescriptors,
- std::move(initNetworkMetadata),
- initBlobs,
- std::move(model.value()),
- config,
- blobIsPersistent,
- _compiler);
+ /* persistentBlob = */ true); // exporting the blob shall be available in such a scenario
}
ov::SupportedOpsMap PluginCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,
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 f17c2cfcf76..ec6b8b328c2 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
@@ -157,8 +157,7 @@ WeightlessGraph::WeightlessGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGr
std::optional<std::vector<ov::Tensor>> initBlobs,
std::shared_ptr<const ov::Model>&& model,
const FilteredConfig& config,
- const bool blobIsPersistent,
- const ov::SoPtr<VCLCompilerImpl>& compiler)
+ const bool blobIsPersistent)
: Graph(zeGraphExt,
zeroInitStruct,
mainGraphDesc,
@@ -166,7 +165,6 @@ WeightlessGraph::WeightlessGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGr
std::move(mainBlob),
config,
blobIsPersistent,
- compiler,
true),
_initsGraphDesc(initGraphDesc),
_initBlobs(std::move(initBlobs)),
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 1669e57fb67..a475d47c7c7 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -7,13 +7,13 @@
#include <fstream>
#include "compiled_model.hpp"
-#include "compiler_adapter_factory.hpp"
-#include "driver_compiler_adapter.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/device_helpers.hpp"
#include "intel_npu/common/filtered_config.hpp"
#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/igraph.hpp"
#include "intel_npu/common/itt.hpp"
+#include "intel_npu/common/parser_factory.hpp"
#include "intel_npu/config/npuw.hpp"
#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/utils.hpp"
@@ -369,7 +369,7 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCo
if (device) {
auto platformName = device->getName();
CompilerAdapterFactory compilerFactory;
- auto compileType = compilerFactory.determinteAppropriateCompilerTypeBasedOnPlatform(platformName);
+ auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);
if (compileType == ov::intel_npu::CompilerType::DRIVER) {
config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});
}
@@ -956,18 +956,12 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
// list of properties
auto originalModel = exclude_model_ptr_from_map(localProperties);
- ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);
- auto deviceId = _propertiesManager->determineDeviceId(localProperties);
-
- std::shared_ptr<IDevice> device = utils::getDeviceById(_backend, deviceId);
+ std::shared_ptr<IDevice> device =
+ utils::getDeviceById(_backend, _propertiesManager->determineDeviceId(localProperties));
- const auto compilationPlatform =
- utils::getCompilationPlatform(_propertiesManager->determinePlatform(localProperties),
- device == nullptr ? deviceId : device->getName(),
- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());
-
- CompilerAdapterFactory factory;
- auto compiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
+ if (_backend == nullptr || device == nullptr) {
+ OPENVINO_THROW("Device not found.");
+ }
OV_ITT_TASK_CHAIN(PLUGIN_PARSE_MODEL, itt::domains::NPUPlugin, "Plugin::parse", "fork_local_config");
FilteredConfig localConfig = _propertiesManager->getConfigWithCompilerPropertiesDisabled(localProperties);
@@ -1047,11 +1041,22 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
const std::optional<std::vector<ov::Tensor>> initBlobs =
weightsSeparationEnabled ? std::make_optional(std::move(tensorsInits)) : std::nullopt;
- auto graph =
- compiler->parse(tensorMain,
- localConfig,
- initBlobs,
- weightsSeparationEnabled ? std::make_optional(std::move(originalModel)) : std::nullopt);
+ // Special case for PERF_COUNT as it requires compiler_type detection in case it is still set to PREFER_PLUGIN
+ if (localConfig.has<PERF_COUNT>() && localConfig.get<PERF_COUNT>() &&
+ localConfig.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
+ ov::intel_npu::CompilerType compilerType = localConfig.get<COMPILER_TYPE>();
+ CompilerAdapterFactory factory;
+ (void)factory.getCompiler(_backend, compilerType, device->getName());
+
+ localConfig.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compilerType)}});
+ }
+
+ ParserFactory parserFactory;
+ auto parser = parserFactory.getParser(_backend->getInitStructs());
+ auto graph = parser->parse(tensorMain,
+ localConfig,
+ initBlobs,
+ weightsSeparationEnabled ? std::make_optional(std::move(originalModel)) : std::nullopt);
graph->update_network_name("net" + std::to_string(_compiledModelLoadCounter++));
const std::shared_ptr<ov::Model> modelDummy =
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index 352425d7d31..a7d7a0ddb70 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -5,7 +5,7 @@
// Plugin
#include "properties.hpp"
-#include "compiler_adapter_factory.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/device_helpers.hpp"
#include "intel_npu/config/npuw.hpp"
#include "intel_npu/config/options.hpp"
@@ -716,6 +716,7 @@ void Properties::registerPluginProperties() {
CompilerAdapterFactory factory;
auto dummyCompiler = factory.getCompiler(_backend, compilerType, compilationPlatform);
+
return dummyCompiler->get_version();
});
REGISTER_CUSTOM_METRIC(ov::internal::caching_properties, false, [&](const Config& config) {
@@ -760,9 +761,9 @@ void Properties::registerCompiledModelProperties() {
TRY_REGISTER_SIMPLE_PROPERTY(ov::compilation_num_threads, COMPILATION_NUM_THREADS);
TRY_REGISTER_SIMPLE_PROPERTY(ov::hint::inference_precision, INFERENCE_PRECISION_HINT);
TRY_REGISTER_SIMPLE_PROPERTY(ov::cache_mode, CACHE_MODE);
- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::compiler_type, COMPILER_TYPE);
// Properties we shall only enable if they were set prior-to-compilation
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::compiler_type, COMPILER_TYPE);
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::weights_path, WEIGHTS_PATH);
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::cache_dir, CACHE_DIR);
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::enable_profiling, PERF_COUNT);
@@ -1058,9 +1059,6 @@ FilteredConfig Properties::getConfigWithCompilerPropertiesDisabled(const ov::Any
disableCompilerProperties(updatedConfig, _backend);
}
- // Special case for NPU_COMPILER_TYPE - don't need it in the config for this case.
- updatedConfig.enable(ov::intel_npu::compiler_type.name(), false);
-
if (properties.empty()) {
return updatedConfig;
}
@@ -1068,8 +1066,7 @@ FilteredConfig Properties::getConfigWithCompilerPropertiesDisabled(const ov::Any
const std::map<std::string, std::string> rawConfig = any_copy(properties);
std::map<std::string, std::string> cfgsToSet;
for (const auto& [key, value] : rawConfig) {
- if ((updatedConfig.hasOpt(key) && updatedConfig.getOpt(key).mode() == OptionMode::CompileTime) ||
- key == ov::intel_npu::compiler_type.name()) {
+ if ((updatedConfig.hasOpt(key) && updatedConfig.getOpt(key).mode() == OptionMode::CompileTime)) {
_logger.info(
"Config key '%s' is recognized as a compiler option, will not be used for current configuration.",
key.c_str());
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
index 11c8f29949f..f1cfba3bf9d 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
@@ -16,6 +16,20 @@ using namespace ov::test::behavior;
namespace {
+class LogCallbackGuard {
+public:
+ explicit LogCallbackGuard(const std::function<void(std::string_view)>& callback) {
+ ov::util::set_log_callback(callback);
+ }
+
+ ~LogCallbackGuard() {
+ ov::util::reset_log_callback();
+ }
+
+ LogCallbackGuard(const LogCallbackGuard&) = delete;
+ LogCallbackGuard& operator=(const LogCallbackGuard&) = delete;
+};
+
// ExecutableNetwork Properties tests
class ClassExecutableNetworkGetPropertiesTestNPU
: public OVCompiledModelPropertiesBase,
@@ -310,12 +324,14 @@ TEST_P(CheckCompilerTypeProperty, CheckLogAfterSettingExtraConfigToGetProperty)
core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));
- ov::util::set_log_callback(log_cb);
- auto compiler_type = core.get_property(
- deviceName,
- ov::intel_npu::compiler_type,
- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER), ov::intel_npu::qdq_optimization(true)});
- ov::util::reset_log_callback();
+ auto compiler_type = ov::intel_npu::CompilerType::PLUGIN;
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ compiler_type = core.get_property(
+ deviceName,
+ ov::intel_npu::compiler_type,
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER), ov::intel_npu::qdq_optimization(true)});
+ }
ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
@@ -338,22 +354,24 @@ TEST_P(CheckCompilerTypeProperty, CheckLogAfterGettingPropertyWithExtraConfig) {
logs.push_back('\n');
};
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.get_property(deviceName,
- ov::intel_npu::defer_weights_load,
- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.get_property(deviceName,
+ ov::intel_npu::defer_weights_load,
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));
+ }
ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.get_property(
- deviceName,
- ov::intel_npu::defer_weights_load,
- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER), ov::intel_npu::qdq_optimization(true)}));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.get_property(deviceName,
+ ov::intel_npu::defer_weights_load,
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::qdq_optimization(true)}));
+ }
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
}
@@ -372,19 +390,21 @@ TEST_P(CheckCompilerTypeProperty, SetRuntimeProperty) {
logs.push_back('\n');
};
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(
- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));
- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(
+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));
+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));
+ }
ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
+ }
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
}
@@ -403,34 +423,38 @@ TEST_P(CheckCompilerTypeProperty, SetCompilerPropertyForDifferentCompiler) {
logs.push_back('\n');
};
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(
- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));
- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(
+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));
+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));
+ }
ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
+ }
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(
- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(
+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));
+ }
ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));
+ }
ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
}
@@ -450,9 +474,10 @@ TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {
OV_ASSERT_NO_THROW(
core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));
+ }
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
@@ -460,19 +485,21 @@ TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {
OV_ASSERT_NO_THROW(
core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));
+ }
ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
logs.clear();
- ov::util::set_log_callback(log_cb);
- OV_ASSERT_NO_THROW(core.get_property(deviceName,
- ov::intel_npu::compiler_version,
- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.get_property(deviceName,
+ ov::intel_npu::compiler_version,
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));
+ }
ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
@@ -512,10 +539,12 @@ TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithCompiler
logs.push_back('\n');
};
- ov::util::set_log_callback(log_cb);
- core_import.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
- OV_ASSERT_NO_THROW(core_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));
- ov::util::reset_log_callback();
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ core_import.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
+ OV_ASSERT_NO_THROW(
+ core_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));
+ }
ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),
std::string::npos);
@@ -564,12 +593,93 @@ TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithRuntimeP
{{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
ov::workload_type(ov::WorkloadType::EFFICIENT)}}));
- ASSERT_THROW(imported_model.get_property(ov::intel_npu::compiler_type),
- ov::Exception); // Expect to throw due to unsupported property
+ ov::intel_npu::CompilerType compiler_type = ov::intel_npu::CompilerType::PLUGIN;
+ OV_ASSERT_NO_THROW(compiler_type = imported_model.get_property(ov::intel_npu::compiler_type));
+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);
ov::WorkloadType workload_type = ov::WorkloadType::DEFAULT;
OV_ASSERT_NO_THROW(workload_type = imported_model.get_property(ov::workload_type));
ASSERT_TRUE(workload_type == ov::WorkloadType::EFFICIENT);
}
+TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerProperty) {
+ std::string logs;
+ std::mutex logs_mutex;
+ ov::Core core_for_compiler;
+ ov::Core core_for_importing;
+ ov::CompiledModel compiled_model;
+ std::stringstream export_stream;
+
+ OV_ASSERT_NO_THROW(compiled_model = core_for_compiler.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));
+ compiled_model = {};
+
+ core_for_importing.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
+
+ // Keep this std::function alive while logging is active.
+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {
+ std::lock_guard<std::mutex> lock(logs_mutex);
+ logs.append(msg);
+ logs.push_back('\n');
+ };
+
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(
+ core_for_importing.import_model(export_stream,
+ deviceName,
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::platform("5010"),
+ ov::intel_npu::qdq_optimization(true)}}));
+ }
+
+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
+ ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "
+ "configuration."),
+ std::string::npos);
+ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "
+ "current configuration."),
+ std::string::npos);
+}
+
+TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerPropertyAfterCompiling) {
+ std::string logs;
+ std::mutex logs_mutex;
+ ov::Core core;
+ ov::CompiledModel compiled_model;
+ std::stringstream export_stream;
+
+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));
+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));
+ compiled_model = {};
+
+ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));
+
+ // Keep this std::function alive while logging is active.
+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {
+ std::lock_guard<std::mutex> lock(logs_mutex);
+ logs.append(msg);
+ logs.push_back('\n');
+ };
+
+ {
+ LogCallbackGuard log_callback_guard(log_cb);
+ OV_ASSERT_NO_THROW(core.import_model(export_stream,
+ deviceName,
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::platform("5010"),
+ ov::intel_npu::qdq_optimization(true)}}));
+ }
+
+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);
+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);
+ ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "
+ "configuration."),
+ std::string::npos);
+ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "
+ "current configuration."),
+ std::string::npos);
+}
+
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
index 5aca81e6784..ae0823bb6ee 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
@@ -30,6 +30,11 @@ TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImpor
custom_logger << s << std::endl;
};
ov::util::set_log_callback(custom_log_callback);
+ struct ResetLogCallbackGuard {
+ ~ResetLogCallbackGuard() {
+ ov::util::reset_log_callback();
+ }
+ } reset_log_callback_guard;
for (size_t i = 0; i < 2; ++i) {
if (i != 0) {
@@ -38,7 +43,6 @@ TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImpor
std::ignore = core->compile_model(m_modelName, targetDevice, configuration);
configuration.erase(ov::log::level.name());
}
- ov::util::reset_log_callback();
EXPECT_THAT(custom_logger.str(),
::testing::HasSubstr("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"));
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/dynamic_host_pipeline/infer_with_host_compile.hpp b/src/plugins/intel_npu/tests/functional/internal/dynamic_host_pipeline/infer_with_host_compile.hpp
index f15d37e410a..25c158abafb 100644
--- a/src/plugins/intel_npu/tests/functional/internal/dynamic_host_pipeline/infer_with_host_compile.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/dynamic_host_pipeline/infer_with_host_compile.hpp
@@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
+#pragma once
+
#include <common_test_utils/ov_tensor_utils.hpp>
#include <iostream>
#include <sstream>
@@ -77,6 +79,46 @@ protected:
ov::AnyMap configuration;
};
+TEST_P(InferWithHostCompileTests, Compile) {
+ // Skip test according to plugin specific disabledTestPatterns() (if any)
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ auto model = createMaxPoolModel();
+
+ ov::CompiledModel compiledModel;
+ // Compilation shall pass since load of npu_mlir_runtime is deffered with NPU_CREATE_EXECUTOR=0
+ OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));
+
+ std::stringstream modelStream;
+ OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));
+
+ // With HostCompile, the modelStream shall contain "llvm.func"
+ std::string line;
+ auto pos = modelStream.tellg();
+ modelStream.seekg(0, std::ios::beg);
+ bool isLLVMStream = false;
+ int searchRegion = 10;
+ while (std::getline(modelStream, line)) {
+ if (line.find("llvm.func") != std::string::npos) {
+ modelStream.clear();
+ modelStream.seekg(pos);
+ isLLVMStream = true;
+ break;
+ }
+ if (searchRegion-- < 0) {
+ break;
+ }
+ }
+ modelStream.clear();
+ modelStream.seekg(pos);
+ ASSERT_TRUE(isLLVMStream) << "CompiledStream from HostCompile mode shall has 'llvm.func' inside it";
+
+ ov::InferRequest reqDynamic;
+ // Add shape check once npu_mlir_runtime is inside test package
+ EXPECT_THROW(reqDynamic = compiledModel.create_infer_request(), ov::Exception);
+}
+
+#ifdef NPU_PLUGIN_DEVELOPER_BUILD
+
TEST_P(InferWithHostCompileTests, CompileAndImport) {
// Skip test according to plugin specific disabledTestPatterns() (if any)
SKIP_IF_CURRENT_TEST_IS_DISABLED()
@@ -118,6 +160,8 @@ TEST_P(InferWithHostCompileTests, CompileAndImport) {
EXPECT_THROW(reqDynamic = importedModel.create_infer_request(), ov::Exception);
}
+#endif
+
} // namespace behavior
} // namespace test
} // namespace ov