Skip to content

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

[NPU] Move VCL loader ownership to the Plugin (#39413)

Alexandru Enachee056e34af192
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
index e0deb45c9cb..c2efaf24ace 100644
--- 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
@@ -4,51 +4,103 @@
#pragma once
-#include <atomic>
-#include <cstdint>
#include <memory>
-#include <optional>
#include <string_view>
-#include <utility>
#include <vector>
#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/npu.hpp"
#include "intel_npu/common/option_support_cache.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
namespace intel_npu {
+/**
+ * @brief Creates an adapter for the selected NPU compiler.
+ *
+ * A factory is bound to one backend and one VCL provider.
+ *
+ * Share one instance, for example through a `std::shared_ptr<const CompilerAdapterFactory>`, among requests that use
+ * the same backend and provider.
+ */
class CompilerAdapterFactory final {
public:
- std::unique_ptr<ICompilerAdapter> getCompiler(
- const ov::SoPtr<IEngineBackend>& engineBackend,
- ov::intel_npu::CompilerType& compilerType,
- std::string_view platform,
- const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr) const;
+ /**
+ * @brief Creates a factory for the given backend and VCL provider.
+ *
+ * Driver-only operations do not require a provider; a missing provider is rejected only if a VCL compiler is
+ * actually needed.
+ * @param engineBackend The backend that provides the device and Level Zero structures. May be empty for offline
+ * compilation with the compiler-in-plugin.
+ * @param vclFunctionsProvider Supplies VCL entry points when a compiler-in-plugin is needed.
+ * @param optionSupportCache Shared compiler option cache. Null disables caching.
+ */
+ CompilerAdapterFactory(const ov::SoPtr<IEngineBackend>& engineBackend,
+ const VCLFunctionTableProvider& vclFunctionsProvider,
+ const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr);
+ CompilerAdapterFactory(const CompilerAdapterFactory&) = delete;
+ CompilerAdapterFactory& operator=(const CompilerAdapterFactory&) = delete;
+
+ /**
+ * @brief Creates the compiler adapter and writes the resolved type back to `compilerType`.
+ *
+ * PREFER_PLUGIN is resolved like in decideCompilerType(): resolution only loads the function table. If loading
+ * fails during online compilation, the request falls back to DRIVER. A later compiler creation failure, or an
+ * explicit PLUGIN request failure, throws without fallback. A provider that caches its load failure, like the one
+ * of the plugin, rethrows it on every later call.
+ *
+ * @param[in,out] compilerType The requested compiler type on input; the type of the returned adapter on output
+ * (never PREFER_PLUGIN).
+ * @param platform The compilation target platform. Empty means no explicit target, which is treated as online
+ * compilation on the backend device.
+ * @return The compiler adapter. Never null.
+ * @throws ov::Exception if the requested compiler cannot be created, if the driver compiler is selected without a
+ * device matching `platform`, or if `compilerType` is invalid.
+ */
+ std::unique_ptr<ICompilerAdapter> getCompiler(ov::intel_npu::CompilerType& compilerType,
+ std::string_view platform) const;
+
+ /** @brief Returns the shared compiler option cache, or null if caching is disabled. */
+ std::shared_ptr<OptionSupportCache> getOptionSupportCache() const {
+ return _optionSupportCache;
+ }
+
+ /**
+ * @brief Resolves PREFER_PLUGIN to PLUGIN or DRIVER. Any other `compilerType` is left unchanged.
+ *
+ * Meant for validating properties against the selected compiler type. Resolving PREFER_PLUGIN only loads the
+ * function table; it does not verify that a compiler can be created. An online function-table load failure falls
+ * back to DRIVER, while an offline or cross-compilation load failure throws. A platform that only the driver
+ * compiler serves resolves to DRIVER without loading VCL when compilation is online.
+ *
+ * @param[in,out] compilerType The requested compiler type on input; the resolved type on output.
+ * @param device The device that runs the compiled model. May be null for offline compilation.
+ * @param platform The compilation target platform. Empty means no explicit target, which is treated as online
+ * compilation on `device`.
+ * @throws ov::Exception if loading the function table fails during offline (or cross) compilation, since only the
+ * compiler-in-plugin can serve such a compilation.
+ */
void decideCompilerType(ov::intel_npu::CompilerType& compilerType,
const std::shared_ptr<intel_npu::IDevice>& device,
- std::string_view platform);
+ std::string_view platform) const;
- static const std::vector<ov::intel_npu::CompilerType>& getKnownCompilerTypes();
+ const std::vector<ov::intel_npu::CompilerType>& getKnownCompilerTypes() const {
+ return _knownCompilerTypes;
+ }
private:
ov::intel_npu::CompilerType determineAppropriateCompilerTypeBasedOnPlatform(std::string_view platform) const;
- std::pair<std::unique_ptr<ICompilerAdapter>, ov::intel_npu::CompilerType> resolvePreferPluginCompiler(
- const ov::SoPtr<IEngineBackend>& engineBackend,
- const std::shared_ptr<OptionSupportCache>& optionSupportCache,
- const std::shared_ptr<intel_npu::IDevice>& device,
- std::string_view platform) const;
-
- enum class PluginCompilerPresence : std::uint8_t {
- UNKNOWN = 0,
- PRESENT = 1,
- ABSENT = 2,
- };
+ ov::intel_npu::CompilerType resolvePreferPluginCompiler(const std::shared_ptr<intel_npu::IDevice>& device,
+ std::string_view platform) const;
- inline static std::atomic<PluginCompilerPresence> _pluginCompilerPresence{PluginCompilerPresence::UNKNOWN};
+ ov::SoPtr<IEngineBackend> _engineBackend;
+ VCLFunctionTableProvider _vclFunctionsProvider;
+ std::shared_ptr<OptionSupportCache> _optionSupportCache;
+ const std::vector<ov::intel_npu::CompilerType> _knownCompilerTypes = {ov::intel_npu::CompilerType::DRIVER,
+ ov::intel_npu::CompilerType::PLUGIN};
};
} // 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
index 80f06eb78e5..7cce70a1543 100644
--- 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
@@ -7,6 +7,7 @@
#include <memory>
#include "intel_npu/common/iparser.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
@@ -15,6 +16,7 @@ namespace intel_npu {
class ParserFactory final {
public:
std::unique_ptr<IParser> getParser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStructs,
+ const VCLFunctionTableProvider& vclFunctionsProvider,
bool perfCountEnabled) const;
};
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
index 1947ecadd12..70e34a8d7ed 100644
--- 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
@@ -4,60 +4,51 @@
#include "intel_npu/common/compiler_adapter_factory.hpp"
+#include <exception>
+#include <memory>
+#include <optional>
+#include <string_view>
+
#include "compiler_impl.hpp"
#include "driver_compiler_adapter.hpp"
#include "intel_npu/npu_private_properties.hpp"
+#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/vcl/vcl_api.hpp"
#include "openvino/core/except.hpp"
#include "plugin_compiler_adapter.hpp"
#include "vcl_profiling_decoder.hpp"
namespace intel_npu {
+CompilerAdapterFactory::CompilerAdapterFactory(const ov::SoPtr<IEngineBackend>& engineBackend,
+ const VCLFunctionTableProvider& vclFunctionsProvider,
+ const std::shared_ptr<OptionSupportCache>& optionSupportCache)
+ : _engineBackend(engineBackend),
+ _vclFunctionsProvider(vclFunctionsProvider),
+ _optionSupportCache(optionSupportCache) {}
-namespace {
-
-std::shared_ptr<IVCLCompiler> makePluginCompiler(std::shared_ptr<const VCLFunctionTable>& functions,
- const std::shared_ptr<IDevice>& device,
- std::string_view platform,
- const std::shared_ptr<OptionSupportCache>& optionSupportCache) {
- auto vclLoader = VCLLoader::getInstance();
- OPENVINO_ASSERT(vclLoader != nullptr, "VCL loader is nullptr");
- functions = vclLoader->sharedFunctions();
-
- // Only online compilation gets the attached device's descriptor.
- // Offline and cross compilation get a dummy one, so the local device cannot affect the blob.
- const bool onlineCompilation = device && (platform.empty() || device->getName() == platform);
-
- return std::make_shared<VCLCompilerImpl>(
- functions,
- onlineCompilation ? std::optional<IDevice::DeviceProperties>{device->getDeviceProperties()} : std::nullopt,
- ScopedOptionSupportCache{optionSupportCache,
- static_cast<OptionSupportCache::CacheKey>(ov::intel_npu::CompilerType::PLUGIN)});
-}
-
-} // namespace
-
-std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(
- const ov::SoPtr<IEngineBackend>& engineBackend,
- ov::intel_npu::CompilerType& compilerType,
- std::string_view platform,
- const std::shared_ptr<OptionSupportCache>& optionSupportCache) const {
- const auto device = engineBackend ? engineBackend->getDevice() : nullptr;
+std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(ov::intel_npu::CompilerType& compilerType,
+ std::string_view platform) const {
+ const auto device = _engineBackend ? _engineBackend->getDevice() : nullptr;
if (compilerType == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- auto [pluginCompiler, resolvedCompilerType] =
- resolvePreferPluginCompiler(engineBackend, optionSupportCache, device, platform);
- compilerType = resolvedCompilerType;
- if (pluginCompiler) {
- return std::move(pluginCompiler);
- }
+ compilerType = resolvePreferPluginCompiler(device, platform);
}
if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
std::shared_ptr<const VCLFunctionTable> functions;
std::shared_ptr<IVCLCompiler> compiler;
try {
- compiler = makePluginCompiler(functions, device, platform, optionSupportCache);
+ OPENVINO_ASSERT(_vclFunctionsProvider != nullptr,
+ "CompilerAdapterFactory requires a way to obtain the VCL entry points");
+ functions = _vclFunctionsProvider();
+ const bool onlineCompilation = device && (platform.empty() || device->getName() == platform);
+ compiler = std::make_shared<VCLCompilerImpl>(
+ functions,
+ onlineCompilation ? std::optional<IDevice::DeviceProperties>{device->getDeviceProperties()}
+ : std::nullopt,
+ ScopedOptionSupportCache{
+ _optionSupportCache,
+ static_cast<OptionSupportCache::CacheKey>(ov::intel_npu::CompilerType::PLUGIN)});
} catch (const std::exception& vclException) {
OPENVINO_THROW("VCL compiler loading failed, aborting. Error: ", vclException.what());
}
@@ -70,7 +61,7 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(
ex.what());
}
- return std::make_unique<PluginCompilerAdapter>(engineBackend ? engineBackend->getInitStructs() : nullptr,
+ return std::make_unique<PluginCompilerAdapter>(_engineBackend ? _engineBackend->getInitStructs() : nullptr,
compiler,
profilingDecoder);
}
@@ -88,7 +79,7 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(
OPENVINO_THROW("Could not find a valid NPU device for the provided configuration.");
}
- return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs(), optionSupportCache);
+ return std::make_unique<DriverCompilerAdapter>(_engineBackend->getInitStructs(), _optionSupportCache);
}
OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");
@@ -96,12 +87,12 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(
void CompilerAdapterFactory::decideCompilerType(ov::intel_npu::CompilerType& compilerType,
const std::shared_ptr<intel_npu::IDevice>& device,
- std::string_view platform) {
+ std::string_view platform) const {
if (compilerType != ov::intel_npu::CompilerType::PREFER_PLUGIN) {
return;
}
- compilerType = resolvePreferPluginCompiler({}, nullptr, device, platform).second;
+ compilerType = resolvePreferPluginCompiler(device, platform);
}
ov::intel_npu::CompilerType CompilerAdapterFactory::determineAppropriateCompilerTypeBasedOnPlatform(
@@ -114,69 +105,30 @@ ov::intel_npu::CompilerType CompilerAdapterFactory::determineAppropriateCompiler
return ov::intel_npu::CompilerType::DRIVER;
}
-std::pair<std::unique_ptr<ICompilerAdapter>, ov::intel_npu::CompilerType>
-CompilerAdapterFactory::resolvePreferPluginCompiler(const ov::SoPtr<IEngineBackend>& engineBackend,
- const std::shared_ptr<OptionSupportCache>& optionSupportCache,
- const std::shared_ptr<intel_npu::IDevice>& device,
- std::string_view platform) const {
- const auto pluginCompilerPresence = _pluginCompilerPresence.load(std::memory_order_acquire);
+ov::intel_npu::CompilerType CompilerAdapterFactory::resolvePreferPluginCompiler(
+ const std::shared_ptr<intel_npu::IDevice>& device,
+ std::string_view platform) const {
const bool onlineCompilation = device && (platform.empty() || device->getName() == platform);
if (onlineCompilation &&
determineAppropriateCompilerTypeBasedOnPlatform(platform) == ov::intel_npu::CompilerType::DRIVER) {
- return {nullptr, ov::intel_npu::CompilerType::DRIVER};
- }
-
- if (pluginCompilerPresence == PluginCompilerPresence::PRESENT) {
- // The actual compiler will be created in getCompiler().
- return {nullptr, ov::intel_npu::CompilerType::PLUGIN};
+ return ov::intel_npu::CompilerType::DRIVER;
}
- if (pluginCompilerPresence == PluginCompilerPresence::ABSENT) {
+ std::shared_ptr<const VCLFunctionTable> functions;
+ try {
+ OPENVINO_ASSERT(_vclFunctionsProvider != nullptr,
+ "CompilerAdapterFactory requires a way to obtain the VCL entry points");
+ functions = _vclFunctionsProvider();
+ OPENVINO_ASSERT(functions != nullptr, "VCL function table provider returned no entry points");
+ } catch (const std::exception& ex) {
if (onlineCompilation) {
- return {nullptr, ov::intel_npu::CompilerType::DRIVER};
+ return ov::intel_npu::CompilerType::DRIVER;
}
- OPENVINO_THROW("Plugin compiler is absent for offline or cross compilation.");
+ OPENVINO_THROW("Failed to load VCL function table for offline or cross compilation. Error: ", ex.what());
}
- if (pluginCompilerPresence == PluginCompilerPresence::UNKNOWN) {
- std::shared_ptr<IVCLCompiler> pluginCompiler;
- std::shared_ptr<const VCLFunctionTable> functions;
- try {
- pluginCompiler = makePluginCompiler(functions, device, platform, optionSupportCache);
- } catch (...) {
- _pluginCompilerPresence.store(PluginCompilerPresence::ABSENT, std::memory_order_release);
- if (onlineCompilation) {
- return {nullptr, ov::intel_npu::CompilerType::DRIVER};
- }
- OPENVINO_THROW("Failed to create plugin compiler for offline or cross compilation.");
- }
-
- _pluginCompilerPresence.store(PluginCompilerPresence::PRESENT, std::memory_order_release);
- std::shared_ptr<IProfilingDecoder> profilingDecoder;
- try {
- profilingDecoder = std::make_shared<VCLProfilingDecoder>(functions);
- } catch (const std::exception& ex) {
- Logger::global().warning("Failed to create the VCL profiling decoder for plugin compilation: %s",
- ex.what());
- }
-
- auto pluginAdapter =
- std::make_unique<PluginCompilerAdapter>(engineBackend ? engineBackend->getInitStructs() : nullptr,
- pluginCompiler,
- profilingDecoder);
- return {std::move(pluginAdapter), ov::intel_npu::CompilerType::PLUGIN};
- }
-
- // Should not reach here, but throw in case of unexpected state.
- OPENVINO_THROW("Unexpected state in resolvePreferPluginCompiler");
-}
-
-const std::vector<ov::intel_npu::CompilerType>& CompilerAdapterFactory::getKnownCompilerTypes() {
- static const std::vector<ov::intel_npu::CompilerType> knownCompiler = {ov::intel_npu::CompilerType::DRIVER,
- ov::intel_npu::CompilerType::PLUGIN};
-
- return knownCompiler;
+ return ov::intel_npu::CompilerType::PLUGIN;
}
} // 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
index c027c235fa5..a7323b900a8 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/parser_factory.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser_factory.cpp
@@ -5,14 +5,15 @@
#include "intel_npu/common/parser_factory.hpp"
#include <exception>
+#include <memory>
-#include "intel_npu/utils/vcl/vcl_api.hpp"
#include "parser.hpp"
#include "vcl_profiling_decoder.hpp"
namespace intel_npu {
std::unique_ptr<IParser> ParserFactory::getParser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStructs,
+ const VCLFunctionTableProvider& vclFunctionsProvider,
bool perfCountEnabled) const {
OPENVINO_ASSERT(
zeroInitStructs != nullptr,
@@ -21,9 +22,9 @@ std::unique_ptr<IParser> ParserFactory::getParser(const std::shared_ptr<ZeroInit
std::shared_ptr<IProfilingDecoder> profilingDecoder;
if (perfCountEnabled) {
try {
- auto vclLoader = VCLLoader::getInstance();
- OPENVINO_ASSERT(vclLoader != nullptr, "VCL loader is nullptr");
- profilingDecoder = std::make_shared<VCLProfilingDecoder>(vclLoader->sharedFunctions());
+ OPENVINO_ASSERT(vclFunctionsProvider != nullptr,
+ "Profiling is enabled but no way to obtain the VCL entry points was given");
+ profilingDecoder = std::make_shared<VCLProfilingDecoder>(vclFunctionsProvider());
} catch (const std::exception& ex) {
Logger::global().warning("Failed to create the VCL profiling decoder for model import: %s", ex.what());
}
diff --git a/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp b/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp
index 71637bc4e1f..b64e09d6561 100644
--- a/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp
@@ -11,6 +11,7 @@
#include "intel_npu/common/igraph.hpp"
#include "intel_npu/common/npu.hpp"
#include "intel_npu/config/config.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
#include "metadata.hpp"
#include "openvino/runtime/tensor.hpp"
@@ -47,12 +48,14 @@ public:
* @param network_name The resulted graph object will use this network name.
* @param core The OV core. The weights separation feature may depend on this object to extract the original
* weights.
+ * @param vclFunctionsProvider Supplies the VCL entry points provider, forwarded to the parser factory.
* @return A graph object. The type of graph depends on the content of the blob. E.g. a "weightless" graph will be
* returned if the weights separation feature was detected.
*/
std::shared_ptr<IGraph> create_graph(const ov::SoPtr<IEngineBackend>& backend,
const std::string_view network_name,
- const std::shared_ptr<ov::ICore>& core);
+ const std::shared_ptr<ov::ICore>& core,
+ const VCLFunctionTableProvider& vclFunctionsProvider);
/**
* @brief Uses the metadata of the resulted graph object to build a minimalistic OV model.
diff --git a/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp b/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp
index e6e9c3f33e0..0c8f3d14fb9 100644
--- a/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/compiler_option_support_helper.hpp
@@ -5,6 +5,7 @@
#pragma once
#include <cstdint>
+#include <memory>
#include <mutex>
#include <optional>
#include <string>
@@ -12,7 +13,6 @@
#include <vector>
#include "intel_npu/common/compiler_adapter_factory.hpp"
-#include "intel_npu/common/npu.hpp"
#include "intel_npu/common/option_support_cache.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
@@ -20,18 +20,14 @@ namespace intel_npu {
class CompilerOptionSupportHelper final {
public:
- explicit CompilerOptionSupportHelper(const ov::SoPtr<IEngineBackend>& backend,
- const CompilerAdapterFactory& adapterFactory);
-
- const std::shared_ptr<OptionSupportCache>& getOptionSupportCache() const;
+ explicit CompilerOptionSupportHelper(const std::shared_ptr<const CompilerAdapterFactory>& adapterFactory);
bool isOptionSupported(ov::intel_npu::CompilerType compilerType,
const std::string& optionName,
const std::optional<std::string>& optionValue = std::nullopt);
private:
- const ov::SoPtr<IEngineBackend> _backend;
- const CompilerAdapterFactory _adapterFactory;
+ const std::shared_ptr<const CompilerAdapterFactory> _adapterFactory;
std::shared_ptr<OptionSupportCache> _optionSupportCache;
std::mutex _supportedOptionsLoadedMutex;
diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
index 24c6dcdf0f5..942abbe73f5 100644
--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
@@ -4,22 +4,28 @@
#pragma once
+#include <exception>
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include "backends_registry.hpp"
#include "blob_source.hpp"
#include "compiler_option_support_helper.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/npu.hpp"
#include "intel_npu/config/config.hpp"
#include "intel_npu/utils/logger/logger.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
#include "openvino/runtime/iplugin.hpp"
#include "openvino/runtime/so_ptr.hpp"
#include "plugin_property_manager.hpp"
namespace intel_npu {
+class VCLLoader;
+
class Plugin : public ov::IPlugin {
public:
Plugin();
@@ -68,12 +74,27 @@ private:
std::shared_ptr<ov::ICompiledModel> import_model(BlobSource& blobSource, ov::AnyMap& properties) const;
+ /**
+ * @brief Returns a provider of the VCL entry points for the components that need them.
+ *
+ * The provider calls back into this plugin. The factory that stores it must not outlive the plugin.
+ */
+ VCLFunctionTableProvider vcl_functions_provider() const;
+
std::unique_ptr<BackendsRegistry> _backendsRegistry;
// _backend might not be set by the plugin; certain actions, such as offline compilation, might be supported.
// Appropriate checks are needed in plugin/metrics/properties when actions depend on a backend.
ov::SoPtr<IEngineBackend> _backend;
+ // Loading is deferred until a provider is invoked. Cache both success and failure for this plugin.
+ mutable std::mutex _vclLoaderMutex;
+ mutable std::shared_ptr<const VCLLoader> _vclLoader;
+ mutable std::exception_ptr _vclLoadFailure;
+
+ // The only factory of the plugin, so that all requests share one compiler option support cache.
+ std::shared_ptr<const CompilerAdapterFactory> _compilerAdapterFactory;
+
mutable Logger _logger;
std::unique_ptr<PluginPropertyManager> _propertiesManager;
std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;
diff --git a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp
index c9f5cd439e1..cbc1b06a82c 100644
--- a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp
@@ -13,6 +13,7 @@
#include <vector>
#include "compiler_option_support_helper.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/npu.hpp"
#include "intel_npu/config/config.hpp"
@@ -29,6 +30,7 @@ public:
PluginPropertyManager(const std::shared_ptr<OptionsDesc>& options,
const ov::SoPtr<IEngineBackend>& backend,
const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,
+ const std::shared_ptr<const CompilerAdapterFactory>& compilerAdapterFactory,
Logger& logger);
PluginPropertyManager& operator=(const PluginPropertyManager& other) = delete;
@@ -60,6 +62,7 @@ private:
ov::SoPtr<IEngineBackend> _backend;
std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;
+ std::shared_ptr<const CompilerAdapterFactory> _compilerAdapterFactory;
Logger& _logger;
mutable std::mutex _mutex;
diff --git a/src/plugins/intel_npu/src/plugin/src/blob_format_importers.cpp b/src/plugins/intel_npu/src/plugin/src/blob_format_importers.cpp
index 8341ea0bc03..3706a90441c 100644
--- a/src/plugins/intel_npu/src/plugin/src/blob_format_importers.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/blob_format_importers.cpp
@@ -393,7 +393,8 @@ IBlobFormatImporter::IBlobFormatImporter(const std::shared_ptr<const ov::Model>&
std::shared_ptr<IGraph> IBlobFormatImporter::create_graph(const ov::SoPtr<IEngineBackend>& backend,
const std::string_view network_name,
- const std::shared_ptr<ov::ICore>& core) {
+ const std::shared_ptr<ov::ICore>& core,
+ const VCLFunctionTableProvider& vclFunctionsProvider) {
OV_ITT_TASK_CHAIN(PARSE_AND_CREATE_GRAPH, itt::domains::NPUPlugin, "IBlobFormatImporter", "create_graph");
m_logger.debug("Creating a graph");
@@ -410,7 +411,7 @@ std::shared_ptr<IGraph> IBlobFormatImporter::create_graph(const ov::SoPtr<IEngin
OV_ITT_TASK_NEXT(PARSE_AND_CREATE_GRAPH, "get_parser");
m_logger.trace("Creating the parser");
ParserFactory parserFactory;
- auto parser = parserFactory.getParser(backend->getInitStructs(), m_config.get<PERF_COUNT>());
+ auto parser = parserFactory.getParser(backend->getInitStructs(), vclFunctionsProvider, m_config.get<PERF_COUNT>());
std::variant<std::monostate, std::shared_ptr<const ov::Model>, std::pair<std::string, std::shared_ptr<ov::ICore>>>
weights_source;
diff --git a/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp b/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp
index 43e3c110d26..828e4b734b4 100644
--- a/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/compiler_option_support_helper.cpp
@@ -17,27 +17,25 @@ OptionSupportCache::CacheKey toCacheKey(const ov::intel_npu::CompilerType compil
}
} // namespace
-CompilerOptionSupportHelper::CompilerOptionSupportHelper(const ov::SoPtr<IEngineBackend>& backend,
- const CompilerAdapterFactory& adapterFactory)
- : _backend(backend),
- _adapterFactory(adapterFactory),
- _optionSupportCache(std::make_shared<OptionSupportCache>()) {}
-
-const std::shared_ptr<OptionSupportCache>& CompilerOptionSupportHelper::getOptionSupportCache() const {
- return _optionSupportCache;
+CompilerOptionSupportHelper::CompilerOptionSupportHelper(
+ const std::shared_ptr<const CompilerAdapterFactory>& adapterFactory)
+ : _adapterFactory(adapterFactory) {
+ OPENVINO_ASSERT(_adapterFactory != nullptr,
+ "CompilerOptionSupportHelper requires a non-null CompilerAdapterFactory");
+ _optionSupportCache = _adapterFactory->getOptionSupportCache();
}
bool CompilerOptionSupportHelper::isOptionSupported(ov::intel_npu::CompilerType compilerType,
const std::string& optionName,
const std::optional<std::string>& optionValue) {
- const auto supportedCompilerTypes = _adapterFactory.getKnownCompilerTypes();
+ const auto& supportedCompilerTypes = _adapterFactory->getKnownCompilerTypes();
OPENVINO_ASSERT(std::find(supportedCompilerTypes.begin(), supportedCompilerTypes.end(), compilerType) !=
supportedCompilerTypes.end(),
"Unsupported compiler type");
const auto cacheKey = toCacheKey(compilerType);
const auto getCachedSupport = [&]() -> std::optional<bool> {
- if (optionValue.has_value()) {
+ if (optionValue.has_value() || !_optionSupportCache) {
return std::nullopt;
}
return _optionSupportCache->isOptionSupported(cacheKey, optionName);
@@ -48,7 +46,7 @@ bool CompilerOptionSupportHelper::isOptionSupported(ov::intel_npu::CompilerType
}
std::unique_ptr<ICompilerAdapter> compiler;
- compiler = _adapterFactory.getCompiler(_backend, compilerType, "", _optionSupportCache);
+ compiler = _adapterFactory->getCompiler(compilerType, "");
std::once_flag* optionsLoaded = nullptr;
{
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index f725ca929da..8b79fac0689 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -17,6 +17,7 @@
#include "intel_npu/config/npuw.hpp"
#include "intel_npu/config/options.hpp"
#include "intel_npu/utils/utils.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
#include "npuw/compiled_model.hpp"
#include "npuw/gqa_compiled_model.hpp"
#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
@@ -181,6 +182,9 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {
// backend registry shall be created after configs are updated
_backendsRegistry = std::make_unique<BackendsRegistry>();
_backend = _backendsRegistry->getEngineBackend();
+ const auto optionSupportCache = std::make_shared<OptionSupportCache>();
+ _compilerAdapterFactory =
+ std::make_shared<const CompilerAdapterFactory>(_backend, vcl_functions_provider(), optionSupportCache);
register_options(_backend, *options);
if (_backend) {
@@ -190,9 +194,30 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {
/// Init and register properties
OV_ITT_TASK_NEXT(PLUGIN, "RegisterProperties");
- _compilerOptionSupportHelper = std::make_shared<CompilerOptionSupportHelper>(_backend, CompilerAdapterFactory());
- _propertiesManager =
- std::make_unique<PluginPropertyManager>(options, _backend, _compilerOptionSupportHelper, _logger);
+ _compilerOptionSupportHelper = std::make_shared<CompilerOptionSupportHelper>(_compilerAdapterFactory);
+ _propertiesManager = std::make_unique<PluginPropertyManager>(options,
+ _backend,
+ _compilerOptionSupportHelper,
+ _compilerAdapterFactory,
+ _logger);
+}
+
+VCLFunctionTableProvider Plugin::vcl_functions_provider() const {
+ return [this] {
+ std::lock_guard<std::mutex> lock(_vclLoaderMutex);
+ if (_vclLoadFailure) {
+ std::rethrow_exception(_vclLoadFailure);
+ }
+ if (!_vclLoader) {
+ try {
+ _vclLoader = std::make_shared<VCLLoader>();
+ } catch (...) {
+ _vclLoadFailure = std::current_exception();
+ throw;
+ }
+ }
+ return _vclLoader->sharedFunctions();
+ };
}
void Plugin::set_property(const ov::AnyMap& properties) {
@@ -274,11 +299,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
device == nullptr ? std::move(deviceId) : device->getName());
ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);
- CompilerAdapterFactory factory;
- auto compiler = factory.getCompiler(_backend,
- compilerType,
- compilationPlatform,
- _compilerOptionSupportHelper->getOptionSupportCache());
+ auto compiler = _compilerAdapterFactory->getCompiler(compilerType, compilationPlatform);
localProperties[ov::intel_npu::compiler_type.name()] = compilerType;
if (!compilationPlatform.empty()) {
@@ -607,7 +628,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(BlobSource& blobSource,
}
const std::shared_ptr<IGraph> graph =
- blobFormatImporter->create_graph(_backend, "net" + std::to_string(_compiledModelLoadCounter++), get_core());
+ blobFormatImporter->create_graph(_backend,
+ "net" + std::to_string(_compiledModelLoadCounter++),
+ get_core(),
+ vcl_functions_provider());
return std::make_shared<CompiledModel>(blobFormatImporter->create_dummy_model(),
shared_from_this(),
@@ -650,11 +674,7 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
device == nullptr ? std::move(deviceId) : device->getName());
ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);
- CompilerAdapterFactory factory;
- auto compiler = factory.getCompiler(_backend,
- compilerType,
- compilationPlatform,
- _compilerOptionSupportHelper->getOptionSupportCache());
+ auto compiler = _compilerAdapterFactory->getCompiler(compilerType, compilationPlatform);
localProperties[ov::intel_npu::compiler_type.name()] = compilerType;
if (!compilationPlatform.empty()) {
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp
index 4e8e5f6249f..80aa9486601 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp
@@ -95,13 +95,16 @@ ov::CompatibilityCheck validateCompatibilityDescriptor(const ov::SoPtr<intel_npu
namespace intel_npu {
-PluginPropertyManager::PluginPropertyManager(const std::shared_ptr<OptionsDesc>& options,
- const ov::SoPtr<IEngineBackend>& backend,
- const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,
- Logger& logger)
+PluginPropertyManager::PluginPropertyManager(
+ const std::shared_ptr<OptionsDesc>& options,
+ const ov::SoPtr<IEngineBackend>& backend,
+ const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,
+ const std::shared_ptr<const CompilerAdapterFactory>& compilerAdapterFactory,
+ Logger& logger)
: _config(options),
_backend(backend),
_compilerOptionSupportHelper(optionSupportHelper),
+ _compilerAdapterFactory(compilerAdapterFactory),
_logger(logger) {
if (_backend == nullptr) {
_logger.info("No backend is available. Backend/device-dependent properties will be unavailable.");
@@ -372,8 +375,7 @@ std::optional<ov::intel_npu::CompilerType> PluginPropertyManager::resolveCompile
getPlatformOrDefault(arguments),
device == nullptr ? deviceId : device->getName());
- CompilerAdapterFactory factory;
- factory.decideCompilerType(compilerType.value(), device, compilationPlatform);
+ _compilerAdapterFactory->decideCompilerType(compilerType.value(), device, compilationPlatform);
return compilerType;
} catch (const std::exception& ex) {
_logger.warning("Failed to resolve compiler type: %s. Compiler-dependent properties will be unsupported.",
@@ -920,8 +922,7 @@ void PluginPropertyManager::registerProperties() {
}
try {
- CompilerAdapterFactory factory;
- return factory.getCompiler(_backend, compilerType.value(), compilationPlatform) != nullptr;
+ return _compilerAdapterFactory->getCompiler(compilerType.value(), compilationPlatform) != nullptr;
} catch (...) {
return false;
}
@@ -939,8 +940,7 @@ void PluginPropertyManager::registerProperties() {
device == nullptr ? deviceId : device->getName());
}
- CompilerAdapterFactory factory;
- return factory.getCompiler(_backend, compilerType.value(), compilationPlatform)->get_version();
+ return _compilerAdapterFactory->getCompiler(compilerType.value(), compilationPlatform)->get_version();
},
[](const ov::Any&) {
OPENVINO_THROW("READ-ONLY configuration key: ", ov::intel_npu::compiler_version.name());
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp
index af429ac7121..4d2d0e70d62 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp
@@ -5,10 +5,8 @@
#pragma once
#include <memory>
-#include <string>
#include "intel_npu/utils/logger/logger.hpp"
-#include "openvino/core/except.hpp"
#include "vcl.h"
namespace intel_npu {
@@ -76,18 +74,17 @@ struct VCLFunctionTable {
/**
* @brief Owns the loaded VCL compiler library and the function table resolved out of it.
*
- * The loading constructor is private: `getInstance` is the only way to load, so the process cannot
- * end up with two independently dlopen'd copies of the compiler library.
+ * Instances must be owned by a `shared_ptr` (`sharedFunctions()` relies on it); use `std::make_shared`.
*/
class VCLLoader final : public std::enable_shared_from_this<VCLLoader> {
public:
+ VCLLoader();
+
VCLLoader(const VCLLoader& other) = delete;
VCLLoader(VCLLoader&& other) = delete;
void operator=(const VCLLoader&) = delete;
void operator=(VCLLoader&&) = delete;
- static const std::shared_ptr<const VCLLoader> getInstance();
-
/**
* @brief The function table, sharing this loader's lifetime.
*
@@ -101,8 +98,6 @@ public:
}
private:
- explicit VCLLoader(const std::string& library_dir);
-
VCLFunctionTable _functions;
std::shared_ptr<void> lib;
Logger _logger;
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_function_table_provider.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_function_table_provider.hpp
new file mode 100644
index 00000000000..183c3ac2629
--- /dev/null
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_function_table_provider.hpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <functional>
+#include <memory>
+
+namespace intel_npu {
+
+struct VCLFunctionTable;
+
+/**
+ * @brief Obtains the VCL entry points on demand.
+ *
+ * Providers defer loading until the entry points are requested to resolve or construct a compiler-in-plugin,
+ * or to create a profiling decoder. Profiling imports can request them even when using the driver compiler.
+ * A provider should remember a failed load, so that callers do not repeat it, and always supply the same set of
+ * entry points: what is built from them, such as a CompilerAdapterFactory, is bound to that set.
+ *
+ * Lives apart from vcl_api.hpp so that headers that only pass a provider around do not pull in the VCL C API.
+ */
+using VCLFunctionTableProvider = std::function<std::shared_ptr<const VCLFunctionTable>()>;
+
+} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/utils/src/vcl/vcl_api.cpp b/src/plugins/intel_npu/src/utils/src/vcl/vcl_api.cpp
index fb5acf9e2c6..088068dc893 100644
--- a/src/plugins/intel_npu/src/utils/src/vcl/vcl_api.cpp
+++ b/src/plugins/intel_npu/src/utils/src/vcl/vcl_api.cpp
@@ -4,19 +4,21 @@
#include "intel_npu/utils/vcl/vcl_api.hpp"
-#include <filesystem>
-#include <mutex>
#include <stdexcept>
+#include "openvino/core/except.hpp"
#include "openvino/util/file_util.hpp"
#include "openvino/util/shared_object.hpp"
namespace intel_npu {
-VCLLoader::VCLLoader(const std::string& library_dir) : _logger("VCLLoader", Logger::global().level()) {
+VCLLoader::VCLLoader() : _logger("VCLLoader", Logger::global().level()) {
const auto baseName = "openvino_intel_npu_compiler_loader";
+ const auto libraryDir = ov::util::get_ov_lib_path();
+ OPENVINO_ASSERT(!libraryDir.empty(),
+ "Cannot load the VCL compiler library: the directory of the OpenVINO runtime library is unknown");
try {
- const auto libpath = ov::util::make_plugin_library_name(std::filesystem::path(library_dir), baseName);
+ const auto libpath = ov::util::make_plugin_library_name(libraryDir, baseName);
_logger.debug("Try to load: %s", ov::util::path_to_string(libpath).c_str());
this->lib = ov::util::load_shared_object(libpath);
} catch (const std::runtime_error& error) {
@@ -45,22 +47,4 @@ VCLLoader::VCLLoader(const std::string& library_dir) : _logger("VCLLoader", Logg
#undef vcl_symbol_statement
}
-const std::shared_ptr<const VCLLoader> VCLLoader::getInstance() {
- static std::mutex mtx;
- std::lock_guard<std::mutex> lock(mtx);
-
- static std::shared_ptr<const VCLLoader> instance = nullptr;
-
- if (!instance) {
- const auto library_dir = ov::util::path_to_string(ov::util::get_ov_lib_path());
- if (library_dir.empty()) {
- OPENVINO_THROW("VCLLoader instance has not been loaded yet, and no valid path was provided to load it.");
- }
- // Not make_shared: the loading constructor is private so that this is the only way to load.
- instance = std::shared_ptr<const VCLLoader>(new VCLLoader(library_dir));
- }
-
- return instance;
-}
-
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
index c65c56edc80..121aca11eb5 100644
--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
@@ -204,14 +204,14 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {
std::shared_ptr<::intel_npu::ICompilerAdapter> compiler;
try {
- compiler = npu_config->get<::intel_npu::COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER
- ? std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(
- std::make_shared<::intel_npu::DriverCompilerAdapter>(zeroInitStruct))
- : std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(
- std::make_shared<::intel_npu::PluginCompilerAdapter>(
- zeroInitStruct,
- std::make_shared<::intel_npu::VCLCompilerImpl>(
- ::intel_npu::VCLLoader::getInstance()->sharedFunctions())));
+ if (npu_config->get<::intel_npu::COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER) {
+ compiler = std::make_shared<::intel_npu::DriverCompilerAdapter>(zeroInitStruct);
+ } else {
+ compiler = std::make_shared<::intel_npu::PluginCompilerAdapter>(
+ zeroInitStruct,
+ std::make_shared<::intel_npu::VCLCompilerImpl>(
+ std::make_shared<::intel_npu::VCLLoader>()->sharedFunctions()));
+ }
} catch (...) {
GTEST_SKIP() << "Couldn't load compiler library";
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/parser_factory.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/parser_factory.cpp
new file mode 100644
index 00000000000..b6f23e0320f
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/parser_factory.cpp
@@ -0,0 +1,75 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_npu/common/parser_factory.hpp"
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+#include "functional_test_utils/skip_tests_config.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
+#include "intel_npu/utils/zero/zero_init.hpp"
+#include "openvino/core/except.hpp"
+
+namespace {
+
+using namespace ::intel_npu;
+
+class ParserFactoryFunctionalTests : public ::testing::Test {
+protected:
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ initStructs = ZeroInitStructsHolder::getInstance();
+ loader = std::make_shared<VCLLoader>();
+ }
+
+ // Hands out the real VCL entry points and counts how many times they were requested.
+ VCLFunctionTableProvider countingProvider() {
+ return [this] {
+ ++calls;
+ return loader->sharedFunctions();
+ };
+ }
+
+ std::shared_ptr<ZeroInitStructsHolder> initStructs;
+ std::shared_ptr<VCLLoader> loader;
+ std::size_t calls = 0;
+ ParserFactory factory;
+};
+
+TEST_F(ParserFactoryFunctionalTests, GetParserProfilingDisabledDoesNotInvokeProvider) {
+ const auto parser = factory.getParser(initStructs, countingProvider(), false);
+ EXPECT_NE(parser, nullptr);
+ EXPECT_EQ(calls, 0u);
+}
+
+TEST_F(ParserFactoryFunctionalTests, GetParserProfilingEnabledWithUnavailableProviderStillReturnsParser) {
+ const VCLFunctionTableProvider unavailable = [this]() -> std::shared_ptr<const VCLFunctionTable> {
+ ++calls;
+ OPENVINO_THROW("The VCL library cannot be loaded");
+ };
+ const auto parser = factory.getParser(initStructs, unavailable, true);
+ EXPECT_NE(parser, nullptr);
+ EXPECT_EQ(calls, 1u);
+}
+
+TEST_F(ParserFactoryFunctionalTests, GetParserProfilingEnabledWithoutProviderStillReturnsParser) {
+ const auto parser = factory.getParser(initStructs, VCLFunctionTableProvider{}, true);
+ EXPECT_NE(parser, nullptr);
+}
+
+TEST_F(ParserFactoryFunctionalTests, GetParserProfilingEnabledInvokesProviderOnce) {
+ const auto parser = factory.getParser(initStructs, countingProvider(), true);
+ EXPECT_NE(parser, nullptr);
+ EXPECT_EQ(calls, 1u);
+}
+
+TEST_F(ParserFactoryFunctionalTests, GetParserWithoutInitStructsThrowsBeforeInvokingProvider) {
+ EXPECT_THROW(factory.getParser(nullptr, countingProvider(), true), ov::Exception);
+ EXPECT_EQ(calls, 0u);
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp
index d1b8d7a07d5..ca3add5c80c 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp
@@ -45,7 +45,7 @@ protected:
allocator = std::make_shared<::intel_npu::vcl_allocator_2>();
try {
- functions = ::intel_npu::VCLLoader::getInstance()->sharedFunctions();
+ functions = std::make_shared<::intel_npu::VCLLoader>()->sharedFunctions();
} catch (const std::exception&) {
GTEST_SKIP() << "Couldn't load compiler library";
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp
index 132afc018df..dd365730df5 100644
--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_compiler_option_support_helper.cpp
@@ -4,7 +4,9 @@
#include <gtest/gtest.h>
+#include <exception>
#include <functional>
+#include <memory>
#include <mutex>
#include <string>
#include <thread>
@@ -17,6 +19,7 @@
#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/icompiler_adapter.hpp"
#include "intel_npu/common/npu.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
#include "openvino/core/any.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
@@ -26,6 +29,8 @@ namespace ov {
namespace test {
namespace behavior {
+using namespace ::intel_npu;
+
namespace {
// Log markers emitted once per adapter, when its constructor runs (see driver_compiler_adapter.cpp /
// plugin_compiler_adapter.cpp). Used to detect whether a given compiler type had to be (re)initialized.
@@ -34,29 +39,31 @@ std::string startMarkerFor(ov::intel_npu::CompilerType compilerType) {
: "initialize PluginCompilerAdapter start";
}
+// Only successful PLUGIN bulk loading emits this marker; DRIVER has no equivalent success marker.
size_t countOccurrences(const std::string& haystack, const std::string& needle) {
size_t count = 0;
- for (size_t pos = haystack.find(needle); pos != std::string::npos; pos = haystack.find(needle, pos + needle.size())) {
+ for (size_t pos = haystack.find(needle); pos != std::string::npos;
+ pos = haystack.find(needle, pos + needle.size())) {
++count;
}
return count;
}
-// Only PluginCompilerAdapter's successful bulk load logs a distinctive, identifiable marker (see
-// "VCLCompilerImpl return supported_options" in compiler_impl.cpp). DriverCompilerAdapter has
-// no equivalent marker on its success path, so "exactly once" bulk-load checks below only apply to PLUGIN.
std::string bulkLoadMarkerFor(ov::intel_npu::CompilerType compilerType) {
return compilerType == ov::intel_npu::CompilerType::PLUGIN ? "VCLCompilerImpl return supported_options" : "";
}
+
} // namespace
-// Exercises CompilerOptionSupportHelper against a real backend/compiler, complementing the
+// Exercises CompilerOptionSupportHelper against a real backend and the real VCL, complementing the
// backend-agnostic unit tests in tests/unit/npu/compiler_option_support_helper_test.cpp.
class CompilerOptionSupportHelperFunctionalTests : public ov::test::behavior::OVPluginTestBase,
public testing::WithParamInterface<ov::intel_npu::CompilerType> {
protected:
- ov::SoPtr<::intel_npu::IEngineBackend> backend;
- std::unique_ptr<::intel_npu::CompilerOptionSupportHelper> helper;
+ ov::SoPtr<IEngineBackend> backend;
+ std::shared_ptr<OptionSupportCache> optionSupportCache;
+ VCLFunctionTableProvider vclFunctionsProvider;
+ std::unique_ptr<CompilerOptionSupportHelper> helper;
ov::intel_npu::CompilerType compilerType;
std::string targetDevice;
@@ -68,9 +75,14 @@ protected:
OVPluginTestBase::SetUp();
compilerType = GetParam();
- backend = ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<::intel_npu::ZeroEngineBackend>());
- helper =
- std::make_unique<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory());
+ backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());
+ optionSupportCache = std::make_shared<OptionSupportCache>();
+ const auto loader = std::make_shared<VCLLoader>();
+ vclFunctionsProvider = [loader] {
+ return loader->sharedFunctions();
+ };
+ helper = std::make_unique<CompilerOptionSupportHelper>(
+ std::make_shared<const CompilerAdapterFactory>(backend, vclFunctionsProvider, optionSupportCache));
}
void TearDown() override {
@@ -90,8 +102,7 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, RejectsCompilerTypeOutsideSup
}
// Properties from DriverCompilerAdapter's legacy fallback list marked as supported since compiler
-// version 0.0 (see "_supportedPropertiesWithVersions" in driver_compiler_adapter.cpp). These are safe,
-// version-independent choices to exercise real (uncached) compiler lookups for both compiler types.
+// version 0.0. These are safe, version-independent choices to exercise uncached compiler lookups.
const std::vector<std::string> knownSupportedOptions = {ov::enable_profiling.name(),
ov::hint::performance_mode.name(),
ov::log::level.name(),
@@ -118,11 +129,11 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, GetsSupportFromCompilerWhenNo
}
}
- // The cache was empty for these options, so the real compiler adapter must have been created.
+ // The cache was empty for these options, so the compiler adapter must have been created.
ASSERT_NE(logs.find(startMarkerFor(compilerType)), std::string::npos);
}
-TEST_P(CompilerOptionSupportHelperFunctionalTests, CachesResultAfterRealCompilerLookup) {
+TEST_P(CompilerOptionSupportHelperFunctionalTests, CachesResultAfterCompilerLookup) {
for (const auto& optionName : knownSupportedOptions) {
OV_ASSERT_NO_THROW(helper->isOptionSupported(compilerType, optionName));
}
@@ -140,7 +151,7 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, CachesResultAfterRealCompiler
utils::LoggerLevelGuard loggerLevelGuard(ov::log::Level::INFO);
// Second lookup for every option: each must be served from the cache populated by the
- // previous real compiler lookup, without creating the adapter again.
+ // previous compiler adapter lookup, without creating the adapter again.
for (const auto& optionName : knownSupportedOptions) {
bool isSupported = false;
OV_ASSERT_NO_THROW(isSupported = helper->isOptionSupported(compilerType, optionName));
@@ -152,8 +163,8 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, CachesResultAfterRealCompiler
}
TEST_P(CompilerOptionSupportHelperFunctionalTests, AddsNewOptionToCacheAndReturnsItWithoutCompilerLookup) {
- const auto cacheKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(compilerType);
- helper->getOptionSupportCache()->addSupportedOption(cacheKey, "MANUALLY_CACHED_OPTION", true);
+ const auto cacheKey = static_cast<OptionSupportCache::CacheKey>(compilerType);
+ optionSupportCache->addSupportedOption(cacheKey, "MANUALLY_CACHED_OPTION", true);
std::string logs;
std::mutex logsMutex;
@@ -176,9 +187,9 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, AddsNewOptionToCacheAndReturn
ASSERT_EQ(logs.find(startMarkerFor(compilerType)), std::string::npos);
}
-// "DUMMY_OPTION_NOT_IN_BULK_LIST" is not part of any real compiler's bulk "get_supported_options()" dump,
+// "DUMMY_OPTION_NOT_IN_BULK_LIST" is not part of any compiler's bulk "get_supported_options()" dump,
// so unlike "knownSupportedOptions" above, the first lookup cannot be answered from the bulk-populated
-// cache and must fall through to the individual "is_option_supported" probe on the real compiler adapter.
+// cache and must fall through to the individual "is_option_supported" probe on the compiler adapter.
TEST_P(CompilerOptionSupportHelperFunctionalTests, ProbesCompilerDirectlyForOptionOutsideBulkList) {
const std::string unlistedOption = "DUMMY_OPTION_NOT_IN_BULK_LIST";
@@ -227,10 +238,10 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, ProbesCompilerDirectlyForOpti
TEST_P(CompilerOptionSupportHelperFunctionalTests, BatchModeSupportMatchesDirectCompilerProbe) {
const std::string batchModeOption = ov::intel_npu::batch_mode.name();
- ::intel_npu::CompilerAdapterFactory factory;
+ const CompilerAdapterFactory factory{backend, vclFunctionsProvider};
auto adapterCompilerType = compilerType;
- std::unique_ptr<::intel_npu::ICompilerAdapter> compilerAdapter;
- OV_ASSERT_NO_THROW(compilerAdapter = factory.getCompiler(backend, adapterCompilerType, ""));
+ std::unique_ptr<ICompilerAdapter> compilerAdapter;
+ OV_ASSERT_NO_THROW(compilerAdapter = factory.getCompiler(adapterCompilerType, ""));
bool supportedByCompiler = false;
OV_ASSERT_NO_THROW(supportedByCompiler = compilerAdapter->is_option_supported(batchModeOption));
@@ -262,12 +273,11 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, BatchModeSupportMatchesDirect
ASSERT_EQ(logs.find(startMarkerFor(compilerType)), std::string::npos);
}
-// Stresses the shared, per-compiler-type once_flag/cache guard in CompilerOptionSupportHelper::isOptionSupported
-// with concurrent lookups for the same key. Bulk loading ("get_supported_options") must still run exactly once.
TEST_P(CompilerOptionSupportHelperFunctionalTests, ConcurrentLookupsForSameKeyLoadOptionsOnceWithoutRaces) {
constexpr int kThreadCount = 8;
std::vector<std::thread> threads;
- std::vector<bool> results(kThreadCount, false);
+ // Avoid vector<bool>'s packed bits: concurrent writes to distinct indices can still race.
+ std::vector<int> results(kThreadCount, 0);
std::vector<std::exception_ptr> failures(kThreadCount);
std::string logs;
@@ -285,10 +295,8 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, ConcurrentLookupsForSameKeyLo
for (int i = 0; i < kThreadCount; ++i) {
threads.emplace_back([&, i]() {
try {
- // Mixing options already known to be part of the bulk list, queried concurrently
- // for the same compiler type/key.
const auto& optionName = knownSupportedOptions[i % knownSupportedOptions.size()];
- results[i] = helper->isOptionSupported(compilerType, optionName);
+ results[i] = helper->isOptionSupported(compilerType, optionName) ? 1 : 0;
} catch (...) {
failures[i] = std::current_exception();
}
@@ -301,13 +309,11 @@ TEST_P(CompilerOptionSupportHelperFunctionalTests, ConcurrentLookupsForSameKeyLo
for (int i = 0; i < kThreadCount; ++i) {
ASSERT_FALSE(failures[i]) << "Thread " << i << " threw an exception";
- EXPECT_TRUE(results[i]) << "Thread " << i;
+ EXPECT_EQ(results[i], 1) << "Thread " << i;
}
const auto marker = bulkLoadMarkerFor(compilerType);
if (!marker.empty()) {
- // Regardless of how many threads raced past the cache-miss check, the expensive bulk
- // "get_supported_options" retrieval, guarded by the per-key once_flag, must run exactly once.
EXPECT_EQ(countOccurrences(logs, marker), 1u);
}
}
@@ -317,24 +323,26 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
::testing::Values(ov::intel_npu::CompilerType::DRIVER, ov::intel_npu::CompilerType::PLUGIN),
CompilerOptionSupportHelperFunctionalTests::getTestCaseName);
-// Single helper instance shared by concurrent lookups against two independent compiler-type keys
-// (DRIVER and PLUGIN), to verify the once_flag/cache map has no cross-key races or deadlocks.
class CompilerOptionSupportHelperConcurrencyTests : public ov::test::behavior::OVPluginTestBase {
protected:
- ov::SoPtr<::intel_npu::IEngineBackend> backend;
- std::unique_ptr<::intel_npu::CompilerOptionSupportHelper> helper;
-
- std::string targetDevice;
+ ov::SoPtr<IEngineBackend> backend;
+ std::shared_ptr<OptionSupportCache> optionSupportCache;
+ std::unique_ptr<CompilerOptionSupportHelper> helper;
void SetUp() override {
- targetDevice = ov::test::utils::DEVICE_NPU;
-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
OVPluginTestBase::SetUp();
- backend = ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<::intel_npu::ZeroEngineBackend>());
- helper =
- std::make_unique<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory());
+ // The compiler-in-plugin key of this test needs the real VCL entry points.
+ const auto loader = std::make_shared<VCLLoader>();
+ backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());
+ optionSupportCache = std::make_shared<OptionSupportCache>();
+ helper = std::make_unique<CompilerOptionSupportHelper>(std::make_shared<const CompilerAdapterFactory>(
+ backend,
+ [loader] {
+ return loader->sharedFunctions();
+ },
+ optionSupportCache));
}
void TearDown() override {
@@ -343,10 +351,11 @@ protected:
};
TEST_F(CompilerOptionSupportHelperConcurrencyTests,
- ConcurrentLookupsForDifferentKeysLoadOptionsOncePerKeyWithoutDeadlock) {
+ ConcurrentLookupsForDifferentKeysLoadOptionsOncePerKeyWithoutDeadlock) {
constexpr int kThreadsPerType = 4;
std::vector<std::thread> threads;
- std::vector<bool> results(kThreadsPerType * 2, false);
+ // Avoid vector<bool>'s packed bits: concurrent writes to distinct indices can still race.
+ std::vector<int> results(kThreadsPerType * 2, 0);
std::vector<std::exception_ptr> failures(kThreadsPerType * 2);
std::string logs;
@@ -365,7 +374,9 @@ TEST_F(CompilerOptionSupportHelperConcurrencyTests,
threads.emplace_back([&, i]() {
try {
results[i] = helper->isOptionSupported(ov::intel_npu::CompilerType::DRIVER,
- knownSupportedOptions[i % knownSupportedOptions.size()]);
+ knownSupportedOptions[i % knownSupportedOptions.size()])
+ ? 1
+ : 0;
} catch (...) {
failures[i] = std::current_exception();
}
@@ -374,7 +385,9 @@ TEST_F(CompilerOptionSupportHelperConcurrencyTests,
const int idx = kThreadsPerType + i;
try {
results[idx] = helper->isOptionSupported(ov::intel_npu::CompilerType::PLUGIN,
- knownSupportedOptions[i % knownSupportedOptions.size()]);
+ knownSupportedOptions[i % knownSupportedOptions.size()])
+ ? 1
+ : 0;
} catch (...) {
failures[idx] = std::current_exception();
}
@@ -387,11 +400,9 @@ TEST_F(CompilerOptionSupportHelperConcurrencyTests,
for (size_t i = 0; i < results.size(); ++i) {
ASSERT_FALSE(failures[i]) << "Thread " << i << " threw an exception";
- EXPECT_TRUE(results[i]) << "Thread " << i;
+ EXPECT_EQ(results[i], 1) << "Thread " << i;
}
- // Concurrent traffic on the DRIVER key must not block or interfere with the independent
- // once_flag/cache entry for the PLUGIN key (and vice versa): PLUGIN must still bulk-load exactly once.
EXPECT_EQ(countOccurrences(logs, bulkLoadMarkerFor(ov::intel_npu::CompilerType::PLUGIN)), 1u);
}
diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp
index 9b2aade66e5..79da906e448 100644
--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp
@@ -27,6 +27,7 @@
#include "intel_npu/config/options.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "intel_npu/npuw_private_properties.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
#include "openvino/core/any.hpp"
#include "openvino/core/log.hpp"
#include "openvino/runtime/core.hpp"
@@ -45,11 +46,13 @@ using ConfigParams = std::tuple<std::string, // Device name
namespace ov {
namespace test {
namespace behavior {
+
class PropertiesManagerTests : public ov::test::behavior::OVPluginTestBase,
public testing::WithParamInterface<ConfigParams> {
protected:
std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();
ov::SoPtr<::intel_npu::IEngineBackend> backend;
+ ::intel_npu::VCLFunctionTableProvider vclFunctionsProvider;
std::unique_ptr<::intel_npu::PluginPropertyManager> propertiesManager;
std::string configuration;
@@ -80,6 +83,10 @@ public:
OVPluginTestBase::SetUp();
backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());
+ const auto vclLoader = std::make_shared<VCLLoader>();
+ vclFunctionsProvider = [vclLoader] {
+ return vclLoader->sharedFunctions();
+ };
options->reset();
#define REGISTER_OPTION(OPT_TYPE) \
do { \
@@ -152,10 +159,15 @@ public:
REGISTER_OPTION(Opt);
});
+ const auto optionSupportCache = std::make_shared<::intel_npu::OptionSupportCache>();
+ const auto adapterFactory = std::make_shared<const ::intel_npu::CompilerAdapterFactory>(backend,
+ vclFunctionsProvider,
+ optionSupportCache);
propertiesManager = std::make_unique<PluginPropertyManager>(
options,
backend,
- std::make_shared<::intel_npu::CompilerOptionSupportHelper>(backend, CompilerAdapterFactory()),
+ std::make_shared<::intel_npu::CompilerOptionSupportHelper>(adapterFactory),
+ adapterFactory,
::intel_npu::Logger::global());
}
@@ -678,10 +690,14 @@ TEST_P(CompatibilityCheckTests, CheckUnsupportedConfigWithGetMergedConfigAndUnkn
std::shared_ptr<::intel_npu::OptionsDesc> localOptions = std::make_shared<::intel_npu::OptionsDesc>();
localOptions->add<::intel_npu::COMPILER_TYPE>();
+ const auto optionSupportCache = std::make_shared<::intel_npu::OptionSupportCache>();
+ const auto adapterFactory =
+ std::make_shared<const ::intel_npu::CompilerAdapterFactory>(backend, vclFunctionsProvider, optionSupportCache);
auto localPropertiesManager = std::make_unique<::intel_npu::PluginPropertyManager>(
localOptions,
backend,
- std::make_shared<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory()),
+ std::make_shared<::intel_npu::CompilerOptionSupportHelper>(adapterFactory),
+ adapterFactory,
::intel_npu::Logger::global());
{
diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/vcl_loader.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/vcl_loader.cpp
new file mode 100644
index 00000000000..3c26f601643
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/internal/utils/vcl_loader.cpp
@@ -0,0 +1,212 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <array>
+#include <cstddef>
+#include <exception>
+#include <filesystem>
+#include <functional>
+#include <future>
+#include <memory>
+#include <mutex>
+#include <optional>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "common/utils.hpp"
+#include "common_test_utils/subgraph_builders/multi_single_conv.hpp"
+#include "common_test_utils/test_constants.hpp"
+#include "functional_test_utils/skip_tests_config.hpp"
+#include "intel_npu/npu_private_properties.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
+#include "openvino/runtime/core.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
+#include "openvino/util/file_util.hpp"
+
+namespace {
+
+using namespace ::intel_npu;
+
+constexpr std::string_view kLoaderLibrary = "openvino_intel_npu_compiler_loader";
+constexpr std::string_view kLoadAttemptMarker = "Try to load";
+
+class VCLLoaderTests : public ::testing::Test {
+protected:
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ const auto library =
+ ov::util::make_plugin_library_name(ov::util::get_ov_lib_path(), std::string(kLoaderLibrary));
+ if (!std::filesystem::exists(library)) {
+ GTEST_SKIP() << "Compiler library not installed: " << library;
+ }
+ }
+};
+
+TEST_F(VCLLoaderTests, FunctionTableKeepsLoaderAliveAfterOwnerReleased) {
+ std::shared_ptr<const VCLFunctionTable> functions;
+ {
+ const auto loader = std::make_shared<VCLLoader>();
+ functions = loader->sharedFunctions();
+ }
+ ASSERT_NE(functions, nullptr);
+ ASSERT_NE(functions->vclGetVersion, nullptr);
+ vcl_version_info_t compilerVersion{};
+ vcl_version_info_t profilingVersion{};
+ EXPECT_EQ(functions->vclGetVersion(&compilerVersion, &profilingVersion), VCL_RESULT_SUCCESS);
+}
+
+TEST_F(VCLLoaderTests, RepeatedCallsReturnTheSameTable) {
+ const auto loader = std::make_shared<VCLLoader>();
+
+ EXPECT_EQ(loader->sharedFunctions(), loader->sharedFunctions());
+}
+
+TEST_F(VCLLoaderTests, ConcurrentCallsReturnTheSameTable) {
+ const auto loader = std::make_shared<VCLLoader>();
+ constexpr std::size_t threadCount = 8;
+ std::promise<void> startSignal;
+ const auto start = startSignal.get_future().share();
+ std::array<std::future<std::shared_ptr<const VCLFunctionTable>>, threadCount> calls;
+ for (auto& call : calls) {
+ call = std::async(std::launch::async, [&loader, start] {
+ start.wait();
+ return loader->sharedFunctions();
+ });
+ }
+ startSignal.set_value();
+ const auto functions = calls.front().get();
+ ASSERT_NE(functions, nullptr);
+ for (std::size_t i = 1; i < calls.size(); i++) {
+ EXPECT_EQ(functions, calls[i].get());
+ }
+}
+
+// Each plugin instance loads the VCL library on its own, at most once, and replays a failed load. The tests count the
+// load attempts that the plugin logs, which holds whether or not the compiler library is installed.
+class PluginVCLLoadingTests : public ::testing::Test {
+protected:
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ logCallbackGuard.emplace(logCallback);
+ }
+
+ void TearDown() override {
+ if (!cores.empty()) {
+ cores.back()->set_property(ov::test::utils::DEVICE_NPU, ov::log::level(originalLogLevel));
+ }
+ }
+
+ // The log level is global to the plugin library and a new plugin instance resets it, so it is raised after the
+ // instance is created.
+ ov::Core& createCore() {
+ auto& core = *cores.emplace_back(std::make_unique<ov::Core>());
+ const auto level = core.get_property(ov::test::utils::DEVICE_NPU, ov::log::level);
+ if (cores.size() == 1) {
+ originalLogLevel = level;
+ }
+ core.set_property(ov::test::utils::DEVICE_NPU, ov::log::level(ov::log::Level::DEBUG));
+ return core;
+ }
+
+ std::size_t libraryLoadAttempts() {
+ std::lock_guard<std::mutex> lock(messagesMutex);
+ return static_cast<std::size_t>(std::count_if(messages.begin(), messages.end(), [](const std::string& message) {
+ return message.find(kLoadAttemptMarker) != std::string::npos &&
+ message.find(kLoaderLibrary) != std::string::npos;
+ }));
+ }
+
+ static std::string outcomeOf(const std::function<void()>& request) {
+ try {
+ request();
+ return "ok";
+ } catch (const std::exception& ex) {
+ return ex.what();
+ }
+ }
+
+ // Reaches the compiler-in-plugin through the property manager, which serializes its callers.
+ static void requestCompilerVersion(ov::Core& core) {
+ core.get_property(ov::test::utils::DEVICE_NPU,
+ ov::intel_npu::compiler_version.name(),
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)});
+ }
+
+ // Reaches the compiler-in-plugin straight from the plugin, so concurrent requests are not serialized.
+ static void requestQueryModel(ov::Core& core, const std::shared_ptr<const ov::Model>& model) {
+ core.query_model(model,
+ ov::test::utils::DEVICE_NPU,
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::platform(ov::intel_npu::Platform::NPU4000)});
+ }
+
+ std::vector<std::string> messages;
+ std::mutex messagesMutex;
+ std::function<void(std::string_view)> logCallback = [this](std::string_view message) {
+ std::lock_guard<std::mutex> lock(messagesMutex);
+ messages.emplace_back(message);
+ };
+ std::optional<ov::test::utils::LogCallbackGuard> logCallbackGuard;
+ std::vector<std::unique_ptr<ov::Core>> cores;
+ ov::log::Level originalLogLevel = ov::log::Level::NO;
+};
+
+TEST_F(PluginVCLLoadingTests, RepeatedRequestsLoadTheLibraryOnce) {
+ auto& core = createCore();
+
+ std::vector<std::string> outcomes;
+ for (int i = 0; i < 3; i++) {
+ outcomes.push_back(outcomeOf([&core] {
+ requestCompilerVersion(core);
+ }));
+ }
+
+ EXPECT_EQ(libraryLoadAttempts(), 1u);
+ for (const auto& outcome : outcomes) {
+ EXPECT_EQ(outcome, outcomes.front());
+ }
+}
+
+TEST_F(PluginVCLLoadingTests, ConcurrentFirstRequestsLoadTheLibraryOnce) {
+ constexpr std::size_t threadCount = 4;
+ auto& core = createCore();
+ const auto model = ov::test::utils::make_multi_single_conv();
+
+ std::promise<void> startSignal;
+ const auto start = startSignal.get_future().share();
+ std::vector<std::future<std::string>> requests;
+ for (std::size_t i = 0; i < threadCount; i++) {
+ requests.push_back(std::async(std::launch::async, [&core, &model, start] {
+ start.wait();
+ return outcomeOf([&core, &model] {
+ requestQueryModel(core, model);
+ });
+ }));
+ }
+ startSignal.set_value();
+ for (auto& request : requests) {
+ request.wait();
+ }
+
+ EXPECT_EQ(libraryLoadAttempts(), 1u);
+}
+
+TEST_F(PluginVCLLoadingTests, EachPluginInstanceLoadsTheLibraryItself) {
+ auto& first = createCore();
+ outcomeOf([&first] {
+ requestCompilerVersion(first);
+ });
+ auto& second = createCore();
+ outcomeOf([&second] {
+ requestCompilerVersion(second);
+ });
+
+ EXPECT_EQ(libraryLoadAttempts(), 2u);
+}
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_adapter_factory.cpp b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_adapter_factory.cpp
new file mode 100644
index 00000000000..58a636e04ee
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_adapter_factory.cpp
@@ -0,0 +1,238 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_npu/common/compiler_adapter_factory.hpp"
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "common_test_utils/test_assertions.hpp"
+#include "intel_npu/npu_private_properties.hpp"
+#include "npu/compiler_adapter/fake_vcl.hpp"
+#include "npu/fake_backend_utils.hpp"
+#include "openvino/core/except.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
+#include "vcl_provider_utils.hpp"
+
+// A test without a device models offline compilation: the compiler-in-plugin is then the only one that can serve the
+// request, and the target is given by the platform. The tests named Online* get a device.
+namespace {
+
+using namespace ::intel_npu;
+using CompilerType = ov::intel_npu::CompilerType;
+using ov::test::npu::FakeDevice;
+using ov::test::npu::FakeEngineBackend;
+namespace vcl_provider = ov::test::npu::vcl_provider;
+
+// kPluginPlatform and kOtherPluginPlatform are served by the compiler-in-plugin. kDriverOnlyPlatform is served only by
+// the driver compiler, when the compilation is online.
+constexpr std::string_view kPluginPlatform = ov::intel_npu::Platform::NPU4000;
+constexpr std::string_view kDriverOnlyPlatform = ov::intel_npu::Platform::NPU3720;
+constexpr std::string_view kOtherPluginPlatform = ov::intel_npu::Platform::NPU5010;
+
+CompilerType decide(const CompilerAdapterFactory& factory, std::string_view platform = kPluginPlatform) {
+ auto type = CompilerType::PREFER_PLUGIN;
+ factory.decideCompilerType(type, nullptr, platform);
+ return type;
+}
+
+std::shared_ptr<FakeDevice> deviceOf(std::string_view platform) {
+ return std::make_shared<FakeDevice>(std::string(platform));
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeLoadsFunctionsWithoutCreatingCompiler) {
+ fake_vcl::FakeVcl fake;
+ std::size_t calls = 0;
+ const CompilerAdapterFactory factory({}, vcl_provider::counted(calls, fake.provider()));
+ for (int i = 0; i < 3; i++) {
+ EXPECT_EQ(decide(factory), CompilerType::PLUGIN);
+ }
+ EXPECT_EQ(calls, 3u);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 0u);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeWhenProviderFailsThrowsOffline) {
+ const CompilerAdapterFactory factory({}, vcl_provider::unavailable());
+ OV_EXPECT_THROW_HAS_SUBSTRING(decide(factory), ov::Exception, "Failed to load VCL function table");
+ OV_EXPECT_THROW_HAS_SUBSTRING(decide(factory), ov::Exception, "Injected unavailable provider");
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeExplicitCompilerTypeDoesNotInvokeProvider) {
+ const CompilerAdapterFactory factory(
+ {},
+ vcl_provider::forbidden("An explicit compiler type must not be resolved through the provider"));
+ for (const auto explicitType : {CompilerType::DRIVER, CompilerType::PLUGIN}) {
+ auto type = explicitType;
+ factory.decideCompilerType(type, nullptr, kPluginPlatform);
+ EXPECT_EQ(type, explicitType);
+ }
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeProviderFailuresAreRethrown) {
+ std::size_t calls = 0;
+ const CompilerAdapterFactory factory({}, vcl_provider::counted(calls, vcl_provider::unavailable()));
+ for (int i = 0; i < 2; i++) {
+ OV_EXPECT_THROW_HAS_SUBSTRING(decide(factory), ov::Exception, "Failed to load VCL function table");
+ }
+ EXPECT_EQ(calls, 2u);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeSeparateFactoriesLoadProviderIndependently) {
+ fake_vcl::FakeVcl fake;
+ std::size_t calls = 0;
+ const auto countedProvider = vcl_provider::counted(calls, fake.provider());
+ const CompilerAdapterFactory first({}, countedProvider);
+ const CompilerAdapterFactory second({}, countedProvider);
+ EXPECT_EQ(decide(first), CompilerType::PLUGIN);
+ EXPECT_EQ(decide(second), CompilerType::PLUGIN);
+ EXPECT_EQ(calls, 2u);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 0u);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeOnlinePluginPlatformResolvesToPlugin) {
+ fake_vcl::FakeVcl fake;
+ const CompilerAdapterFactory factory({}, fake.provider());
+ auto type = CompilerType::PREFER_PLUGIN;
+
+ factory.decideCompilerType(type, deviceOf(kPluginPlatform), kPluginPlatform);
+
+ EXPECT_EQ(type, CompilerType::PLUGIN);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 0u);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeOnlineDriverOnlyPlatformDoesNotInvokeProvider) {
+ const CompilerAdapterFactory factory({}, VCLFunctionTableProvider{});
+ auto type = CompilerType::PREFER_PLUGIN;
+
+ factory.decideCompilerType(type, deviceOf(kDriverOnlyPlatform), kDriverOnlyPlatform);
+
+ EXPECT_EQ(type, CompilerType::DRIVER);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeOnlinePluginPlatformFallsBackWhenProviderIsUnavailable) {
+ const CompilerAdapterFactory factory({}, vcl_provider::unavailable());
+ auto type = CompilerType::PREFER_PLUGIN;
+
+ factory.decideCompilerType(type, deviceOf(kPluginPlatform), kPluginPlatform);
+
+ EXPECT_EQ(type, CompilerType::DRIVER);
+}
+
+TEST(CompilerAdapterFactoryTests, DecideCompilerTypeCrossPlatformWithoutPluginThrows) {
+ const CompilerAdapterFactory factory({}, vcl_provider::unavailable());
+ auto type = CompilerType::PREFER_PLUGIN;
+
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.decideCompilerType(type, deviceOf(kPluginPlatform), kOtherPluginPlatform),
+ ov::Exception,
+ "Failed to load VCL function table");
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerPreferPluginLoadsFunctionsThenCreatesCompiler) {
+ fake_vcl::FakeVcl fake;
+ std::size_t providerCalls = 0;
+ const CompilerAdapterFactory factory({}, vcl_provider::counted(providerCalls, fake.provider()));
+
+ auto type = CompilerType::PREFER_PLUGIN;
+ EXPECT_NE(factory.getCompiler(type, kPluginPlatform), nullptr);
+ EXPECT_EQ(type, CompilerType::PLUGIN);
+ EXPECT_EQ(providerCalls, 2u);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 1u);
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerPreferPluginThrowsWhenCompilerCreationFails) {
+ fake_vcl::FakeVcl fake;
+ const CompilerAdapterFactory factory({}, fake.provider());
+ ASSERT_EQ(decide(factory), CompilerType::PLUGIN);
+
+ fake.failWith(fake_vcl::kCompilerCreate, VCL_RESULT_ERROR_UNKNOWN);
+ auto type = CompilerType::PREFER_PLUGIN;
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.getCompiler(type, kPluginPlatform),
+ ov::Exception,
+ "VCL compiler loading failed");
+ EXPECT_EQ(type, CompilerType::PLUGIN);
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerExplicitPluginFailuresDoNotPreventLaterResolution) {
+ fake_vcl::FakeVcl fake;
+ fake.failWith(fake_vcl::kCompilerCreate, VCL_RESULT_ERROR_UNKNOWN);
+ const CompilerAdapterFactory factory({}, fake.provider());
+ for (int i = 0; i < 2; i++) {
+ auto type = CompilerType::PLUGIN;
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.getCompiler(type, kPluginPlatform),
+ ov::Exception,
+ "VCL compiler loading failed");
+ EXPECT_EQ(type, CompilerType::PLUGIN);
+ }
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 2u);
+
+ // Explicit PLUGIN failures do not affect later PREFER_PLUGIN resolution, which only loads functions.
+ fake.succeed(fake_vcl::kCompilerCreate);
+ EXPECT_EQ(decide(factory), CompilerType::PLUGIN);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 2u);
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerDriverTypeThrowsWithoutInvokingProvider) {
+ const CompilerAdapterFactory factory({}, VCLFunctionTableProvider{});
+ auto type = CompilerType::DRIVER;
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.getCompiler(type, kPluginPlatform),
+ ov::Exception,
+ "Could not find an NPU device");
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerDriverTypeForAnotherPlatformThanTheDeviceThrowsWithoutInvokingProvider) {
+ const auto backend =
+ std::make_shared<FakeEngineBackend>(std::vector<std::string>{std::string(kDriverOnlyPlatform)});
+ const CompilerAdapterFactory factory(
+ ov::SoPtr<IEngineBackend>(backend),
+ vcl_provider::forbidden("Driver compilation must not request VCL entry points"));
+ auto type = CompilerType::DRIVER;
+
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.getCompiler(type, kPluginPlatform),
+ ov::Exception,
+ "Could not find a valid NPU device");
+}
+
+TEST(CompilerAdapterFactoryTests, GetCompilerInvalidCompilerTypeThrowsWithoutInvokingProvider) {
+ const CompilerAdapterFactory factory(
+ ov::SoPtr<IEngineBackend>{nullptr},
+ vcl_provider::forbidden("An invalid compiler type must not request VCL entry points"));
+ auto type = static_cast<CompilerType>(999);
+
+ OV_EXPECT_THROW_HAS_SUBSTRING(factory.getCompiler(type, kPluginPlatform),
+ ov::Exception,
+ "Invalid NPU_COMPILER_TYPE");
+}
+
+// Offline compilation can target any platform, including the ones that only the driver compiler serves when the
+// compilation is online. Without a device the platform is not looked at, so one platform of each kind is enough.
+class CompilerAdapterFactoryPlatformTests : public ::testing::TestWithParam<std::string> {};
+
+TEST_P(CompilerAdapterFactoryPlatformTests, DecideCompilerTypeResolvesToPlugin) {
+ fake_vcl::FakeVcl fake;
+ const CompilerAdapterFactory factory({}, fake.provider());
+ EXPECT_EQ(decide(factory, GetParam()), CompilerType::PLUGIN);
+}
+
+TEST_P(CompilerAdapterFactoryPlatformTests, GetCompilerPreferPluginCreatesPluginCompiler) {
+ fake_vcl::FakeVcl fake;
+ const CompilerAdapterFactory factory({}, fake.provider());
+ auto type = CompilerType::PREFER_PLUGIN;
+ EXPECT_NE(factory.getCompiler(type, GetParam()), nullptr);
+ EXPECT_EQ(type, CompilerType::PLUGIN);
+ EXPECT_EQ(fake.callCount(fake_vcl::kCompilerCreate), 1u);
+}
+
+INSTANTIATE_TEST_SUITE_P(OfflinePlatforms,
+ CompilerAdapterFactoryPlatformTests,
+ ::testing::Values(std::string(kDriverOnlyPlatform), std::string(kPluginPlatform)),
+ [](const testing::TestParamInfo<std::string>& info) {
+ return "NPU" + info.param;
+ });
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/fake_vcl.hpp b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/fake_vcl.hpp
index ee39d212f1c..be014291164 100644
--- a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/fake_vcl.hpp
+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/fake_vcl.hpp
@@ -9,6 +9,7 @@
#include <cstring>
#include <map>
#include <memory>
+#include <mutex>
#include <optional>
#include <set>
#include <string>
@@ -16,9 +17,19 @@
#include <vector>
#include "intel_npu/utils/vcl/vcl_api.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
namespace fake_vcl {
+// The options a default FakeVcl advertises as supported.
+inline constexpr const char* kOptionA = "OPT_A";
+inline constexpr const char* kOptionB = "OPT_B";
+inline constexpr const char* kOptionC = "OPT_C";
+
+// Entry point names, as they appear in FakeVcl::calls and the failWith/callCount arguments.
+inline constexpr const char* kCompilerCreate = "vclCompilerCreate";
+inline constexpr const char* kGetCompilerSupportedOptions = "vclGetCompilerSupportedOptions";
+
//
// The VCL entry points are plain C function pointers with no user-data parameter, so the fake has to
// route through a file-static "current instance" pointer. FakeVcl sets it on construction and clears
@@ -69,6 +80,17 @@ public:
std::shared_ptr<const intel_npu::VCLFunctionTable> functions() const {
return _functions;
}
+
+ std::mutex& mutex() {
+ return _mutex;
+ }
+
+ // A provider that always hands out the function table. Shares the table, so it stays valid after the fake.
+ intel_npu::VCLFunctionTableProvider provider() const {
+ return [functions = _functions] {
+ return functions;
+ };
+ }
/// Same table, writable, for tests that need to null an entry point out.
std::shared_ptr<intel_npu::VCLFunctionTable> mutableFunctions() const {
return _functions;
@@ -80,9 +102,11 @@ public:
/// Force a specific entry point to fail. Cleared per entry point.
void failWith(const std::string& fn, vcl_result_t result) {
+ std::lock_guard<std::mutex> lock(_mutex);
_results[fn] = result;
}
void succeed(const std::string& fn) {
+ std::lock_guard<std::mutex> lock(_mutex);
_results.erase(fn);
}
@@ -115,7 +139,7 @@ public:
std::optional<uint64_t> compatibilityStringSizeOverride;
/// Raw buffer returned by vclGetCompilerSupportedOptions (trailing NULs are meaningful).
- std::string supportedOptionsBuffer = std::string("OPT_A OPT_B OPT_C");
+ std::string supportedOptionsBuffer = std::string(kOptionA) + ' ' + kOptionB + ' ' + kOptionC;
/// Options vclGetCompilerIsOptionSupported reports as UNSUPPORTED_FEATURE. Everything else
/// follows failWith("vclGetCompilerIsOptionSupported", ...), so a fake can model a compiler
@@ -155,6 +179,7 @@ public:
int profilingDestroyCount = 0;
size_t callCount(const std::string& fn) const {
+ std::lock_guard<std::mutex> lock(_mutex);
size_t n = 0;
for (const auto& c : calls) {
if (c == fn) {
@@ -170,6 +195,7 @@ public:
/// Index of the first occurrence of fn in the call log, or npos.
size_t indexOf(const std::string& fn) const {
+ std::lock_guard<std::mutex> lock(_mutex);
for (size_t i = 0; i < calls.size(); ++i) {
if (calls[i] == fn) {
return i;
@@ -188,6 +214,7 @@ public:
private:
void wire();
+ mutable std::mutex _mutex;
std::shared_ptr<intel_npu::VCLFunctionTable> _functions;
std::map<std::string, vcl_result_t> _results;
};
@@ -201,6 +228,7 @@ private:
if (self == nullptr) { \
return VCL_RESULT_ERROR_UNKNOWN; \
} \
+ std::lock_guard<std::mutex> lock(self->mutex()); \
const vcl_result_t scripted = self->resultFor(#fn); \
if (scripted != VCL_RESULT_SUCCESS) { \
return scripted; \
@@ -226,6 +254,7 @@ inline vcl_result_t VCL_APICALL fake_vclCompilerCreate(vcl_compiler_desc_t* comp
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
// Record the descriptors even on the failure path: the test asserts what was forwarded.
if (compilerDesc != nullptr) {
self->compilerDescs.push_back(*compilerDesc);
@@ -251,6 +280,7 @@ inline vcl_result_t VCL_APICALL fake_vclCompilerDestroy(vcl_compiler_handle_t) {
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
++self->compilerDestroyCount;
return self->resultFor("vclCompilerDestroy");
}
@@ -290,6 +320,7 @@ inline vcl_result_t VCL_APICALL fake_vclAllocatedExecutableCreate4(vcl_compiler_
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
if (desc.options != nullptr) {
self->buildFlags.emplace_back(desc.options, static_cast<size_t>(desc.optionsSize));
}
@@ -325,6 +356,7 @@ inline vcl_result_t VCL_APICALL fake_vclAllocatedExecutableCreateWSOneShot2(vcl_
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
if (desc.options != nullptr) {
self->buildFlags.emplace_back(desc.options, static_cast<size_t>(desc.optionsSize));
}
@@ -358,6 +390,7 @@ inline vcl_result_t VCL_APICALL fake_vclExecutableGetCompatibilityString(vcl_exe
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
const vcl_result_t scripted = self->resultFor("vclExecutableGetCompatibilityString");
if (scripted != VCL_RESULT_SUCCESS) {
return scripted;
@@ -389,6 +422,7 @@ inline vcl_result_t VCL_APICALL fake_vclExecutableDestroy(vcl_executable_handle_
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
++self->executableDestroyCount;
return self->resultFor("vclExecutableDestroy");
}
@@ -400,6 +434,7 @@ inline vcl_result_t VCL_APICALL fake_vclQueryNetworkCreate(vcl_compiler_handle_t
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
if (desc.options != nullptr) {
self->queryBuildFlags.emplace_back(desc.options, static_cast<size_t>(desc.optionsSize));
}
@@ -432,6 +467,7 @@ inline vcl_result_t VCL_APICALL fake_vclQueryNetworkDestroy(vcl_query_handle_t)
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
++self->queryDestroyCount;
return self->resultFor("vclQueryNetworkDestroy");
}
@@ -483,6 +519,7 @@ inline vcl_result_t VCL_APICALL fake_vclProfilingDestroy(vcl_profiling_handle_t)
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
++self->profilingDestroyCount;
return self->resultFor("vclProfilingDestroy");
}
@@ -511,6 +548,7 @@ inline vcl_result_t VCL_APICALL fake_vclGetCompilerIsOptionSupported(vcl_compile
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
const std::string optionName = option != nullptr ? std::string(option) : std::string();
self->optionSupportQueries.emplace_back(
optionName,
@@ -527,7 +565,11 @@ inline vcl_result_t VCL_APICALL fake_vclExecutableCreate(vcl_compiler_handle_t,
vcl_executable_desc_t,
vcl_executable_handle_t*) {
FakeVcl* self = current();
- return self == nullptr ? VCL_RESULT_ERROR_UNKNOWN : self->resultFor("vclExecutableCreate");
+ if (self == nullptr) {
+ return VCL_RESULT_ERROR_UNKNOWN;
+ }
+ std::lock_guard<std::mutex> lock(self->mutex());
+ return self->resultFor("vclExecutableCreate");
}
inline vcl_result_t VCL_APICALL fake_vclExecutableGetSerializableBlob(vcl_executable_handle_t,
@@ -537,6 +579,7 @@ inline vcl_result_t VCL_APICALL fake_vclExecutableGetSerializableBlob(vcl_execut
if (self == nullptr) {
return VCL_RESULT_ERROR_UNKNOWN;
}
+ std::lock_guard<std::mutex> lock(self->mutex());
if (blobSize != nullptr) {
*blobSize = 0;
}
diff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/vcl_provider_utils.hpp b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/vcl_provider_utils.hpp
new file mode 100644
index 00000000000..a1635fd6f02
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/vcl_provider_utils.hpp
@@ -0,0 +1,55 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <initializer_list>
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "fake_vcl.hpp"
+#include "intel_npu/utils/vcl/vcl_api.hpp"
+#include "intel_npu/utils/vcl/vcl_function_table_provider.hpp"
+#include "openvino/core/except.hpp"
+
+namespace ov::test::npu::vcl_provider {
+
+// A provider over a fake VCL table. The closure keeps the fake instance alive.
+inline ::intel_npu::VCLFunctionTableProvider fake(std::initializer_list<std::string> unsupportedOptions = {}) {
+ auto fakeVcl = std::make_shared<::fake_vcl::FakeVcl>();
+ fakeVcl->unsupportedOptions.insert(unsupportedOptions.begin(), unsupportedOptions.end());
+ return [fakeVcl = std::move(fakeVcl)] {
+ return fakeVcl->functions();
+ };
+}
+
+// A provider whose VCL library cannot be loaded.
+inline ::intel_npu::VCLFunctionTableProvider unavailable() {
+ return []() -> std::shared_ptr<const ::intel_npu::VCLFunctionTable> {
+ OPENVINO_THROW("Injected unavailable provider");
+ };
+}
+
+// A provider the code under test must never call. A call fails the test.
+inline ::intel_npu::VCLFunctionTableProvider forbidden(std::string reason) {
+ return [reason = std::move(reason)]() -> std::shared_ptr<const ::intel_npu::VCLFunctionTable> {
+ ADD_FAILURE() << reason;
+ OPENVINO_THROW("Unexpected provider invocation: ", reason);
+ };
+}
+
+// Wraps `vclFunctionsProvider`, counting every call in `calls`. `calls` must outlive the returned provider.
+inline ::intel_npu::VCLFunctionTableProvider counted(std::size_t& calls,
+ ::intel_npu::VCLFunctionTableProvider vclFunctionsProvider) {
+ return [&calls, vclFunctionsProvider = std::move(vclFunctionsProvider)] {
+ calls++;
+ return vclFunctionsProvider();
+ };
+}
+
+} // namespace ov::test::npu::vcl_provider
diff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp b/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp
index 6e4b3e5d995..75acee1e485 100644
--- a/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp
+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_option_support_helper_test.cpp
@@ -6,12 +6,31 @@
#include <gtest/gtest.h>
+#include <memory>
+#include <utility>
+
#include "openvino/core/except.hpp"
namespace {
using CompilerType = ov::intel_npu::CompilerType;
+struct CompilerOptionSupportTestContext {
+ std::shared_ptr<::intel_npu::OptionSupportCache> cache;
+ std::shared_ptr<const ::intel_npu::CompilerAdapterFactory> factory;
+ std::unique_ptr<::intel_npu::CompilerOptionSupportHelper> helper;
+};
+
+CompilerOptionSupportTestContext makeContext(
+ const ov::SoPtr<::intel_npu::IEngineBackend>& backend = ov::SoPtr<::intel_npu::IEngineBackend>{nullptr}) {
+ auto cache = std::make_shared<::intel_npu::OptionSupportCache>();
+ auto factory = std::make_shared<const ::intel_npu::CompilerAdapterFactory>(backend,
+ ::intel_npu::VCLFunctionTableProvider{},
+ cache);
+ auto helper = std::make_unique<::intel_npu::CompilerOptionSupportHelper>(factory);
+ return {std::move(cache), std::move(factory), std::move(helper)};
+}
+
// Minimal IEngineBackend double: exercises the real CompilerAdapterFactory::getCompiler() logic
// (no device available) without requiring an actual NPU driver/compiler in the test environment.
class MockEngineBackendNoDevice : public ::intel_npu::IEngineBackend {
@@ -35,54 +54,68 @@ public:
};
TEST(CompilerOptionSupportHelperTests, ReturnsCachedSupportedOptionWithoutBackend) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext();
const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::PLUGIN);
- helper.getOptionSupportCache()->addSupportedOption(key, "CACHED_OPTION", true);
+ context.cache->addSupportedOption(key, "CACHED_OPTION", true);
- EXPECT_TRUE(helper.isOptionSupported(CompilerType::PLUGIN, "CACHED_OPTION"));
+ EXPECT_TRUE(context.helper->isOptionSupported(CompilerType::PLUGIN, "CACHED_OPTION"));
}
TEST(CompilerOptionSupportHelperTests, ReturnsCachedUnsupportedOptionWithoutBackend) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext();
const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);
- helper.getOptionSupportCache()->addSupportedOption(key, "CACHED_OPTION", false);
+ context.cache->addSupportedOption(key, "CACHED_OPTION", false);
- EXPECT_FALSE(helper.isOptionSupported(CompilerType::DRIVER, "CACHED_OPTION"));
+ EXPECT_FALSE(context.helper->isOptionSupported(CompilerType::DRIVER, "CACHED_OPTION"));
}
TEST(CompilerOptionSupportHelperTests, KeepsCompilerTypeCacheEntriesIndependent) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext();
const auto pluginKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::PLUGIN);
const auto driverKey = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);
- helper.getOptionSupportCache()->addSupportedOption(pluginKey, "SHARED_OPTION", true);
- helper.getOptionSupportCache()->addSupportedOption(driverKey, "SHARED_OPTION", false);
+ context.cache->addSupportedOption(pluginKey, "SHARED_OPTION", true);
+ context.cache->addSupportedOption(driverKey, "SHARED_OPTION", false);
- EXPECT_TRUE(helper.isOptionSupported(CompilerType::PLUGIN, "SHARED_OPTION"));
- EXPECT_FALSE(helper.isOptionSupported(CompilerType::DRIVER, "SHARED_OPTION"));
+ EXPECT_TRUE(context.helper->isOptionSupported(CompilerType::PLUGIN, "SHARED_OPTION"));
+ EXPECT_FALSE(context.helper->isOptionSupported(CompilerType::DRIVER, "SHARED_OPTION"));
}
TEST(CompilerOptionSupportHelperTests, RejectsPreferPluginBeforeCompilerLookup) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext();
- EXPECT_THROW(helper.isOptionSupported(CompilerType::PREFER_PLUGIN, "ANY_OPTION"), ov::Exception);
+ EXPECT_THROW(context.helper->isOptionSupported(CompilerType::PREFER_PLUGIN, "ANY_OPTION"), ov::Exception);
}
TEST(CompilerOptionSupportHelperTests, RejectsCompilerTypeOutsideSupportedList) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext();
- EXPECT_THROW(helper.isOptionSupported(static_cast<CompilerType>(999), "ANY_OPTION"), ov::Exception);
+ EXPECT_THROW(context.helper->isOptionSupported(static_cast<CompilerType>(999), "ANY_OPTION"), ov::Exception);
}
-TEST(CompilerOptionSupportHelperTests, ExposesSharedOptionSupportCache) {
- ::intel_npu::CompilerOptionSupportHelper helper({nullptr}, ::intel_npu::CompilerAdapterFactory());
-
- ASSERT_NE(helper.getOptionSupportCache(), nullptr);
+TEST(CompilerOptionSupportHelperTests, ContextSharesCacheWithFactoryAndHelper) {
+ const auto context = makeContext();
+ ASSERT_NE(context.cache, nullptr);
+ ASSERT_NE(context.factory, nullptr);
+ ASSERT_NE(context.helper, nullptr);
+ EXPECT_EQ(context.factory->getOptionSupportCache(), context.cache);
}
TEST(CompilerOptionSupportHelperTests, DriverLookupWithoutDeviceThrows) {
auto backend = std::make_shared<MockEngineBackendNoDevice>();
ov::SoPtr<::intel_npu::IEngineBackend> backendPtr(backend);
- ::intel_npu::CompilerOptionSupportHelper helper(backendPtr, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext(backendPtr);
+
+ EXPECT_THROW(context.helper->isOptionSupported(CompilerType::DRIVER, "ANY_OPTION"), ov::Exception);
+}
+
+TEST(CompilerOptionSupportHelperTests, DriverLookupWithoutDeviceThrowsWhenFactoryCacheDisabled) {
+ auto backend = std::make_shared<MockEngineBackendNoDevice>();
+ ov::SoPtr<::intel_npu::IEngineBackend> backendPtr(backend);
+ const auto factory =
+ std::make_shared<const ::intel_npu::CompilerAdapterFactory>(backendPtr,
+ ::intel_npu::VCLFunctionTableProvider{},
+ nullptr);
+ ::intel_npu::CompilerOptionSupportHelper helper(factory);
EXPECT_THROW(helper.isOptionSupported(CompilerType::DRIVER, "ANY_OPTION"), ov::Exception);
}
@@ -90,13 +123,14 @@ TEST(CompilerOptionSupportHelperTests, DriverLookupWithoutDeviceThrows) {
TEST(CompilerOptionSupportHelperTests, OptionValueBypassesCacheAndReachesCompilerLookup) {
auto backend = std::make_shared<MockEngineBackendNoDevice>();
ov::SoPtr<::intel_npu::IEngineBackend> backendPtr(backend);
- ::intel_npu::CompilerOptionSupportHelper helper(backendPtr, ::intel_npu::CompilerAdapterFactory());
+ auto context = makeContext(backendPtr);
const auto key = static_cast<::intel_npu::OptionSupportCache::CacheKey>(CompilerType::DRIVER);
- helper.getOptionSupportCache()->addSupportedOption(key, "ANY_OPTION", true);
+ context.cache->addSupportedOption(key, "ANY_OPTION", true);
// Even though "ANY_OPTION" is cached as supported, providing a concrete value must skip the
// cache and fall through to the real compiler lookup, which throws without a device.
- EXPECT_THROW(helper.isOptionSupported(CompilerType::DRIVER, "ANY_OPTION", std::string("1")), ov::Exception);
+ EXPECT_THROW(context.helper->isOptionSupported(CompilerType::DRIVER, "ANY_OPTION", std::string("1")),
+ ov::Exception);
}
} // namespace
diff --git a/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp b/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp
index 0dec94d84c7..34013c3f65b 100644
--- a/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp
+++ b/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp
@@ -6,102 +6,20 @@
#include <gtest/gtest.h>
-#include <algorithm>
-#include <cctype>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
#include "intel_npu/npu_private_properties.hpp"
-#include "openvino/core/except.hpp"
+#include "npu/fake_backend_utils.hpp"
namespace {
-class MockDevice : public ::intel_npu::IDevice {
-public:
- explicit MockDevice(std::string name) : _name(std::move(name)) {}
-
- std::string getName() const override {
- return _name;
- }
- std::string getFullDeviceName() const override {
- return "Mock NPU " + _name;
- }
- std::shared_ptr<::intel_npu::InferRequest> createInferRequest(
- const std::shared_ptr<const ::intel_npu::ICompiledModel>&,
- const ::intel_npu::Config&) override {
- return nullptr;
- }
- void updateInfo(const ov::AnyMap&) override {}
- bool validateCompatibilityDescriptor(const std::string&) const override {
- return true;
- }
- DeviceProperties getDeviceProperties() const override {
- return {};
- }
-
-private:
- std::string _name;
-};
-
-// Mirrors ZeroEngineBackend::getDevice(name) lookup: empty -> first device, number -> index if in range, otherwise
-// name.
-class MockEngineBackend : public ::intel_npu::IEngineBackend {
-public:
- explicit MockEngineBackend(std::vector<std::string> deviceNames) {
- for (auto& name : deviceNames) {
- _devices.push_back(std::make_shared<MockDevice>(std::move(name)));
- }
- }
-
- const std::shared_ptr<::intel_npu::IDevice> getDevice() const override {
- return _devices.empty() ? nullptr : _devices.front();
- }
- const std::shared_ptr<::intel_npu::IDevice> getDevice(const std::string& name) const override {
- if (_devices.empty()) {
- return nullptr;
- }
- if (name.empty()) {
- return getDevice();
- }
- // A number is an index first, otherwise it is searched as an arch name (e.g. "5010")
- if (std::all_of(name.begin(), name.end(), ::isdigit)) {
- const auto index = static_cast<size_t>(std::stoul(name));
- if (index < _devices.size()) {
- return _devices[index];
- }
- }
- for (const auto& device : _devices) {
- if (device->getName() == name) {
- return device;
- }
- }
- OPENVINO_THROW("Could not find available NPU device with the specified name: NPU.", name);
- }
- const std::vector<std::string> getDeviceNames() const override {
- std::vector<std::string> names;
- for (const auto& device : _devices) {
- names.push_back(device->getName());
- }
- return names;
- }
- const std::string getName() const override {
- return "MOCK";
- }
- bool isCommandQueueExtSupported() const override {
- return false;
- }
- bool isLUIDExtSupported() const override {
- return false;
- }
- bool isContextExtSupported() const override {
- return false;
- }
- void updateInfo(const ov::AnyMap&) override {}
-
-private:
- std::vector<std::shared_ptr<MockDevice>> _devices;
-};
+using ov::test::npu::FakeEngineBackend;
ov::SoPtr<::intel_npu::IEngineBackend> makeBackend(std::vector<std::string> deviceNames) {
- return ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<MockEngineBackend>(std::move(deviceNames)));
+ return ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<FakeEngineBackend>(std::move(deviceNames)));
}
const std::string NPU4000{ov::intel_npu::Platform::NPU4000};
diff --git a/src/plugins/intel_npu/tests/unit/npu/fake_backend_utils.hpp b/src/plugins/intel_npu/tests/unit/npu/fake_backend_utils.hpp
new file mode 100644
index 00000000000..ae9ca3a1b96
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npu/fake_backend_utils.hpp
@@ -0,0 +1,164 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <algorithm>
+#include <cctype>
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "intel_npu/common/npu.hpp"
+#include "openvino/core/any.hpp"
+#include "openvino/core/except.hpp"
+
+namespace ov::test::npu {
+
+// Hand written fakes of the backend interfaces: they have no call expectations, only canned values and a device lookup
+// like the real one.
+class FakeDevice final : public ::intel_npu::IDevice {
+public:
+ static constexpr uint32_t kDeviceId = 0;
+ static constexpr uint32_t kSubDevId = 3;
+ static constexpr uint32_t kMaxNumSlices = 4;
+ static constexpr uint64_t kAllocMemSize = 4096;
+ static constexpr uint8_t kUuidByte = 0x5A;
+
+ // @param reportsMaxNumSlices When false, getMaxNumSlices() fails like on a device that cannot report it.
+ explicit FakeDevice(std::string name, bool reportsMaxNumSlices = true)
+ : _name(std::move(name)),
+ _reportsMaxNumSlices(reportsMaxNumSlices) {}
+
+ std::string getName() const override {
+ return _name;
+ }
+ std::string getFullDeviceName() const override {
+ return "Fake NPU " + _name;
+ }
+ Uuid getUuid() const override {
+ Uuid uuid{};
+ uuid.uuid.fill(kUuidByte);
+ return uuid;
+ }
+ uint64_t getAllocMemSize() const override {
+ return kAllocMemSize;
+ }
+ uint32_t getSubDevId() const override {
+ return kSubDevId;
+ }
+ uint32_t getMaxNumSlices() const override {
+ return _reportsMaxNumSlices ? kMaxNumSlices : ::intel_npu::IDevice::getMaxNumSlices();
+ }
+ std::shared_ptr<::intel_npu::InferRequest> createInferRequest(
+ const std::shared_ptr<const ::intel_npu::ICompiledModel>&,
+ const ::intel_npu::Config&) override {
+ return nullptr;
+ }
+ void updateInfo(const ov::AnyMap&) override {}
+ bool validateCompatibilityDescriptor(const std::string&) const override {
+ return true;
+ }
+ DeviceProperties getDeviceProperties() const override {
+ return {kDeviceId, kSubDevId, kMaxNumSlices};
+ }
+
+private:
+ std::string _name;
+ bool _reportsMaxNumSlices;
+};
+
+struct FakeBackendOptions {
+ bool contextExtensionSupported = false;
+ uint32_t driverVersion = 1;
+ uint32_t graphExtVersion = 1;
+};
+
+// Mirrors the device lookup of ZeroEngineBackend: an empty id selects the first device, a number is an index when it is
+// in range and a name otherwise, and an unknown name throws. No names means no devices, like offline compilation.
+class FakeEngineBackend final : public ::intel_npu::IEngineBackend {
+public:
+ static constexpr const char* kName = "FAKE_BACKEND";
+
+ explicit FakeEngineBackend(const std::vector<std::string>& deviceNames, FakeBackendOptions options = {})
+ : _options(options) {
+ for (const auto& name : deviceNames) {
+ _devices.push_back(std::make_shared<FakeDevice>(name));
+ }
+ }
+
+ explicit FakeEngineBackend(std::vector<std::shared_ptr<FakeDevice>> devices, FakeBackendOptions options = {})
+ : _options(options),
+ _devices(std::move(devices)) {}
+
+ const std::shared_ptr<::intel_npu::IDevice> getDevice() const override {
+ return _devices.empty() ? nullptr : _devices.front();
+ }
+ const std::shared_ptr<::intel_npu::IDevice> getDevice(const std::string& name) const override {
+ if (_devices.empty()) {
+ return nullptr;
+ }
+ if (name.empty()) {
+ return getDevice();
+ }
+ const auto isDigit = [](unsigned char character) {
+ return std::isdigit(character) != 0;
+ };
+ if (std::all_of(name.begin(), name.end(), isDigit)) {
+ const auto index = static_cast<std::size_t>(std::stoul(name));
+ if (index < _devices.size()) {
+ return _devices[index];
+ }
+ }
+ for (const auto& device : _devices) {
+ if (device->getName() == name) {
+ return device;
+ }
+ }
+ OPENVINO_THROW("Could not find available NPU device with the specified name: NPU.", name);
+ }
+ const std::vector<std::string> getDeviceNames() const override {
+ std::vector<std::string> names;
+ for (const auto& device : _devices) {
+ names.push_back(device->getName());
+ }
+ return names;
+ }
+ uint32_t getDriverVersion() const override {
+ return _options.driverVersion;
+ }
+ uint32_t getGraphExtVersion() const override {
+ return _options.graphExtVersion;
+ }
+ const std::string getName() const override {
+ return kName;
+ }
+ bool isCommandQueueExtSupported() const override {
+ return false;
+ }
+ bool isLUIDExtSupported() const override {
+ return false;
+ }
+ bool isContextExtSupported() const override {
+ return _options.contextExtensionSupported;
+ }
+ void updateInfo(const ov::AnyMap& properties) override {
+ _updatedProperties = properties;
+ }
+
+ // What the last updateInfo() call received.
+ const ov::AnyMap& updatedProperties() const {
+ return _updatedProperties;
+ }
+
+private:
+ const FakeBackendOptions _options;
+ ov::AnyMap _updatedProperties;
+ std::vector<std::shared_ptr<FakeDevice>> _devices;
+};
+
+} // namespace ov::test::npu