Skip to content

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

[NPU] Remove the option ENABLE_MLIR_COMPILER and ICompiler (#33589)

Wenjing Kang99f90bc4d9c8
diff --git a/src/plugins/intel_npu/cmake/features.cmake b/src/plugins/intel_npu/cmake/features.cmake
index ebfb23a9a07..51ee1458315 100644
--- a/src/plugins/intel_npu/cmake/features.cmake
+++ b/src/plugins/intel_npu/cmake/features.cmake
@@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
#
-ov_option(ENABLE_MLIR_COMPILER "Enable compilation of npu_mlir_compiler libraries" ON)
-
ov_option(ENABLE_NPU_PLUGIN_ENGINE "Enable compilation of NPU plugin engine" ON)
if(NOT ENABLE_NPU_PLUGIN_ENGINE AND ENABLE_TESTS)
diff --git a/src/plugins/intel_npu/src/al/CMakeLists.txt b/src/plugins/intel_npu/src/al/CMakeLists.txt
index d4faab04c23..8fda6c45325 100644
--- a/src/plugins/intel_npu/src/al/CMakeLists.txt
+++ b/src/plugins/intel_npu/src/al/CMakeLists.txt
@@ -22,10 +22,6 @@ target_include_directories(${TARGET_NAME}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
-if(ENABLE_MLIR_COMPILER)
- target_compile_definitions(${TARGET_NAME} PRIVATE ENABLE_MLIR_COMPILER)
-endif()
-
target_link_libraries(${TARGET_NAME}
PUBLIC
openvino::npu_logger_utils
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/icompiler.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/icompiler.hpp
deleted file mode 100644
index ea6bad78fa7..00000000000
--- a/src/plugins/intel_npu/src/al/include/intel_npu/icompiler.hpp
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (C) 2018-2026 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-// Compiler Interface
-
-#pragma once
-
-#include "intel_npu/config/config.hpp"
-#include "intel_npu/network_metadata.hpp"
-#include "openvino/runtime/profiling_info.hpp"
-
-namespace intel_npu {
-
-#ifndef ICOMPILER_MAKE_VERSION
-/// @brief Generates npu compiler (generic 'oneAPI') API version number
-# define ICOMPILER_MAKE_VERSION(_major, _minor) ((_major << 16) | (_minor & 0x0000ffff))
-#endif // ICOMPILER_MAKE_VERSION
-
-/**
- * @struct NetworkDescription
- * @brief The object returned by the compiler
- * to provide such information about a network as description of inputs and outputs,
- * name and compiled network in a format executable by device
- */
-struct NetworkDescription final {
- NetworkDescription(std::vector<uint8_t>&& compiledNetwork, NetworkMetadata&& metadata)
- : compiledNetwork(std::move(compiledNetwork)),
- metadata(std::move(metadata)) {}
- NetworkDescription(ov::Tensor&& compiledNetWorkTensor, NetworkMetadata&& metadata)
- : compiledNetwork(),
- metadata(std::move(metadata)),
- compiledNetworkTensor(std::move(compiledNetWorkTensor)) {}
- // Force move semantics to prevent blob copies
- NetworkDescription(const NetworkDescription&) = delete;
- NetworkDescription(NetworkDescription&&) = default;
- NetworkDescription& operator=(const NetworkDescription&) = delete;
- NetworkDescription& operator=(NetworkDescription&&) = default;
- ~NetworkDescription() = default;
-
- std::vector<uint8_t> compiledNetwork;
-
- NetworkMetadata metadata;
-
- ov::Tensor compiledNetworkTensor;
-};
-
-/**
- * @interface ICompiler
- * @brief An interface to be implemented by a concrete compiler to provide
- * methods for preparing a network for execution on a NPU device
- */
-class ICompiler : public std::enable_shared_from_this<ICompiler> {
-public:
- /**
- * @brief Transforms a network from the OpenVINO model representation to a format executable
- * by a NPU device
- * @param model a shared pointer to the OpenVINO model to be compiled
- * @param config a reference to NPUConfig containing plugin config options
- * including config options related to compilation
- * @return a shared pointer on an object implementing NetworkDescription interface
- */
- virtual NetworkDescription compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0;
-
- /**
- * @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in
- * the same scope.
- * @return A "NetworkDescription" object for each init schedule, followed by another one corresponding to the main
- * part.
- */
- virtual std::vector<std::shared_ptr<NetworkDescription>> compileWsOneShot(
- const std::shared_ptr<ov::Model>& /*model*/,
- const Config& /*config*/) const {
- OPENVINO_NOT_IMPLEMENTED;
- }
-
- /**
- * @brief Sequential compilation of Init(s) and Main
- *
- * "Stateless compiler" approach
- * We want to get multiple Inits in the case of a large number of weights.
- * This allows us to build pipeline:
- * Allocate W1 -> Init1
- * Allocate W2 -> Init2
- * Allocate W3 -> Init2
- *
- * This is why there is an additional parameter callNumber:
- * Compiler should somehow understand wich Init(or Main) to return
- * Plugin does not know total numbers of Init schedules
- */
- virtual NetworkDescription compileWsIterative(const std::shared_ptr<ov::Model>& /*model*/,
- const Config& /*config*/,
- size_t /*callNumber*/) const {
- OPENVINO_NOT_IMPLEMENTED;
- }
-
- /**
- * @brief Returns information about supported layers of the network passed
- * @param model The model to be queried
- * @param config A reference to NPUConfig containing plugin config options
- * including config options related to compilation
- * @returns SupportedOpsMap structure with information about supported layers
- */
- virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0;
-
- /**
- * @brief Parses already compiled network to extract meta information:
- * inputs and outputs descriptions
- * @param network compiled network represented as a vector of char
- * @param config a reference to NPUConfig containing plugin config options
- * Note: compilation options will be ignored,
- * since the network is already compiled
- * @return a shared pointer on an object implementing NetworkDescription interface
- */
- virtual NetworkMetadata parse(const std::vector<uint8_t>& network, const Config& config) const = 0;
-
- /**
- * @brief Returns the compiler version
- * @return composite uint32_t value of compiler version.
- * MSB 16 bits = Major version
- * LSB 16bits = Minor version
- */
- virtual uint32_t get_version() const = 0;
-
- virtual std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
- const std::vector<uint8_t>& network,
- const Config& config) const = 0;
-
-protected:
- virtual ~ICompiler() = default;
-};
-
-} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
index 2aec07d42fe..78f5492e890 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
@@ -18,6 +18,7 @@
#include "openvino/core/partial_shape.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/runtime/common.hpp"
+#include "openvino/runtime/profiling_info.hpp"
namespace intel_npu {
@@ -155,7 +156,34 @@ struct NetworkMetadata final {
* to the index of the entry which bears the same name.
*/
void bindRelatedDescriptors();
+};
-}; // namespace intel_npu
+/**
+ * @struct NetworkDescription
+ * @brief The object returned by the compiler
+ * to provide such information about a network as description of inputs and outputs,
+ * name and compiled network in a format executable by device
+ */
+struct NetworkDescription final {
+ NetworkDescription(std::vector<uint8_t>&& compiledNetwork, NetworkMetadata&& metadata)
+ : compiledNetwork(std::move(compiledNetwork)),
+ metadata(std::move(metadata)) {}
+ NetworkDescription(ov::Tensor&& compiledNetWorkTensor, NetworkMetadata&& metadata)
+ : compiledNetwork(),
+ metadata(std::move(metadata)),
+ compiledNetworkTensor(std::move(compiledNetWorkTensor)) {}
+ // Force move semantics to prevent blob copies
+ NetworkDescription(const NetworkDescription&) = delete;
+ NetworkDescription(NetworkDescription&&) = default;
+ NetworkDescription& operator=(const NetworkDescription&) = delete;
+ NetworkDescription& operator=(NetworkDescription&&) = default;
+ ~NetworkDescription() = default;
+
+ std::vector<uint8_t> compiledNetwork;
+
+ NetworkMetadata metadata;
+
+ ov::Tensor compiledNetworkTensor;
+};
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/al/src/icompiler.cpp b/src/plugins/intel_npu/src/al/src/network_metadata.cpp
similarity index 98%
rename from src/plugins/intel_npu/src/al/src/icompiler.cpp
rename to src/plugins/intel_npu/src/al/src/network_metadata.cpp
index dbb67a1029a..5d59a6afee3 100644
--- a/src/plugins/intel_npu/src/al/src/icompiler.cpp
+++ b/src/plugins/intel_npu/src/al/src/network_metadata.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
-#include "intel_npu/icompiler.hpp"
+#include "intel_npu/network_metadata.hpp"
namespace intel_npu {
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 623a44a7862..3a7654f5cbe 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
@@ -9,35 +9,83 @@
#include "compiler.h"
#include "intel_npu/common/filtered_config.hpp"
-#include "intel_npu/icompiler.hpp"
+#include "intel_npu/network_metadata.hpp"
#include "openvino/core/except.hpp"
namespace intel_npu {
-class VCLCompilerImpl final : public intel_npu::ICompiler {
+class VCLCompilerImpl final : public std::enable_shared_from_this<VCLCompilerImpl> {
public:
VCLCompilerImpl();
- ~VCLCompilerImpl() override;
+ ~VCLCompilerImpl();
static const std::shared_ptr<VCLCompilerImpl> getInstance();
- NetworkDescription compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
+ /**
+ * @brief Transforms a network from the OpenVINO model representation to a format executable
+ * by a NPU device
+ * @param model a shared pointer to the OpenVINO model to be compiled
+ * @param config a reference to NPUConfig containing plugin config options
+ * 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;
+ /**
+ * @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in
+ * the same scope.
+ * @return A "NetworkDescription" object for each init schedule, followed by another one corresponding to the main
+ * part.
+ */
std::vector<std::shared_ptr<NetworkDescription>> compileWsOneShot(const std::shared_ptr<ov::Model>& model,
- const Config& config) const override;
-
+ const Config& config) const;
+ /**
+ * @brief Sequential compilation of Init(s) and Main
+ *
+ * "Stateless compiler" approach
+ * We want to get multiple Inits in the case of a large number of weights.
+ * This allows us to build pipeline:
+ * Allocate W1 -> Init1
+ * Allocate W2 -> Init2
+ * Allocate W3 -> Init2
+ *
+ * This is why there is an additional parameter callNumber:
+ * Compiler should somehow understand wich Init(or Main) to return
+ * Plugin does not know total numbers of Init schedules
+ */
NetworkDescription compileWsIterative(const std::shared_ptr<ov::Model>& model,
const Config& config,
- size_t callNumber) const override;
-
- ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
+ size_t callNumber) const;
+ /**
+ * @brief Returns information about supported layers of the network passed
+ * @param model The model to be queried
+ * @param config A reference to NPUConfig containing plugin config options
+ * 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;
- NetworkMetadata parse(const std::vector<uint8_t>& network, const Config& config) const override;
+ /**
+ * @brief Parses already compiled network to extract meta information:
+ * inputs and outputs descriptions
+ * @param network compiled network represented as a vector of char
+ * @param config a reference to NPUConfig containing plugin config options
+ * Note: compilation options will be ignored,
+ * 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;
- uint32_t get_version() const override;
+ /**
+ * @brief Returns the compiler version
+ * @return composite uint32_t value of compiler version.
+ * MSB 16 bits = Major version
+ * LSB 16bits = Minor version
+ */
+ 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 final override;
+ const intel_npu::Config& config) const;
bool get_supported_options(std::vector<char>& options) const;
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 4176d28f5e4..903e9f27c52 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
@@ -8,8 +8,8 @@
#include <ze_graph_ext.h>
+#include "compiler_impl.hpp"
#include "intel_npu/common/igraph.hpp"
-#include "intel_npu/icompiler.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "openvino/runtime/so_ptr.hpp"
#include "ze_graph_ext_wrappers.hpp"
@@ -25,7 +25,7 @@ public:
std::optional<ov::Tensor> blob,
const Config& config,
const bool blobIsPersistent = false,
- const ov::SoPtr<ICompiler>& compiler = {nullptr},
+ 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;
@@ -94,7 +94,7 @@ protected:
*/
std::optional<std::size_t> _batchSize = std::nullopt;
- const ov::SoPtr<ICompiler> _compiler;
+ const ov::SoPtr<VCLCompilerImpl> _compiler;
Logger _logger;
};
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp
index 994167e276d..c0aac94bb46 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
@@ -6,8 +6,8 @@
#pragma once
+#include "compiler_impl.hpp"
#include "intel_npu/common/icompiler_adapter.hpp"
-#include "intel_npu/icompiler.hpp"
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "openvino/runtime/so_ptr.hpp"
@@ -44,7 +44,7 @@ private:
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;
- ov::SoPtr<ICompiler> _compiler;
+ ov::SoPtr<VCLCompilerImpl> _compiler;
Logger _logger;
};
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 d94c5b0c4d0..b6666eb0c3e 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,6 +6,7 @@
#pragma once
+#include "compiler_impl.hpp"
#include "graph.hpp"
#include "intel_npu/utils/zero/zero_host_tensor.hpp"
#include "openvino/op/constant.hpp"
@@ -32,7 +33,7 @@ public:
const std::shared_ptr<const ov::Model>& model,
const Config& config,
const bool blobIsPersistent = false,
- const ov::SoPtr<ICompiler>& compiler = {nullptr});
+ const ov::SoPtr<VCLCompilerImpl>& compiler = {nullptr});
/**
* @brief The main schedule along with the weights initialization ones are exported.
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 03662b02bab..c801b7c007c 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -20,7 +20,7 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,
std::optional<ov::Tensor> blob,
const Config& config,
const bool blobIsPersistent,
- const ov::SoPtr<ICompiler>& compiler,
+ const ov::SoPtr<VCLCompilerImpl>& compiler,
const bool calledFromWeightlessGraph)
: IGraph(),
_zeGraphExt(zeGraphExt),
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 74fa2a641f9..f33f9ed4098 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
@@ -7,7 +7,6 @@
#include <memory>
#include <string>
-#include "compiler_impl.hpp"
#include "graph.hpp"
#include "intel_npu/common/device_helpers.hpp"
#include "intel_npu/common/itt.hpp"
@@ -27,25 +26,6 @@
namespace {
-std::shared_ptr<intel_npu::ICompiler> get_compiler(std::shared_ptr<void> so) {
- static constexpr auto CreateFuncName = "CreateNPUCompiler";
- auto symbol = ov::util::get_symbol(so, CreateFuncName);
-
- using CreateFuncT = void (*)(std::shared_ptr<intel_npu::ICompiler>&);
- const auto createFunc = reinterpret_cast<CreateFuncT>(symbol);
-
- std::shared_ptr<intel_npu::ICompiler> compilerPtr;
- createFunc(compilerPtr);
- return compilerPtr;
-}
-
-ov::SoPtr<intel_npu::ICompiler> load_compiler(const std::filesystem::path& libpath) {
- auto compilerSO = ov::util::load_shared_object(libpath);
- auto compiler = get_compiler(compilerSO);
-
- return ov::SoPtr<intel_npu::ICompiler>(compiler, compilerSO);
-}
-
ov::Tensor make_tensor_from_vector(std::vector<uint8_t>& vector) {
auto tensor = ov::Tensor(ov::element::u8, ov::Shape{vector.size()}, vector.data());
auto impl = ov::get_tensor_impl(std::move(tensor));
@@ -71,22 +51,9 @@ PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr<ZeroInitStruc
auto vclLib = vclCompilerPtr->getLinkedLibrary();
_logger.info("PLUGIN VCL compiler is loading");
OPENVINO_ASSERT(vclLib != nullptr, "VCL library is nullptr");
- _compiler = ov::SoPtr<intel_npu::ICompiler>(vclCompilerPtr, vclLib);
+ _compiler = ov::SoPtr<VCLCompilerImpl>(vclCompilerPtr, vclLib);
} catch (const std::exception& vcl_exception) {
- _logger.info("VCL compiler load failed: %s. Trying to load MLIR compiler...", vcl_exception.what());
- std::string baseName = "npu_mlir_compiler";
- auto libPath = ov::util::make_plugin_library_name(ov::util::get_ov_lib_path(), baseName + OV_BUILD_POSTFIX);
- try {
- _compiler = load_compiler(libPath);
- if (!_compiler) {
- throw std::runtime_error("MLIR compiler load returned nullptr");
- } else {
- _logger.info("MLIR compiler loaded successfully. PLUGIN compiler will be used.");
- }
- } catch (const std::exception& mlir_exception) {
- _logger.info("MLIR compiler load failed: %s", mlir_exception.what());
- throw std::runtime_error("Both VCL and MLIR compiler load failed, aborting.");
- }
+ OPENVINO_THROW("VCL compiler loading failed, aborting. Error: ", vcl_exception.what());
}
if (_zeroInitStruct == nullptr) {
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 a5f4d75aabe..cbb07ec0b9e 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
@@ -158,7 +158,7 @@ WeightlessGraph::WeightlessGraph(const std::shared_ptr<ZeGraphExtWrappers>& zeGr
const std::shared_ptr<const ov::Model>& model,
const Config& config,
const bool blobIsPersistent,
- const ov::SoPtr<ICompiler>& compiler)
+ const ov::SoPtr<VCLCompilerImpl>& compiler)
: Graph(zeGraphExt,
zeroInitStruct,
mainGraphDesc,