OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Register all properties only once, update supported_properties only when need them (#36623)
Bogdan Pereanu1d9da14ce1cb
diff --git a/src/plugins/intel_npu/README.md b/src/plugins/intel_npu/README.mdindex 93a561d01f1..6a96a0d1050 100644--- a/src/plugins/intel_npu/README.md+++ b/src/plugins/intel_npu/README.md@@ -152,17 +152,30 @@ Properties will get registered and advertised based on the following logic:- Does the compiler report supported properties? (older compilers from driver do not)- Yes:- check if property is supported by compiler- - if supported: **Enable** and advertise in supported_properties- - if NOT supported: **Disable** and don't advertise in supported properties+ - if supported: advertise in supported_properties+ - if NOT supported: don't advertise in supported properties- No (fallback to legacy mode):- check if property's support version >= compiler version- - true: **Enable** and advertise in supported properties- - false: **Disable** and don't advertise in supported properties+ - true: advertise in supported properties+ - false: don't advertise in supported properties-Note: this logic does not affect OptionMode::Runtime type of options/properties. Those will get registered w/o any criteria, with the exception of some special cases, like NPU_TURBO or WORKLOAD_TYPE (which are tied to driver graph extension version).+### Property manager and configuration flow++The property manager handles individual property requests through `getProperty`, `setProperty`, and+`isPropertySupported`. For compilation, import, and query operations, it also provides+`getMergedConfigAndUnknownProperties`, which returns a merged `Config` and an `ov::AnyMap` of properties that are not+consumed by the plugin.++The merged `Config` is shared with the compiler, import path, and other runtime components. During compilation and+import, the `Config` and `unknownProperties` are passed together to the compiled model, which uses them to initialize its+property manager. Compiler-supported internal options are kept in `Config`; only the remaining unconsumed properties are+forwarded in `unknownProperties`.++The detailed property and configuration design, is described in [NPU Properties](./docs/npu-properties-howto.md).+The following methods are made available to return the value of a given property (at core level or model specific):```plugin_properties = ov.get_property("NPU", <property_name>);diff --git a/src/plugins/intel_npu/docs/example-adding-property.patch b/src/plugins/intel_npu/docs/example-adding-property.patchdeleted file mode 100644index 4dc63d9807b..00000000000--- a/src/plugins/intel_npu/docs/example-adding-property.patch+++ /dev/null@@ -1,163 +0,0 @@-From 17b6ddb34c1c670765cfe4f93cd686dc88ff3c33 Mon Sep 17 00:00:00 2001-From: csoka <[email protected]>-Date: Tue, 27 May 2025 20:50:06 +0300-Subject: [PATCH 1/2] [intel-npu] Example of adding a new config-backed NPU- property------ .../npu-device.rst | 1 +- .../pyopenvino/core/properties/properties.cpp | 1 +- .../openvino/runtime/intel_npu/properties.hpp | 8 +++- src/plugins/intel_npu/README.md | 1 +- .../al/include/intel_npu/config/options.hpp | 55 +++++++++++++++++++- .../intel_npu/src/plugin/src/plugin.cpp | 1 +- .../intel_npu/src/plugin/src/properties.cpp | 2 +- 7 files changed, 69 insertions(+)--diff --git a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-index 279ad1dfcf..93c749d83a 100644---- a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-+++ b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-@@ -151,6 +151,7 @@ offer a limited set of supported OpenVINO features.- ov::intel_npu::bypass_umd_caching- ov::intel_npu::defer_weights_load- ov::intel_npu::run_inferences_sequentially-+ ov::intel_npu::example_property-- .. tab-item:: Read-only properties--diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-index 4aadb3dec9..5349248ac7 100644---- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-@@ -342,4 +342,5 @@ void regmodule_properties(py::module m) {- wrap_property_RW(m_intel_npu, ov::intel_npu::compiler_dynamic_quantization, "compiler_dynamic_quantization");- wrap_property_RW(m_intel_npu, ov::intel_npu::qdq_optimization, "qdq_optimization");- wrap_property_RW(m_intel_npu, ov::intel_npu::run_inferences_sequentially, "run_inferences_sequentially");-+ wrap_property_RW(m_intel_npu, ov::intel_npu::example_property, "example_property");- }-diff --git a/src/inference/include/openvino/runtime/intel_npu/properties.hpp b/src/inference/include/openvino/runtime/intel_npu/properties.hpp-index 5deabd6ba6..10ba958498 100644---- a/src/inference/include/openvino/runtime/intel_npu/properties.hpp-+++ b/src/inference/include/openvino/runtime/intel_npu/properties.hpp-@@ -136,5 +136,13 @@ static constexpr ov::Property<bool> defer_weights_load{"NPU_DEFER_WEIGHTS_LOAD"}- */- static constexpr ov::Property<bool> run_inferences_sequentially{"NPU_RUN_INFERENCES_SEQUENTIALLY"};--+/**-+ * @brief [Only for NPU Plugin]-+ * Type: boolean, default is false.-+ * Example property for demonstration and documentation purposes-+ * @ingroup ov_runtime_npu_prop_cpp_api-+ */-+static constexpr ov::Property<uint32_t, ov::PropertyMutability::RW> example_property{"NPU_EXAMPLE_PROPERTY"};-+- } // namespace intel_npu- } // namespace ov-diff --git a/src/plugins/intel_npu/README.md b/src/plugins/intel_npu/README.md-index ab8d083fda..c15e61091b 100644---- a/src/plugins/intel_npu/README.md-+++ b/src/plugins/intel_npu/README.md-@@ -204,6 +204,7 @@ The following properties are supported (may differ based on current system confi- | `ov::intel_npu::bypass_umd_caching`/</br>`NPU_BYPASS_UMD_CACHING` | RW | Bypass the caching of compiled models in UMD. | `YES`/ `NO`| `NO` |- | `ov::intel_npu::defer_weights_load`/</br>`NPU_DEFER_WEIGHTS_LOAD` | RW | Delay loading the weights until inference is created. | `YES`/ `NO`| `NO` |- | `ov::intel_npu::run_inferences_sequentially`/</br>`NPU_RUN_INFERENCES_SEQUENTIALLY` | RW | Run inferences in async mode sequentially in the order in which they are started to optimize host scheduling. | `YES`/ `NO`| `NO` |-+| `ov::intel_npu::example_property`/</br>`NPU_EXAMPLE_PROPERTY` | RW | Example property for demonstration purposes | `<std::uint32_t>`| `1337` |-- - ### Compiled_model properties VS Plugin properties-diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-index 0ecd186c05..fa311e84de 100644---- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-@@ -1407,4 +1407,59 @@ struct MODEL_PTR final : OptionBase<MODEL_PTR, std::shared_ptr<const ov::Model>>- }- };--+//-+// EXAMPLE_PROPERTY-+//-+struct EXAMPLE_PROPERTY final : OptionBase<EXAMPLE_PROPERTY, uint32_t> {-+ static std::string_view key() {-+ return ov::intel_npu::example_property.name();-+ }-+-+ static constexpr std::string_view getTypeName() {-+ return "uint32_t";-+ }-+-+ static uint32_t defaultValue() {-+ return 1337;-+ }-+-+ static bool isPublic() {-+ return true;-+ }-+-+ static OptionMode mode() {-+ return OptionMode::Both;-+ }-+-+ static ov::PropertyMutability mutability() {-+ return ov::PropertyMutability::RW;-+ }-+-+ static std::string_view envVar() {-+ return "IE_NPU_EXAMPLE_PROPERTY";-+ }-+-+ static uint32_t parse(std::string_view val) {-+ if (val == "1337") {-+ return 1337;-+ } else if (val == "666") {-+ return 666;-+ }-+-+ OPENVINO_THROW("Value '", val, "'is not a valid EXAMPLE_PROPERTY option");-+ }-+-+ static std::string toString(const uint32_t& val) {-+ std::stringstream strStream;-+-+ strStream << val;-+-+ return strStream.str();-+ }-+};-+- } // namespace intel_npu-diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp-index 1f8e9c8732..a0a98ca709 100644---- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp-+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp-@@ -215,6 +215,7 @@ void Plugin::init_options() {- REGISTER_OPTION(DISABLE_VERSION_CHECK);- REGISTER_OPTION(MODEL_PTR);- REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);-+ REGISTER_OPTION(EXAMPLE_PROPERTY);- if (_backend) {- if (_backend->isCommandQueueExtSupported()) {- REGISTER_OPTION(TURBO);-diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp-index cf9f68f570..79ed35c2af 100644---- a/src/plugins/intel_npu/src/plugin/src/properties.cpp-+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp-@@ -377,6 +377,7 @@ void Properties::registerPluginProperties() {- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::batch_compiler_mode_settings, BATCH_COMPILER_MODE_SETTINGS);- TRY_REGISTER_SIMPLE_PROPERTY(ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);- TRY_REGISTER_SIMPLE_PROPERTY(ov::workload_type, WORKLOAD_TYPE);-+ TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::example_property, EXAMPLE_PROPERTY);-- TRY_REGISTER_CUSTOMFUNC_PROPERTY(ov::intel_npu::stepping, STEPPING, [&](const Config& config) {- if (!config.has<STEPPING>()) {-@@ -531,6 +532,7 @@ void Properties::registerCompiledModelProperties() {- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::batch_compiler_mode_settings,- BATCH_COMPILER_MODE_SETTINGS);- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);-+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::example_property, EXAMPLE_PROPERTY);-- TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::batch_mode, BATCH_MODE, false);-----2.34.1-diff --git a/src/plugins/intel_npu/docs/example-removing-property.patch b/src/plugins/intel_npu/docs/example-removing-property.patchdeleted file mode 100644index a4ef70fe618..00000000000--- a/src/plugins/intel_npu/docs/example-removing-property.patch+++ /dev/null@@ -1,163 +0,0 @@-From 569809974c58901faef73e4bd3d6b84c47a3ff2c Mon Sep 17 00:00:00 2001-From: csoka <[email protected]>-Date: Tue, 27 May 2025 20:51:40 +0300-Subject: [PATCH 2/2] [intel-npu] Example for removing a config-backed NPU- property------ .../npu-device.rst | 1 -- .../pyopenvino/core/properties/properties.cpp | 1 -- .../openvino/runtime/intel_npu/properties.hpp | 8 ---- src/plugins/intel_npu/README.md | 1 -- .../al/include/intel_npu/config/options.hpp | 55 -------------------- .../intel_npu/src/plugin/src/plugin.cpp | 1 -- .../intel_npu/src/plugin/src/properties.cpp | 2 -- 7 files changed, 69 deletions(-)--diff --git a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-index 93c749d83a..279ad1dfcf 100644---- a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-+++ b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-@@ -151,7 +151,6 @@ offer a limited set of supported OpenVINO features.- ov::intel_npu::bypass_umd_caching- ov::intel_npu::defer_weights_load- ov::intel_npu::run_inferences_sequentially-- ov::intel_npu::example_property-- .. tab-item:: Read-only properties--diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-index 5349248ac7..4aadb3dec9 100644---- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp-@@ -342,5 +342,4 @@ void regmodule_properties(py::module m) {- wrap_property_RW(m_intel_npu, ov::intel_npu::compiler_dynamic_quantization, "compiler_dynamic_quantization");- wrap_property_RW(m_intel_npu, ov::intel_npu::qdq_optimization, "qdq_optimization");- wrap_property_RW(m_intel_npu, ov::intel_npu::run_inferences_sequentially, "run_inferences_sequentially");-- wrap_property_RW(m_intel_npu, ov::intel_npu::example_property, "example_property");- }-diff --git a/src/inference/include/openvino/runtime/intel_npu/properties.hpp b/src/inference/include/openvino/runtime/intel_npu/properties.hpp-index 10ba958498..5deabd6ba6 100644---- a/src/inference/include/openvino/runtime/intel_npu/properties.hpp-+++ b/src/inference/include/openvino/runtime/intel_npu/properties.hpp-@@ -136,13 +136,5 @@ static constexpr ov::Property<bool> defer_weights_load{"NPU_DEFER_WEIGHTS_LOAD"}- */- static constexpr ov::Property<bool> run_inferences_sequentially{"NPU_RUN_INFERENCES_SEQUENTIALLY"};---/**-- * @brief [Only for NPU Plugin]-- * Type: boolean, default is false.-- * Example property for demonstration and documentation purposes-- * @ingroup ov_runtime_npu_prop_cpp_api-- */--static constexpr ov::Property<uint32_t, ov::PropertyMutability::RW> example_property{"NPU_EXAMPLE_PROPERTY"};--- } // namespace intel_npu- } // namespace ov-diff --git a/src/plugins/intel_npu/README.md b/src/plugins/intel_npu/README.md-index c15e61091b..ab8d083fda 100644---- a/src/plugins/intel_npu/README.md-+++ b/src/plugins/intel_npu/README.md-@@ -204,7 +204,6 @@ The following properties are supported (may differ based on current system confi- | `ov::intel_npu::bypass_umd_caching`/</br>`NPU_BYPASS_UMD_CACHING` | RW | Bypass the caching of compiled models in UMD. | `YES`/ `NO`| `NO` |- | `ov::intel_npu::defer_weights_load`/</br>`NPU_DEFER_WEIGHTS_LOAD` | RW | Delay loading the weights until inference is created. | `YES`/ `NO`| `NO` |- | `ov::intel_npu::run_inferences_sequentially`/</br>`NPU_RUN_INFERENCES_SEQUENTIALLY` | RW | Run inferences in async mode sequentially in the order in which they are started to optimize host scheduling. | `YES`/ `NO`| `NO` |--| `ov::intel_npu::example_property`/</br>`NPU_EXAMPLE_PROPERTY` | RW | Example property for demonstration purposes | `<std::uint32_t>`| `1337` |-- - ### Compiled_model properties VS Plugin properties-diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-index fa311e84de..0ecd186c05 100644---- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp-@@ -1407,59 +1407,4 @@ struct MODEL_PTR final : OptionBase<MODEL_PTR, std::shared_ptr<const ov::Model>>- }- };---//--// EXAMPLE_PROPERTY--//--struct EXAMPLE_PROPERTY final : OptionBase<EXAMPLE_PROPERTY, uint32_t> {-- static std::string_view key() {-- return ov::intel_npu::example_property.name();-- }---- static constexpr std::string_view getTypeName() {-- return "uint32_t";-- }---- static uint32_t defaultValue() {-- return 1337;-- }---- static bool isPublic() {-- return true;-- }---- static OptionMode mode() {-- return OptionMode::Both;-- }---- static ov::PropertyMutability mutability() {-- return ov::PropertyMutability::RW;-- }---- static std::string_view envVar() {-- return "IE_NPU_EXAMPLE_PROPERTY";-- }---- static uint32_t parse(std::string_view val) {-- if (val == "1337") {-- return 1337;-- } else if (val == "666") {-- return 666;-- }---- OPENVINO_THROW("Value '", val, "'is not a valid EXAMPLE_PROPERTY option");-- }---- static std::string toString(const uint32_t& val) {-- std::stringstream strStream;---- strStream << val;---- return strStream.str();-- }--};--- } // namespace intel_npu-diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp-index a0a98ca709..1f8e9c8732 100644---- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp-+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp-@@ -215,7 +215,6 @@ void Plugin::init_options() {- REGISTER_OPTION(DISABLE_VERSION_CHECK);- REGISTER_OPTION(MODEL_PTR);- REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);-- REGISTER_OPTION(EXAMPLE_PROPERTY);- if (_backend) {- if (_backend->isCommandQueueExtSupported()) {- REGISTER_OPTION(TURBO);-diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp-index 79ed35c2af..cf9f68f570 100644---- a/src/plugins/intel_npu/src/plugin/src/properties.cpp-+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp-@@ -377,7 +377,6 @@ void Properties::registerPluginProperties() {- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::batch_compiler_mode_settings, BATCH_COMPILER_MODE_SETTINGS);- TRY_REGISTER_SIMPLE_PROPERTY(ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);- TRY_REGISTER_SIMPLE_PROPERTY(ov::workload_type, WORKLOAD_TYPE);-- TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::example_property, EXAMPLE_PROPERTY);-- TRY_REGISTER_CUSTOMFUNC_PROPERTY(ov::intel_npu::stepping, STEPPING, [&](const Config& config) {- if (!config.has<STEPPING>()) {-@@ -532,7 +531,6 @@ void Properties::registerCompiledModelProperties() {- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::batch_compiler_mode_settings,- BATCH_COMPILER_MODE_SETTINGS);- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);-- TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::example_property, EXAMPLE_PROPERTY);-- TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::batch_mode, BATCH_MODE, false);-----2.34.1-diff --git a/src/plugins/intel_npu/docs/img/properties_class_hierarchy.png b/src/plugins/intel_npu/docs/img/properties_class_hierarchy.pngdeleted file mode 100644index b623be33384..00000000000--- a/src/plugins/intel_npu/docs/img/properties_class_hierarchy.png+++ /dev/null@@ -1,3 +0,0 @@-version https://git-lfs.github.com/spec/v1-oid sha256:368b64e950d4201186230fc765492fe6f9c1a73475308dfdb576fa5055d64285-size 114174diff --git a/src/plugins/intel_npu/docs/img/properties_init_sequence.png b/src/plugins/intel_npu/docs/img/properties_init_sequence.pngdeleted file mode 100644index a48840ce563..00000000000--- a/src/plugins/intel_npu/docs/img/properties_init_sequence.png+++ /dev/null@@ -1,3 +0,0 @@-version https://git-lfs.github.com/spec/v1-oid sha256:f34af338a6b2ea8fc1654d496f1851287bbce762ceddbaa953680c1ca364bee8-size 107606diff --git a/src/plugins/intel_npu/docs/npu-properties-howto.md b/src/plugins/intel_npu/docs/npu-properties-howto.mdindex 80820a790a8..31fe465a0ca 100644--- a/src/plugins/intel_npu/docs/npu-properties-howto.md+++ b/src/plugins/intel_npu/docs/npu-properties-howto.md@@ -6,13 +6,14 @@ Practical manual for NPU plugin properties- [Glossary](#glossary)- [Structure of a property (Class hierarchy)](#structure-of-a-property-class-hierarchy)- - [Property vs Option vs Metric](#property-vs-option-vs-metric)+ - [Properties With Option vs Properties Without Option](#properties-with-option-vs-properties-without-option)+ - [Property resolution flow](#property-resolution-flow)+ - [Plugin-to-compiled-model property flow](#plugin-to-compiled-model-property-flow)- [OptionBase<T>](#optionbaset)- [OptionDesc](#optiondesc)- [Config](#config)- - [FilteredConfig](#filteredconfig)- [Properties](#properties)-- [How to add a new public (option backed) property](#how-to-add-a-new-public-option-backed-property)+- [How to add a new public (option-backed) property](#how-to-add-a-new-public-option-backed-property)- [Step 1. Define the new property](#step-1-define-the-new-property)- [Step 2. Define the internal option descriptor](#step-2-define-the-internal-option-descriptor)- [Step 3. Register the new option](#step-3-register-the-new-option)@@ -21,26 +22,23 @@ Practical manual for NPU plugin properties- [For compiled-model (if required)](#for-compiled-model-if-required)- [Step 5. Python bindings](#step-5-python-bindings)- [Step 6. Update documentation](#step-6-update-documentation)-- [How to add a new public (metric backed) property](#how-to-add-a-new-public-metric-backed-property)+- [How to add a new public property without option (callback-backed/read-only)](#how-to-add-a-new-public-property-without-option-callback-backedread-only)- [Step 1. Define the new property](#step-1-define-the-new-property-1)- - [Step 2. Define and register a callback function for the new (metric) Property](#step-2-define-and-register-a-callback-function-for-the-new-metric-property)+ - [Step 2. Define and register a callback function for the new property](#step-2-define-and-register-a-callback-function-for-the-new-property)- [Step 3. Python bindings](#step-3-python-bindings)- [Step 4. Update documentation](#step-4-update-documentation)- [Compiled-model properties](#compiled-model-properties)-- [Special cases](#special-cases)- - [SC.1 Adding a new property which requires custom functions](#sc1-adding-a-new-property-which-requires-custom-functions)- - [SC.2 Adding a new (metric-backed) property which requires customization](#sc2-adding-a-new-metric-backed-property-which-requires-customization)- - [SC.3 Filtering out options at registration phase](#sc3-filtering-out-options-at-registration-phase)- [Removing a public property](#removing-a-public-property)## Glossary| Name | Description | Example ||:--------:|:--------- |:--------: |-| Property | a plugin interface which can be set or read. Can map to options or metrics` | `ov::log::level` |+| Property | a plugin interface which can be set or read | `ov::log::level` || Option | a configuration entry in our internal configuration.</br>Consists of an OptionBase template descriptor + a template OptionValue value. | `LOG_LEVEL` |-| Config | Our internal database of configuration keys and their values | `_globalConfig` |-| Metric | A property which does not map to any configuration key and configuration entry in our internal config.</br>Usually a static value directly read from driver or OS. | `ov::device::pci_info` |+| Config | Our internal database of configuration keys and their values | |+| Option-backed property | A property mapped to an Option entry in Config through `register_property`. | `ov::hint::performance_mode` |+| Property without option (callback-backed/read-only) | A property that is not mapped to Config and is implemented by callback logic (usually runtime/backend queries). | `ov::device::pci_info` || Compiler | Npu compiler as viewed from the plugin's perspective.</br>Can be Compiler-In-Driver or Compiler-In-Plugin | `CID` || "Anonymous" property</br>OR</br>compiler-private property | A setting from application level which the plugin has no knowledge of</br>(it is not registered, plugin is not aware of its datatype)</br> but which the compiler reports as supported via is_supported() API. | N/A |@@ -48,20 +46,93 @@ Practical manual for NPU plugin properties## Structure of a property (Class hierarchy)-+### Properties With Option vs Properties Without Option+As shown in the class hierarchy, a property is the public interface to internal information. A property can be+implemented either through a `Config` option or through callback logic.-<br>+Option-backed properties are stored in `Config` and can be updated through their registered setter. Properties without+an option are computed on demand, typically from the backend, driver, or operating system. Examples include driver+version, compiler version, device architecture, PCI information, GOPS, UUID, and LUID.-### Property vs Option vs Metric-As it can be observed in the above class hierarchy diagram, a Property is a public interface to an internal information, the top layer of abstraction.-A property can connect internally to an Option or to a Metric.-The main difference between Option and Metric is that while Options are entries in our internal database (Config) which can be modified at any time, Metrics are static read-only pieces of information-which do not exist in the internal database. Metrics can not be set or changed externally, their values are not stored in the plugin and they most often just a direct system or driver call.-Example of Metrics in NPU Plugin are: driver version, compiler version, device architecture, pci information, gops, uuid, luid, etc.To summarize:-A property can map internally to **one** of the 2 types:-- either a Option, if it has an entry in our internal Config, it is a mutable setting used either by compiler or by inference-- either a Metric, if it is a static immutable piece of information that only needs to be returned on request (system/platform/hardware etc information)+A property can be implemented in **one** of the 2 ways:+- Option-backed property: has an entry in internal Config and is managed through Option descriptors/helpers.+- Property without option: implemented through callback logic (typically read-only runtime/backend information).++### Property resolution flow++The following diagram shows how the two property implementations are initialized and exposed. Compiler type,+backend availability, option mode, and whether a value was stored can affect the final supported property set.++```mermaid+flowchart TD+ A[Application] --> B[PluginPropertyManager]++ B --> C[getProperty]+ B --> D[setProperty]+ B --> E[isPropertySupported]+ C --> F[Registered properties and callbacks]+ D --> F+ E --> F++ B --> G[getMergedConfigAndUnknownProperties]+ G --> H[Config plus unknownProperties]+ H --> I[Config]+ H --> J[unknownProperties: ov::AnyMap]++ I --> K[Compiler]+ I --> L[Import path]+ I --> M[Other runtime components]++ I --> N[CompiledModel]+ J --> N+ N --> O[CompiledModelPropertyManager]+ O --> P[Compiled-model properties]+```++### Plugin-to-compiled-model property flow++`PluginPropertyManager` exposes two different kinds of APIs:++- `getProperty`, `setProperty`, and `isPropertySupported` resolve individual properties through the registered property+ descriptors, support predicates, getters, and setters.+- `getMergedConfigAndUnknownProperties` prepares the configuration for a larger operation and returns both the merged+ configuration and properties that the plugin does not consume.++`Config` is the shared configuration used by the compiler, import path, and other runtime components.++`PluginPropertyManager::getMergedConfigAndUnknownProperties` returns:++```cpp+std::pair<Config, ov::AnyMap>+```++- The returned `Config` is the merged `Config` view after property support, compiler type, option mode, and+ operation rules have been applied. It is consumed by the compiler, import path, other runtime components, and the+ compiled model.+- `unknownProperties` is an `ov::AnyMap` containing keys that the plugin does not consume. During compilation and import,+ this map is passed together with the merged `Config` to `CompiledModel`, which constructs+ `CompiledModelPropertyManager` with both values.++Compiler options are represented by the same option descriptors as other options. Their `OptionMode` determines where+they are used:++- `CompileTime`: used by the compiler and removed or skipped on import.+- `Runtime`: used by plugin/runtime components and not sent to the compiler.+- `Both`: available to the compiler during compilation and to applicable runtime components.++The `mergeMode` controls how the pair is produced:++| Mode | Behavior |+|:-----|:---------|+| `Compile` | Compiler-supported unknown keys are stored as internal configuration. Other unknown keys are returned in `unknownProperties` for the compiled model. |+| `Import` | Compile-time-only options are removed or skipped because the model is already compiled. If `LOADED_FROM_CACHE` is true, compiler options are checked and skipped with a warning; otherwise they are not relevant to the import path. |+| `Query` | Unsupported unknown keys cause an exception instead of being forwarded. |++For registered properties, the manager validates mutability and support before updating `Config`. For compiler-only+properties skipped during import, `unknownProperties` remains empty and the manager logs that the property will not be used+for the current configuration. In `Query` mode, only the merged `Config` view is used; the `unknownProperties` map is not+forwarded to a compiled model. Compiled-model properties are normally registered as read-only.### OptionBase\<T\>Implements the option descriptor. This class contains all the details of a config option: name, datatype, default value, parser, public/private, mutability, compiler version (for legacy support), etc. This serves as the key in our configuration map.@@ -115,7 +186,7 @@ struct OptionBase {return false;}- // Overload this for read-only options (metrics)+ // Overload this for read-only propertiesstatic ov::PropertyMutability mutability() {return ov::PropertyMutability::RW;}@@ -126,39 +197,45 @@ struct OptionBase {};```-### OptionDesc-is storage for the registered options This is the base map which stores the available optionBase descriptors.-This layer implements the option database manipulation functions: add/remove/has/reset-```` Note: This layer is static, intialized once in plugin constructor with all the options the Plugin has knowledge of. ````+### OptionDesc+is storage for the registered options. This is the base map which stores the available OptionBase descriptors.+This layer implements the option database manipulation functions: add/has/reset.+The plugin creates it once and reuses it during constructor bootstrap: first with `LOG_LEVEL` only (for early logging),+then with the full plugin and backend options before property-manager initialization.### Config-is the highlevel configuration "database" which implements the mapping between OptionBase and templatized OptionValue.-Maps and stores the user-defined values for each entry in OptionsDesc layer.-Implements the top level configuration manipulation functions:-get/update/has/getString/toString/fromString and handles typecasts, typeverification, parsing and conversions.-```` Note: This layer is static, initialized once in plugin constructor with the provided (also static) OptionDesc. ````--### FilteredConfig-is a derivative class of Config, used only by NPU Plugin, which implements additional filtering layers atop of the base config,-such as enabling/disabling keys based on their availability/support on the current system configuration.-```` Note: This layer dynamically changes based on system configuration and compiler_type ````+`Config` is the high-level configuration database that maps `OptionBase` descriptors to typed option values. It maps and+stores user-defined values from the `OptionsDesc` layer and implements the top-level configuration functions:+get/update/updateAny/has/getString/toString/fromString and handles typecasts, type verification, parsing and conversions.+It also applies availability and support filtering based on the current system configuration and compiler type.++The target design is one unified `Config` class that combines the current `Config` and `FilteredConfig` responsibilities.+Today, `FilteredConfig` is still a derived implementation used by the NPU plugin; it is not a separate conceptual+configuration layer in the target design.++In plugin bootstrap, `Config` is created early from a minimal descriptor (`LOG_LEVEL`), then expanded in place as the+shared `OptionsDesc` is populated and environment variables are reparsed.++The initialization order is:+1. `Plugin` creates and populates `OptionsDesc` with all plugin options (`register_options(...)`) and then registers backend options (`backend->registerOptions(*options)` when a backend exists).+2. `Plugin` constructs `PluginPropertyManager`, which resolves the effective compiler context and registers property descriptors.### Propertiesis the top level class and serves as the NPU Plugin's interface to OpenVino and the application layer.-It's main purpose is to implement get_property and set_property interfaces and the callback functions of each property.+Its main purpose is to implement `get_property` and `set_property` interfaces and the callback functions for each property.```` Note: This layer dynamically changes based on system configuration and compiler_type ````<br><br>-# How to add a new public (option backed) property+# How to add a new public (option-backed) property-The following steps how to add a new simple property which maps to a compiler configuration option.+The following steps explain how to add a new simple property that maps to a compiler configuration option._*simple in this context means that it has no special callback function required for it, just set/get_## Step 1. Define the new propertyFirst step is to define the new property's name, datatype and string-name in the public header in```bash-openvino/src/inference/include/openvino/runtime/intel_npu/properties.hpp+src/inference/include/openvino/runtime/intel_npu/properties.hpp```Example:```cpp@@ -172,7 +249,7 @@ Notes:## Step 2. Define the internal option descriptorSecond step is to define the optionDesc class for this property in```bash-openvino/src/plugins/intel_npu/al/config/options.hpp+src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp```Example:```cpp@@ -233,7 +310,7 @@ struct EXAMPLE_PROPERTY final : OptionBase<EXAMPLE_PROPERTY, ov::intel_npu::ExamNotes:- key(): needs to return the string name of the property (the NPU_EXAMPLE_PROPERTY defined in the property at step 1)- getTypeName: returns the type name as a human-readable string-- defaultValue: returns the option's default value (if there was no user-defined value set, config.get or get_property(EXAMPLE_PROPERTY) will call this function+- defaultValue: returns the option's default value (if there was no user-defined value set, config.get or get_property(EXAMPLE_PROPERTY) will call this function)- isPublic: defines whether the option is a **public or a private** one- mode: defines the OptionMode of this option. Can be:- CompileTime (for options used ONLY by the compiler)@@ -247,65 +324,91 @@ Notes:**(!!)** None of the member functions are mandatory to be defined.If any is missing, the default function will be used for its call, as defined in the OptionsBase class-(see class **OptionBase** in *npu_plugin/al/include/config/config.hpp* or Class Hierarchy section above)+(see class **OptionBase** in `src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp` or Class Hierarchy section above)## Step 3. Register the new option-Third step is to register the new option in the plugin:-**plugin.cpp > function init_options()**:+Third step is to register the new option in the plugin:+**src/plugins/intel_npu/src/plugin/src/plugin.cpp > function register_options(...)**```cppREGISTER_OPTION(EXAMPLE_PROPERTY);```Notes:-at this point, the npu plugin will take care of registering and managing the option in the internal configuration.-It ensures that it is enabled or disabled based in the current system/environment/application configuration.+The plugin registers the option in `OptionsDesc` before the backend adds its compiler-specific options.## Step 4. Link the new property to the new option-Fourth step is to create and register the Property (which is basicly the interface to this configuration option) for both Plugin and CompiledModel (if needed)+Fourth step is to create and register the Property (which is basically the interface to this configuration option) for both Plugin and CompiledModel (if needed)### For plugin-npu_plugin/plugin/src/plugin_property_manager.cpp > function PluginPropertyManager::registerProperties()+src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp > function PluginPropertyManager::registerProperties()```cpp-try_register_property_based_on_config<EXAMPLE_PROPERTY>(_config, _properties, ov::intel_npu::example_property.name());+register_property(+ EXAMPLE_PROPERTY::key(),+ true,+ ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(EXAMPLE_PROPERTY::key());+ },+ [this](const ov::AnyMap&) {+ return _config.get<EXAMPLE_PROPERTY>();+ },+ [this](const ov::Any& value) {+ _config.updateAny(EXAMPLE_PROPERTY::key(), value);+ });```**Explanation:**-this helper function will register (if all conditions are met) a property with the name ov::intel_npu::example_property.name()-which maps to our internal configuration named EXAMPLE_PROPERTY-and has a simple callback function of config.get<EXAMPLE_PROPERTY>()+`register_property` stores the property name, visibility, mutability, support predicate, getter, and setter in one+descriptor. The support predicate determines whether the property is exposed. The getter reads the typed option from+`Config`, and the setter validates and stores the supplied value through `updateAny`.### For compiled-model (if required)-npu_plugin/plugin/src/compiled_model_property_manager.cpp > function CompiledModelPropertyManager::registerProperties()+src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp > function CompiledModelPropertyManager::registerProperties()```cpp-try_register_property_based_on_config_if_set_as_read_only<EXAMPLE_PROPERTY>(_config, _properties, ov::intel_npu::example_property.name());+const auto hasPropertyValue = [this](const std::string& propertyName) {+ return _config.has(propertyName);+};++register_property(+ EXAMPLE_PROPERTY::key(),+ true,+ ov::PropertyMutability::RO,+ [this, hasPropertyValue](const ov::AnyMap&) {+ return _config.hasOpt(EXAMPLE_PROPERTY::key()) && hasPropertyValue(EXAMPLE_PROPERTY::key());+ },+ [this](const ov::AnyMap&) {+ return _config.get<EXAMPLE_PROPERTY>();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ });```**Explanation:**-this helper function registers the compiled-model property with the name ov::intel_npu::example_property.name()-which maps to our internal configuration named EXAMPLE_PROPERTY-and has a simple callback function of config.get<EXAMPLE_PROPERTY>()-**(!!) ONLY** if it has been previously explicitly set at compile time.+Compiled-model properties are normally read-only. The support predicate above exposes the property only when the+option is registered and has an explicitly stored value in the compiled model's configuration. The setter is still+required by the common descriptor, but rejects writes.## Step 5. Python bindings-In order for the property to be property exposed in python API, add python wrapper for the new property in pyOpenvino-openvino/src/bindings/python/src/pyopenvino/core/properties/properties.cpp:-In section // sumbodule npu+In order for the property to be exposed in Python API, add python wrapper for the new property in pyOpenvino+src/bindings/python/src/pyopenvino/core/properties/properties.cpp:+In section // submodule npu```cppwrap_property_RW(m_intel_npu, ov::intel_npu::example_property, "example_property");```## Step 6. Update documentation-Document the new property in the appropaite sections (+ additional information, if required) in:+Document the new property in the appropriate sections (+ additional information, if required) in:```bash-openvino/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-openvino/src/plugins/intel_npu/README.md+docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst+src/plugins/intel_npu/README.md```<br><br>-# How to add a new public (metric backed) property-As described in the first paragraph, Metrics do not have an entry in our internal Config, they are static immutable data which just needs to be returned at get_property calls.-This means we do not need to define and Option nor register an Option for it.+# How to add a new public property without option (callback-backed/read-only)+As described in the first paragraph, these properties do not have an entry in our internal Config and are returned through callback logic at get_property calls.+This means we do not need to define an Option nor register an Option for them.## Step 1. Define the new propertyFirst step is to define the new property's name, datatype and string-name in the public header in```bash-openvino/src/inference/include/openvino/runtime/intel_npu/properties.hpp+src/inference/include/openvino/runtime/intel_npu/properties.hpp```Example:```cpp@@ -316,138 +419,95 @@ Notes:- mutability is Read-Only- datatype of the property is enum ExampleType { VAL1, VAL2, VAL3 }-## Step 2. Define and register a callback function for the new (metric) Property+## Step 2. Define and register a callback function for the new propertyYou need to register the new property and define a callback function in the owner-specific property manager.-For plugin: npu_plugin/plugin/src/plugin_property_manager.cpp > function PluginPropertyManager::registerProperties()-For compiled-model: npu_plugin/plugin/src/compiled_model_property_manager.cpp > function CompiledModelPropertyManager::registerProperties()+For plugin: src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp > function PluginPropertyManager::registerProperties()+For compiled-model: src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp > function CompiledModelPropertyManager::registerProperties()++For properties without option, prefer a support-gated registration so the getter is only used when backend/runtime requirements are available:```cpp- register_property_with_custom_function(_properties, ov::intel_npu::example_property.name(), true, _metrics->GetDriverVersion());+ const auto has_backend = [this](const ov::AnyMap&) {+ return _backend != nullptr;+ };++ register_property(+ ov::intel_npu::example_property.name(),+ true,+ ov::PropertyMutability::RO,+ has_backend,+ [this](const ov::AnyMap&) {+ return utils::getDriverVersion(_backend);+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ });```**Explanation**-this helper function will register a property with the name **ov::intel_npu::example_property (NPU_EXAMPLE_PROPERTY)**, which will be public and included in supported_properties (second parameter)-which will execute `_metrics->GetDriverVersion()` as its get_property callback.+`register_property` registers a property with the name **ov::intel_npu::example_property (NPU_EXAMPLE_PROPERTY)**, which is public and included in supported_properties when the support predicate returns true.+and calls `utils::getDriverVersion(_backend)` each time get_property is queried. The getter receives query-time+arguments as `ov::AnyMap`; use them when the property supports extra inputs, or ignore them when it does not.Note: the first argument is the property name string (`property.name()`), not the property object itself.## Step 3. Python bindings-In order for the property to be property exposed in python API, add python wrapper for the new property in pyOpenvino-openvino/src/bindings/python/src/pyopenvino/core/properties/properties.cpp:-In section // sumbodule npu+In order for the property to be exposed in Python API, add python wrapper for the new property in pyOpenvino+src/bindings/python/src/pyopenvino/core/properties/properties.cpp:+In section // submodule npu```cppwrap_property_RO(m_intel_npu, ov::intel_npu::example_property, "example_property");```## Step 4. Update documentation-Document the new property in the appropaite sections (+ additional information, if required) in:+Document the new property in the appropriate sections (+ additional information, if required) in:```bash-openvino/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst-openvino/src/plugins/intel_npu/README.md+docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/npu-device.rst+src/plugins/intel_npu/README.md```<br><br># Compiled-model properties-By internal convention, what needs to be included in compiled-model properties gets decided based on the following statements:-- every option which has an effect on model compilation (meaning options with mode=OptionMode::CompileTime or OptionMode::Both) need to be included-- options (with some specific exceptions) should be publicly advertised in compiled-model's supported_properties **ONLY** if they have been explicitly set prior to model compilation.-- compiled-model properties (with a few specific exceptions) are all READ-ONLY, for the reason that the model has already been compiled.-This is to ensure that we only expose settings we are sure were taken into account by compiler.--To facilitate registering properties in compiled-model **ONLY** if they have been explicitly set prior to model compilation, property_registration.hpp provides a helper function:-#### try_register_property_based_on_config_if_set_as_read_only<OPT_TYPE>(config, properties, propertyName)-This helper function registers the provided property to the provided option type only if a value for it exists in the config. (default values do not live in config, but are directly read from OptionsDesc)-Example:-```cpp- try_register_property_based_on_config_if_set_as_read_only<COMPILATION_MODE>(_config,- _properties,- ov::intel_npu::compilation_mode.name());-```--<br><br>--# Special cases-## SC.1 Adding a new property which requires custom functions-If the new property requires a custom callback function, only Step 4. changes.-Instead of using try_register_property_based_on_config helper function, you can choose from the following helper functions:--#### try_register_property_based_on_config_with_visibility<OPT_TYPE>(config, properties, propertyName, is_public)-This can be used when callback is standard, but visibility (public/private) is custom.-Instead of using automatically the value from the option descriptor, one can pass a runtime bool to determine-whether the property will be public (included in supported_properties) or private.-Example:-```cpp- try_register_property_based_on_config_with_visibility<RUN_INFERENCES_SEQUENTIALLY>(- _config,- _properties,- ov::intel_npu::run_inferences_sequentially.name(),- [&] { return _backend && _backend->getInitStructs(); }());-```+Compiled-model properties describe settings that were used to create an already compiled model. By convention:+- options with `OptionMode::CompileTime` or `OptionMode::Both` may be exposed;+- most properties are exposed only when their value was explicitly stored before compilation;+- compiled-model properties are normally `RO`, because changing them cannot recompile the model.-#### try_register_property_based_on_config_with_custom_function(config, properties, propertyName, getter)-This helper function can be used whenever a custom callback function/implementation is required for this property,-provided as a lambda function. The getter receives the Config object and must return an ov::Any value.-(Standard callback function just returns the value of the config)-Example:+The compiled-model manager uses the same six-argument `register_property` function as the plugin manager:```cpp- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::intel_npu::stepping.name(),- [&](const Config& config) {- if (!config.has<STEPPING>()) {- return static_cast<int64_t>(_metrics->GetSteppingNumber(specifiedDeviceName));- }- return config.get<STEPPING>();- });+register_property(+ propertyName,+ isPublic,+ mutability,+ isSupported,+ getter,+ setter);```-## SC.2 Adding a new (metric-backed) property which requires customization-Apart from `register_property_with_custom_function`, two additional helper functions are available for metric-backed properties:--#### try_register_property_with_custom_function(properties, propertyName, shouldRegister, isPublic, getter)-Conditionally registers a metric property. The property is only added when `shouldRegister` is true.-Use this when the availability of a metric depends on a runtime condition (e.g. backend capability check).-Example:+For properties that require an explicitly stored value, use a support predicate such as:```cpp- try_register_property_with_custom_function(_properties,- ov::device::full_name.name(),- !_metrics->GetAvailableDevicesNames().empty(),- true,- [&](const Config& config) {- const auto specifiedDeviceName = get_specified_device_name(config);- return _metrics->GetFullDeviceName(specifiedDeviceName);- });+const auto hasPropertyValue = [this](const std::string& propertyName) {+ return _config.has(propertyName);+};++register_property(+ EXAMPLE_PROPERTY::key(),+ true,+ ov::PropertyMutability::RO,+ [this, hasPropertyValue](const ov::AnyMap&) {+ return _config.hasOpt(EXAMPLE_PROPERTY::key()) && hasPropertyValue(EXAMPLE_PROPERTY::key());+ },+ [this](const ov::AnyMap&) {+ return _config.get<EXAMPLE_PROPERTY>();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ });```-#### try_register_property_with_custom_function_and_args(properties, propertyName, shouldRegister, isPublic, getter)-Same as `try_register_property_with_custom_function`, but for properties whose getter also receives an `ov::AnyMap` of additional-arguments at get_property call time. Use this for properties such as `ov::compatibility_check` that accept-extra input arguments.-Example:-```cpp- try_register_property_with_custom_function_and_args(_properties,- ov::compatibility_check.name(),- _compatibilityCheckSupported,- true,- [this](const Config&, const ov::AnyMap& arguments) {- return validateCompatibilityDescriptor(_backend, arguments);- });-```--## SC.3 Filtering out options at registration phase-There is a possibility to get options filtered out right at the options registration phase too, if desired by a specific cornercase.-If the option is not registered, it will be virtually inexistent in the whole stack at runtime, so there will be no added overhead by all the availability checks and verifications the properties manager does.-To achieve this, we can condition the registration of the option in:-plugin.cpp > (function) void Plugin::init_options()-Example:-```cpp- if (_backend) {- if (_backend->isCommandQueueExtSupported()) {- REGISTER_OPTION(TURBO);- REGISTER_OPTION(WORKLOAD_TYPE);- }- }-```-The above code will register TURBO and WORKLOAD_TYPE options only if command queue extension is supported by the backend (and of course, first if a backend exists)-Having skipped the option registration (in case command queue extension is not supported), the option will not exist in the stack, will not be checked for compiler support, will not be enabled/disabled dinamically and **can not be enabled dynamically** anymore at runtime.+Some compiled-model properties are intentionally available whenever their option is registered, using+`_config.hasOpt(propertyName)` without requiring `_config.has(propertyName)`. This applies to properties whose+default value is part of the compiled-model contract.<br><br># Removing a public property-Removing a public property can be done by removing everything added in section "How do add a new public property" step-by-step.+Removing a public property can be done by removing everything added in section "How to add a new public property" step-by-step.diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hppindex a16ea0227fb..776b3150c70 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp@@ -479,9 +479,11 @@ public:explicit Config(const std::shared_ptr<const OptionsDesc>& desc);- virtual void update(const ConfigMap& options);+ void update(const ConfigMap& options);+ void updateAny(const ov::AnyMap& options);- virtual void updateAny(const ov::AnyMap& options);+ void update(std::string_view key, std::string_view value);+ void updateAny(std::string_view key, const ov::Any& value);void parseEnvVars();@@ -489,6 +491,7 @@ public:bool has() const;bool has(std::string key) const;+ void remove(std::string key);template <class Opt>typename Opt::ValueType get() const;diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hppindex bd3ccfe3073..ec9eaf43cdf 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp@@ -568,6 +568,32 @@ struct MODEL_PRIORITY final : OptionBase<MODEL_PRIORITY, ov::hint::Priority> {}};+struct MODEL_PTR final : OptionBase<MODEL_PTR, std::weak_ptr<const ov::Model>> {+ static std::string_view key() {+ return ov::hint::model.name();+ }++ static constexpr std::string_view getTypeName() {+ return "std::weak_ptr<const ov::Model>";+ }++ static std::weak_ptr<const ov::Model> defaultValue() {+ return {};+ }++ static OptionMode mode() {+ return OptionMode::RunTime;+ }++ static std::string toString(const std::weak_ptr<const ov::Model>&) {+ OPENVINO_THROW("Option ", ov::hint::model.name(), " cannot be converted to string");+ }++ static std::weak_ptr<const ov::Model> parse(std::string_view) {+ OPENVINO_THROW("Option ", ov::hint::model.name(), " cannot be parsed from string");+ }+};+struct CREATE_EXECUTOR final : OptionBase<CREATE_EXECUTOR, int64_t> {static std::string_view key() {return ov::intel_npu::create_executor.name();@@ -1499,67 +1525,4 @@ struct CACHE_ENCRYPTION_CALLBACKS final : OptionBase<CACHE_ENCRYPTION_CALLBACKS,}};-struct RUNTIME_REQUIREMENTS final : OptionBase<RUNTIME_REQUIREMENTS, std::string> {- static std::string_view key() {- return ov::runtime_requirements.name();- }-- static std::string defaultValue() {- return {};- }-- static OptionMode mode() {- return OptionMode::RunTime;- }-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RO;- }-};--struct COMPATIBILITY_CHECK final : OptionBase<COMPATIBILITY_CHECK, ov::CompatibilityCheck> {- static std::string_view key() {- return ov::compatibility_check.name();- }-- static constexpr std::string_view getTypeName() {- return "ov::CompatibilityCheck";- }-- static ov::CompatibilityCheck defaultValue() {- return ov::CompatibilityCheck::NOT_APPLICABLE;- }-- static OptionMode mode() {- return OptionMode::RunTime;- }-- static ov::CompatibilityCheck parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::CompatibilityCheck check_result;- stringStream >> check_result;-- return check_result;- }-- static std::string toString(const ov::CompatibilityCheck& val) {- std::ostringstream stringStream;- stringStream << val;-- return stringStream.str();- }-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RO;- }-};-} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/al/src/config/config.cpp b/src/plugins/intel_npu/src/al/src/config/config.cppindex 5ebf77e4bdf..6c5925ebdfa 100644--- a/src/plugins/intel_npu/src/al/src/config/config.cpp+++ b/src/plugins/intel_npu/src/al/src/config/config.cpp@@ -264,6 +264,10 @@ bool Config::has(std::string key) const {return _impl.count(key) != 0;}+void Config::remove(std::string key) {+ _impl.erase(key);+}+void Config::update(const ConfigMap& options) {for (const auto& p : options) {_log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());@@ -282,6 +286,20 @@ void Config::updateAny(const ov::AnyMap& options) {}}+void Config::update(std::string_view key, std::string_view value) {+ _log.trace("Update option '%s' to value '%s'", std::string(key).c_str(), std::string(value).c_str());++ const auto opt = _desc->get(key);+ _impl[opt.key().data()] = opt.validateAndParseFromString(value);+}++void Config::updateAny(std::string_view key, const ov::Any& value) {+ _log.trace("Update option '%s' to given 'ov::Any' value", std::string(key).c_str());++ const auto opt = _desc->get(key);+ _impl[opt.key().data()] = opt.validateAndParseFromAny(value);+}+std::string Config::toString() const {std::stringstream resultStream;for (auto it = _impl.cbegin(); it != _impl.cend(); ++it) {@@ -298,14 +316,13 @@ std::string Config::toString() const {}void Config::fromString(const std::string& str) {- std::map<std::string, std::string> config;std::string str_cfg(str);auto parse_token = [&](const std::string& token) {auto pos_eq = token.find('=');auto key = token.substr(0, pos_eq);auto value = token.substr(pos_eq + 2, token.size() - pos_eq - 3);- config[key] = std::move(value);+ update(key, value);};size_t pos = 0;@@ -318,8 +335,6 @@ void Config::fromString(const std::string& str) {// Process tailparse_token(str_cfg);-- update(config);}//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.hppindex d3c0996404e..089e92651c0 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@@ -5,8 +5,11 @@#pragma once#include <atomic>+#include <cstdint>#include <memory>+#include <optional>#include <string_view>+#include <utility>#include <vector>#include "intel_npu/common/icompiler_adapter.hpp"@@ -26,10 +29,26 @@ public:std::string_view platform,const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr) const;- static const std::vector<ov::intel_npu::CompilerType>& getSupportedCompilerTypes();+ void decideCompilerType(ov::intel_npu::CompilerType& compilerType,+ const std::shared_ptr<intel_npu::IDevice>& device,+ std::string_view platform);++ static const std::vector<ov::intel_npu::CompilerType>& getKnownCompilerTypes();private:- inline static std::atomic<bool> _pluginCompilerIsPresent{true};+ 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,+ };++ inline static std::atomic<PluginCompilerPresence> _pluginCompilerPresence{PluginCompilerPresence::UNKNOWN};};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hppindex 53b0068c86f..ca7d6eef6e6 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp@@ -25,8 +25,6 @@ std::string getCompilationPlatform(const std::string_view platform,*/std::shared_ptr<IDevice> getDeviceById(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& deviceId);std::string getFullDeviceName(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);-std::string getDeviceArchitecture(const ov::SoPtr<IEngineBackend>& engineBackend,- const std::string& specifiedDeviceName);IDevice::Uuid getDeviceUuid(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);ov::device::LUID getDeviceLUID(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);uint32_t getSteppingNumber(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hppindex da70d6c1dbd..774fe390509 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp@@ -29,20 +29,6 @@ public:*/explicit FilteredConfig(const std::shared_ptr<const OptionsDesc>& desc) : Config(desc) {}- /**- * @brief Updates the configuration with new options if the key is enabled state- * @param options A map of key-value pairs representing the new configuration options.- */- void update(const ConfigMap& options) override;-- /**- * @brief Additional update method for properties that don't have their values convertible to string objects.- * @note In the future, code will be refactored to use only this update method to optimize redundant flow- * ov::Any-->std::string-->Opt::ValueType- * @param options A map of key-value pairs representing the new configuration options.- */- void updateAny(const ov::AnyMap& options) override;-/*** @brief Checks if a specific option exists in the configuration's descriptorDesc.* @param key The key of the option to check.@@ -50,13 +36,6 @@ public:*/bool hasOpt(std::string_view key) const;- /**- * @brief Checks if a specific option is public (publishable in supported_properties).- * @param key The key of the option to check.- * @return True if the option is public, false otherwise.- */- bool isOptPublic(std::string_view key) const;-/*** @brief Retrieves the OptionBase concept associated with a specific option. Used to check option details.* @param key The key of the option to retrieve.@@ -65,41 +44,25 @@ public:details::OptionConcept getOpt(std::string_view key) const;/**- * @brief Checks if a specific option is available (enabled and valid).- * @param key The key of the option to check.- * @return True if the option is available, false otherwise.- */- bool isAvailable(std::string key) const;-- /**- * @brief Enables or disables a specific configuration option.- * @param key The key of the option to enable/disable.- * @param enable True to enable the option, false to disable it.- */- void enable(std::string key, bool enable);-- /**- * @brief Enables all available configuration options.- */- void enableAll();-- /**- * @brief Enables only runtime configuration options.+ * @brief Adds or updates an internal configuration value for compiler-specific needs.+ * @param key The key of the internal configuration to add or update.+ * @param value The value to set for the internal configuration.*/- void enableRuntimeOptions();+ void addOrUpdateInternal(std::string key, std::string value);/**- * @brief Iterates over all enabled options and applies a callback function to each enabled key.- * @param cb A callback function that takes a string (key) as input and performs an operation on it.+ * @brief Checks if an internal compiler configuration exists.+ * @param key The key of the internal configuration to check.+ * @return True if the internal configuration exists, false otherwise.*/- void walkEnables(std::function<void(const std::string&)> cb) const;+ bool hasInternal(std::string_view key) const;/**- * @brief Adds or updates an internal configuration value for compiler-specific needs.- * @param key The key of the internal configuration to add or update.- * @param value The value to set for the internal configuration.+ * @brief Removes all compile-time and internal compiler configuration entries.+ * This is used when a compiler type is not explicitly selected and the config must be reset+ * to a runtime-only state.*/- void addOrUpdateInternal(std::string key, std::string value);+ void removeCompileTimeConfigs();/*** @brief Retrieves an internal configuration value by its key.@@ -108,12 +71,6 @@ public:*/std::string getInternal(std::string key) const;- /**- * @brief Generates a string representation of all internal configurations for compiler use.- * @return A string containing all internal configurations formatted for compiler use.- */- std::string toStringForCompilerInternal() const;-/*** @brief Iterates over all internal configurations and applies a callback function to each entry's key.* @param cb A callback function that takes a string (key) as input and performs an operation on it.@@ -121,15 +78,13 @@ public:void walkInternals(std::function<void(const std::string&)> cb) const;/**- * @brief Generates a string representation of all config keys with set values- * that are relevant for compilation (`OptionMode::Compile` or `OptionMode::Both`).- * @return A string containing filtered configuration keys formatted for compiler use.+ * @brief Generates a compiler configuration string for options supported by the current compiler.+ * @param isSupported Predicate used to filter compile-time and internal compiler options.+ * @return A string containing the supported configuration keys and values.*/- std::string toStringForCompiler() const;+ std::string toStringForCompiler(const std::function<bool(const std::string&)>& isSupported) const;private:- EnableMap _enabled; ///< Map to track whether specific configuration keys are enabled or disabled.-ConfigMap _internal_compiler_configs; ///< Map to store internal (hidden) configurations used for compiler.};diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiled_model.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiled_model.hppindex 81666f0d8af..8d313761924 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiled_model.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiled_model.hpp@@ -19,8 +19,6 @@ public:virtual const std::shared_ptr<IGraph>& get_graph() const = 0;- virtual const Config& get_config() const = 0;-protected:std::shared_ptr<const ICompiledModel> shared_from_this() const {return std::dynamic_pointer_cast<const ICompiledModel>(ov::ICompiledModel::shared_from_this());diff --git a/src/plugins/intel_npu/src/common/src/device_helpers.cpp b/src/plugins/intel_npu/src/common/src/device_helpers.cppindex 15afe0b13e3..594bc325a38 100644--- a/src/plugins/intel_npu/src/common/src/device_helpers.cpp+++ b/src/plugins/intel_npu/src/common/src/device_helpers.cpp@@ -82,16 +82,10 @@ std::string utils::getFullDeviceName(const ov::SoPtr<IEngineBackend>& engineBackOPENVINO_THROW("No device with name '", specifiedDeviceName, "' is available");}-std::string utils::getDeviceArchitecture(const ov::SoPtr<IEngineBackend>& engineBackend,- const std::string& specifiedDeviceName) {- const auto devName = getDeviceName(engineBackend, specifiedDeviceName);- return getPlatformByDeviceName(devName);-}-IDevice::Uuid utils::getDeviceUuid(const ov::SoPtr<IEngineBackend>& engineBackend,const std::string& specifiedDeviceName) {const auto devName = getDeviceName(engineBackend, specifiedDeviceName);- const auto deviceToUse = getDeviceById(engineBackend, devName);+ const auto& deviceToUse = getDeviceById(engineBackend, devName);if (deviceToUse) {return deviceToUse->getUuid();}diff --git a/src/plugins/intel_npu/src/common/src/filtered_config.cpp b/src/plugins/intel_npu/src/common/src/filtered_config.cppindex eafe2b4ecf7..f956cfe079c 100644--- a/src/plugins/intel_npu/src/common/src/filtered_config.cpp+++ b/src/plugins/intel_npu/src/common/src/filtered_config.cpp@@ -14,85 +14,6 @@ details::OptionConcept FilteredConfig::getOpt(std::string_view key) const {return _desc->get(key);}-bool FilteredConfig::isOptPublic(std::string_view key) const {- auto log = Logger::global().clone("Config");- if (_desc->has(key)) {- return _desc->get(key).isPublic();- } else {- log.warning("Option '%s' not registered in config", key.data());- return true;- }-}--void FilteredConfig::update(const ConfigMap& options) {- auto log = Logger::global().clone("Config");-- for (const auto& p : options) {- log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());-- if (isAvailable(p.first)) {- const auto opt = _desc->get(p.first);- _impl[opt.key().data()] = opt.validateAndParseFromString(p.second);- } else {- OPENVINO_THROW("[ NOT_FOUND ] Option '" + p.first + "' is not supported for current configuration");- }- }-}--void FilteredConfig::updateAny(const ov::AnyMap& options) {- auto log = Logger::global().clone("Config");-- for (const auto& p : options) {- log.trace("Update option '%s' to given 'ov::Any' value", p.first.c_str());-- if (isAvailable(p.first)) {- const auto opt = _desc->get(p.first);- _impl[opt.key().data()] = opt.validateAndParseFromAny(p.second);- } else {- OPENVINO_THROW("[ NOT_FOUND ] Option '" + p.first + "' is not supported for current configuration");- }- }-}--bool FilteredConfig::isAvailable(std::string key) const {- // NPUW properties are requested by OV Core during caching and have no effect on the NPU plugin. But we still need- // to enable those for OV Core to query.- if (key.find("NPUW") != key.npos) {- return true; // always available- }- auto it = _enabled.find(key);- if (it != _enabled.end() && hasOpt(key)) {- return it->second;- }- // if doesn't exist = not available- return false;-}--void FilteredConfig::enable(std::string key, bool enabled) {- // we insert for all cases - no need to check if exists- _enabled[key] = enabled;-}--void FilteredConfig::enableAll() {- _desc->walk([&](const details::OptionConcept& opt) {- enable(opt.key().data(), true);- });-}--void FilteredConfig::enableRuntimeOptions() {- _desc->walk([&](const details::OptionConcept& opt) {- if (opt.mode() == OptionMode::RunTime) {- enable(opt.key().data(), true);- }- });-}--void FilteredConfig::walkEnables(std::function<void(const std::string&)> cb) const {- for (const auto& itr : _enabled) {- cb(itr.first);- }-}-void FilteredConfig::walkInternals(std::function<void(const std::string&)> cb) const {for (const auto& itr : _internal_compiler_configs) {cb(itr.first);@@ -107,8 +28,24 @@ void FilteredConfig::addOrUpdateInternal(std::string key, std::string value) {} else {// manual insertlog.trace("Store internal compiler option %s: %s", key.c_str(), value.c_str());- _internal_compiler_configs.insert(std::make_pair(key, value)); // insert new+ _internal_compiler_configs.emplace(key, std::move(value));+ }+}++bool FilteredConfig::hasInternal(std::string_view key) const {+ return _internal_compiler_configs.count(std::string(key)) != 0;+}++void FilteredConfig::removeCompileTimeConfigs() {+ for (auto it = _impl.begin(); it != _impl.end();) {+ if (_desc->get(it->first).mode() == OptionMode::CompileTime) {+ it = _impl.erase(it);+ } else {+ ++it;+ }}++ _internal_compiler_configs.clear();}std::string FilteredConfig::getInternal(std::string key) const {@@ -118,32 +55,49 @@ std::string FilteredConfig::getInternal(std::string key) const {return _internal_compiler_configs.at(key);}-std::string FilteredConfig::toStringForCompilerInternal() const {+std::string FilteredConfig::toStringForCompiler(const std::function<bool(const std::string&)>& isSupported) const {+ if (!isSupported) {+ OPENVINO_THROW("FilteredConfig::toStringForCompiler requires a valid support predicate");+ }+std::stringstream resultStream;+ bool hasSerializedValue = false;- for (auto it = _internal_compiler_configs.cbegin(); it != _internal_compiler_configs.cend(); ++it) {- resultStream << " " << it->first << "=\"" << it->second << "\"";- }+ const auto append = [&](const std::string& key, const std::string& serializedValue) {+ if (hasSerializedValue) {+ resultStream << " ";+ }+ resultStream << key << "=\"" << serializedValue << "\"";+ hasSerializedValue = true;+ };++ for (const auto& [key, value] : _impl) {+ if (!_desc->has(key)) {+ OPENVINO_THROW("[ NOT_FOUND ] Option '" + std::string(key) ++ "' is not supported for current configuration");+ }- return resultStream.str();-}+ const auto mode = _desc->get(key).mode();+ if (mode != OptionMode::CompileTime && mode != OptionMode::Both) {+ continue;+ }+ if (mode == OptionMode::CompileTime && !isSupported(std::string(key))) {+ OPENVINO_THROW("[ NOT_FOUND ] Option '" + std::string(key) ++ "' is not supported for current configuration");+ }+ if (mode == OptionMode::Both && !isSupported(std::string(key))) {+ continue;+ }-std::string FilteredConfig::toStringForCompiler() const {- std::stringstream resultStream;- for (auto it = _impl.cbegin(); it != _impl.cend(); ++it) {- const auto& key = it->first;-- // Only include available configs which options have OptionMode::Compile or OptionMode::Both- if (isAvailable(key.data())) {- if (_desc->has(key)) {- if (_desc->get(key).mode() != OptionMode::RunTime) {- resultStream << key << "=\"" << it->second->toString() << "\"";- if (std::next(it) != _impl.end()) {- resultStream << " ";- }- }- }+ append(std::string(key), value->toString());+ }++ for (const auto& [key, value] : _internal_compiler_configs) {+ if (!isSupported(std::string(key))) {+ OPENVINO_THROW("[ NOT_FOUND ] Option '" + std::string(key) ++ "' is not supported for current configuration");}+ append(std::string(key), value);}return resultStream.str();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.cppindex 68feca6bc83..67e5d886548 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@@ -25,41 +25,25 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(ov::intel_npu::CompilerType& compilerType,std::string_view platform,const std::shared_ptr<OptionSupportCache>& optionSupportCache) const {- const auto device = engineBackend != nullptr ? engineBackend->getDevice() : nullptr;+ const auto device = engineBackend ? engineBackend->getDevice() : nullptr;if (compilerType == ov::intel_npu::CompilerType::PREFER_PLUGIN) {- if (device != nullptr) {- compilerType = determineAppropriateCompilerTypeBasedOnPlatform(platform);- if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {- if (_pluginCompilerIsPresent) {- try {- return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs(),- optionSupportCache,- device->getDeviceProperties());- } catch (...) {- _pluginCompilerIsPresent = false;- compilerType = ov::intel_npu::CompilerType::DRIVER;- }- } else {- // plugin compiler isn't present, fallback to driver compiler- compilerType = ov::intel_npu::CompilerType::DRIVER;- }- }- } else {- // device isn't available, offline compilation only- compilerType = ov::intel_npu::CompilerType::PLUGIN;+ auto [pluginCompiler, resolvedCompilerType] =+ resolvePreferPluginCompiler(engineBackend, optionSupportCache, device, platform);+ compilerType = resolvedCompilerType;+ if (pluginCompiler) {+ return std::move(pluginCompiler);}}if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {- if (device == nullptr) {- return std::make_unique<PluginCompilerAdapter>(nullptr, optionSupportCache);- }+ return std::make_unique<PluginCompilerAdapter>(+ engineBackend ? engineBackend->getInitStructs() : nullptr,+ optionSupportCache,+ device ? std::optional<IDevice::DeviceProperties>{device->getDeviceProperties()} : std::nullopt);+ }- return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs(),- optionSupportCache,- device->getDeviceProperties());- } else if (compilerType == ov::intel_npu::CompilerType::DRIVER) {+ if (compilerType == ov::intel_npu::CompilerType::DRIVER) {if (device == nullptr) {OPENVINO_THROW("Could not find an NPU device. The driver compiler requires a valid device to be present in ""the system.");@@ -73,16 +57,68 @@ std::unique_ptr<ICompilerAdapter> CompilerAdapterFactory::getCompiler(}return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs(), optionSupportCache);- } else {- OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");}++ OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");+}++void CompilerAdapterFactory::decideCompilerType(ov::intel_npu::CompilerType& compilerType,+ const std::shared_ptr<intel_npu::IDevice>& device,+ std::string_view platform) {+ if (compilerType != ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ return;+ }++ compilerType = resolvePreferPluginCompiler({}, nullptr, device, platform).second;+}++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 {+ if (!device) {+ return {nullptr, ov::intel_npu::CompilerType::PLUGIN};+ }++ if (determineAppropriateCompilerTypeBasedOnPlatform(platform) == ov::intel_npu::CompilerType::DRIVER) {+ return {nullptr, ov::intel_npu::CompilerType::DRIVER};+ }++ const auto pluginCompilerPresence = _pluginCompilerPresence.load(std::memory_order_acquire);+ if (pluginCompilerPresence == PluginCompilerPresence::ABSENT) {+ return {nullptr, ov::intel_npu::CompilerType::DRIVER};+ }++ if (pluginCompilerPresence == PluginCompilerPresence::PRESENT) {+ // Compiler is present, return compiler type as PLUGIN. The actual compiler will be created in getCompiler()+ // method.+ return {nullptr, ov::intel_npu::CompilerType::PLUGIN};+ }++ if (pluginCompilerPresence == PluginCompilerPresence::UNKNOWN) {+ try {+ auto pluginCompiler = std::make_unique<PluginCompilerAdapter>(+ engineBackend ? engineBackend->getInitStructs() : nullptr,+ optionSupportCache,+ device ? std::optional<IDevice::DeviceProperties>{device->getDeviceProperties()} : std::nullopt);+ _pluginCompilerPresence.store(PluginCompilerPresence::PRESENT, std::memory_order_release);+ return {std::move(pluginCompiler), ov::intel_npu::CompilerType::PLUGIN};+ } catch (...) {+ _pluginCompilerPresence.store(PluginCompilerPresence::ABSENT, std::memory_order_release);+ return {nullptr, ov::intel_npu::CompilerType::DRIVER};+ }+ }++ // 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::getSupportedCompilerTypes() {- static const std::vector<ov::intel_npu::CompilerType> supportedCompilerTypes = {- ov::intel_npu::CompilerType::DRIVER,- ov::intel_npu::CompilerType::PLUGIN};- return supportedCompilerTypes;+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;}} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cppindex e50afb0c5a1..a784b507b9b 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp@@ -278,9 +278,9 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(false,storeWeightlessCacheAttributeFlag);FilteredConfig updatedConfig = config;- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}std::string buildFlags;@@ -402,9 +402,9 @@ std::pair<std::vector<ov::Tensor>, std::optional<std::string>> VCLCompilerImpl::false,true);FilteredConfig updatedConfig = config;- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}std::string buildFlags;@@ -488,7 +488,7 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compileWsItersize_t callNumber) const {_logger.debug("compileWsIterative start");FilteredConfig updatedConfig = config;- updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber)}});+ updatedConfig.update(ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber));// Return the compatibility descriptor together with the compiled blob.return compile(model, updatedConfig, true);}@@ -566,9 +566,9 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::ModelmaxOpsetVersion,config.get<MODEL_SERIALIZER_VERSION>(),isOptionValueSupportedByCompiler);- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}std::string buildFlags;@@ -630,9 +630,6 @@ bool VCLCompilerImpl::is_option_supported(const std::string& option, const std::try {const char* optname_ch = option.c_str();const char* optvalue_ch = optValue.has_value() ? optValue.value().c_str() : nullptr;- _logger.debug("is_option_supported start for option: %s, value: %s",- optname_ch,- optvalue_ch ? optvalue_ch : "null");THROW_ON_FAIL_FOR_VCL("vclGetCompilerIsOptionSupported",vclGetCompilerIsOptionSupported(_compilerHandle, optname_ch, optvalue_ch),_logHandle);@@ -641,7 +638,6 @@ bool VCLCompilerImpl::is_option_supported(const std::string& option, const std::// The API is only supported in new version, just add log here_logger.debug("Exception in is_option_supported: %s", e.what());}- _logger.debug("option: %s is not supported", option.c_str());return false;}diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cppindex 311736dd12d..61fca88f9ba 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp@@ -108,9 +108,9 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<conisOptionValueSupportedByCompiler,_zeGraphExt->isPluginModelHashSupported());FilteredConfig updatedConfig = config;- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}std::string buildFlags;@@ -182,9 +182,9 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod_zeGraphExt->isPluginModelHashSupported(),true);FilteredConfig updatedConfig = config;- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}std::string buildFlags;@@ -212,7 +212,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Modwhile (true) {_logger.debug("compileWS iteration %d", callNumber);- updatedConfig.update({{ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber++)}});+ updatedConfig.update(ov::intel_npu::ws_compile_call_number.name(), std::to_string(callNumber++));_logger.debug("build flags");buildFlags = serializedIOInfo;@@ -284,9 +284,9 @@ ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov:isOptionValueSupportedByCompiler);FilteredConfig updatedConfig = config;- if (config.isAvailable(ov::intel_npu::model_serializer_version.name())) {- updatedConfig.update({{ov::intel_npu::model_serializer_version.name(),- MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion)}});+ if (is_option_supported(ov::intel_npu::model_serializer_version.name())) {+ updatedConfig.update(ov::intel_npu::model_serializer_version.name(),+ MODEL_SERIALIZER_VERSION::toString(serializedIR.serializerVersion));}const auto isOptionSupportedByCompiler = [this](const std::string& optionName) {return is_option_supported(optionName);@@ -325,7 +325,6 @@ std::vector<std::string> DriverCompilerAdapter::get_supported_options() const {if (compilerOptionsStr.has_value()) {if (compilerOptionsStr->empty()) {- _logger.info("get_supported_options returned no options; returning an empty supported options vector.");return {};}@@ -366,6 +365,9 @@ bool DriverCompilerAdapter::is_option_supported(const std::string& optName,if (optionSupportCache) {const auto cachedSupport = _optionSupportCache->isOptionSupported(driverOptionSupportKey, optName);if (cachedSupport.has_value()) {+ _logger.debug("Option %s %s by DriverCompilerAdapter",+ optName.c_str(),+ cachedSupport.value() ? "is supported" : "is not supported");return cachedSupport.value();}}@@ -377,6 +379,10 @@ bool DriverCompilerAdapter::is_option_supported(const std::string& optName,_optionSupportCache->addSupportedOption(driverOptionSupportKey, optName, supported);}+ _logger.debug("Option %s with value '%s' %s by DriverCompilerAdapter",+ optName.c_str(),+ optValue.has_value() ? optValue->c_str() : "null",+ supported ? "is supported" : "is not supported");return supported;}@@ -388,6 +394,9 @@ bool DriverCompilerAdapter::is_option_supported(const std::string& optName,if (_optionSupportCache) {_optionSupportCache->addSupportedOption(driverOptionSupportKey, optName, supported);}+ _logger.debug("Option %s %s by DriverCompilerAdapter",+ optName.c_str(),+ supported ? "is supported" : "is not supported");return supported;}}diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cppindex 288b53c99bf..f4e3a1a25ba 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp@@ -716,14 +716,13 @@ std::string serializeConfig(const FilteredConfig& originalConfig,std::ostringstream levelStr;levelStr << originalConfig.get<COMPILE_LOG_LEVEL>();configWithCompileLogLevel = originalConfig;- configWithCompileLogLevel->update({{ov::log::level.name(), levelStr.str()}});+ configWithCompileLogLevel->update(ov::log::level.name(), levelStr.str());}const FilteredConfig& config = configWithCompileLogLevel.has_value() ? *configWithCompileLogLevel : originalConfig;std::string content = {};- content += config.toStringForCompiler();- content += config.toStringForCompilerInternal();+ content += config.toStringForCompiler(isOptionSupportedByCompiler);logger.debug("Original content of config: %s", content.c_str());@@ -796,35 +795,6 @@ std::string serializeConfig(const FilteredConfig& originalConfig,getStringReplacement(ov::intel_npu::LegacyPriority::HIGH));}- // Special cases- const auto& removeOptionIfUnsupported = [&](const std::string& optionName) {- if (std::regex_search(content, std::regex(optionName))) {- const bool optionSupported =- isOptionSupportedByCompiler != nullptr ? isOptionSupportedByCompiler(optionName) : false;- if (!optionSupported) {- std::ostringstream optionStr;- optionStr << optionName << KEY_VALUE_SEPARATOR << VALUE_DELIMITER << "\\S+" << VALUE_DELIMITER;- logger.info("%s property is not supported by this compiler. Removing from parameters",- optionName.c_str());- content = std::regex_replace(content, std::regex(optionStr.str()), "");- }- }- };-- // Options with OptionMode::Both may be used by the plugin even when the compiler does not support them.- // Remove them from the config string before sending it to the compiler if they are unsupported.-- // NPU_TURBO is a special option in the sense that by default it is a- // driver-setting, but certain compilers support and make use of it too If we have turbo in the config string, we- // check if compiler supports it. If it doesn't support it, we remove it- removeOptionIfUnsupported(ov::intel_npu::turbo.name());- // LOG_LEVEL must not be sent to the compiler if not supported- removeOptionIfUnsupported(ov::log::level.name());- // PERFORMANCE_HINT must not be sent to the compiler if not supported- removeOptionIfUnsupported(ov::hint::performance_mode.name());- // PERF_COUNT must not be sent to the compiler if not supported- removeOptionIfUnsupported(ov::enable_profiling.name());-// FINAL step to convert prefixes of remaining params, to ensure backwards compatibility// From 5.0.0, driver compiler start to use NPU_ prefix, the old version uses VPU_ prefixif (compilerVersion.major < 5) {diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cppindex b95f419bbc5..0b02b7f44a8 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp@@ -129,7 +129,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::ModFilteredConfig localConfig = config;if (!localConfig.has<SEPARATE_WEIGHTS_VERSION>()) {- localConfig.update({{ov::intel_npu::separate_weights_version.name(), "ONE_SHOT"}});+ localConfig.update(ov::intel_npu::separate_weights_version.name(), "ONE_SHOT");}_logger.info("SEPARATE_WEIGHTS_VERSION: %s",@@ -294,7 +294,6 @@ std::vector<std::string> PluginCompilerAdapter::get_supported_options() const {--optionsSize;}if (optionsSize == 0) {- _logger.info("get_supported_options returned no options; returning an empty supported options vector.");return {};}@@ -320,6 +319,9 @@ bool PluginCompilerAdapter::is_option_supported(const std::string& optname,if (optionSupportCache) {const auto cachedSupport = _optionSupportCache->isOptionSupported(pluginOptionSupportKey, optname);if (cachedSupport.has_value()) {+ _logger.debug("Option %s %s by PluginCompilerAdapter",+ optname.c_str(),+ cachedSupport.value() ? "is supported" : "is not supported");return cachedSupport.value();}}@@ -329,11 +331,10 @@ bool PluginCompilerAdapter::is_option_supported(const std::string& optname,_optionSupportCache->addSupportedOption(pluginOptionSupportKey, optname, supported);}- const char* valueForLog = optValue.has_value() ? optValue->c_str() : "null";- _logger.debug("Option %s %s `%s` by VCLCompilerImpl",+ _logger.debug("Option %s with value '%s' %s by PluginCompilerAdapter",optname.c_str(),- supported ? "is supported" : "is not supported",- valueForLog);+ optValue.has_value() ? optValue->c_str() : "null",+ supported ? "is supported" : "is not supported");return supported;}diff --git a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp b/src/plugins/intel_npu/src/plugin/include/compiled_model.hppindex 0d9348fff16..fa324d8f125 100644--- a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp+++ b/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp@@ -11,6 +11,7 @@#include "intel_npu/common/icompiled_model.hpp"#include "intel_npu/common/npu.hpp"#include "intel_npu/utils/logger/logger.hpp"+#include "openvino/runtime/properties.hpp"#include "openvino/runtime/so_ptr.hpp"namespace intel_npu {@@ -34,6 +35,7 @@ public:const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,const FilteredConfig& config,+ const ov::AnyMap& properties,const std::optional<int64_t>& batchSize);CompiledModel(const CompiledModel&) = delete;@@ -56,26 +58,22 @@ public:const std::shared_ptr<IGraph>& get_graph() const override;- const FilteredConfig& get_config() const override;-void release_memory() override;private:// For special config, stream executors must be set accordingly to ensure correct behavior.- void configure_stream_executors();+ void configure_stream_executors(ov::streams::Num numStreams, bool runInferencesSequentially);Logger _logger;const std::shared_ptr<IDevice> _device;+ std::shared_ptr<IGraph> _graph;+ std::optional<int64_t> _batchSize;std::unique_ptr<CompiledModelPropertyManager> _propertiesManager;- std::shared_ptr<IGraph> _graph;-std::shared_ptr<ov::threading::ITaskExecutor> _resultExecutor = nullptr;mutable std::once_flag _streamExecutorsInitFlag;-- std::optional<int64_t> _batchSize;};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/include/compiled_model_property_manager.hpp b/src/plugins/intel_npu/src/plugin/include/compiled_model_property_manager.hppindex 34b95226c64..9a622bcbcfa 100644--- a/src/plugins/intel_npu/src/plugin/include/compiled_model_property_manager.hpp+++ b/src/plugins/intel_npu/src/plugin/include/compiled_model_property_manager.hpp@@ -4,7 +4,7 @@#pragma once-#include <map>+#include <cstdint>#include <memory>#include <mutex>#include <optional>@@ -13,14 +13,18 @@#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/igraph.hpp"+#include "intel_npu/common/npu.hpp"#include "intel_npu/utils/logger/logger.hpp"+#include "openvino/runtime/properties.hpp"#include "property_registration.hpp"namespace intel_npu {-class CompiledModelPropertyManager final {+class CompiledModelPropertyManager final : private PropertyRegistrationBase {public:CompiledModelPropertyManager(const FilteredConfig& config,+ const ov::AnyMap& properties,+ const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,const std::optional<int64_t>& batchSize,Logger& logger);@@ -28,22 +32,18 @@ public:void setProperty(const ov::AnyMap& properties);ov::Any getProperty(const std::string& name) const;- const FilteredConfig& getConfig() const {- return _config;- }+ FilteredConfig getConfig() const;private:void registerProperties();FilteredConfig _config;+ const std::shared_ptr<IDevice> _device;std::shared_ptr<IGraph> _graph;std::optional<int64_t> _batchSize;Logger& _logger;- std::map<std::string, PropertyDescriptor> _properties;- std::vector<ov::PropertyName> _supportedProperties;-mutable std::mutex _mutex;};diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hppindex 5766d12eedd..723313b2409 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp@@ -11,6 +11,7 @@#include "backends_registry.hpp"#include "blob_source.hpp"#include "compiler_option_support_helper.hpp"+#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/npu.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/runtime/iplugin.hpp"@@ -63,13 +64,7 @@ public:const ov::AnyMap& properties) const override;private:- void update_log_level(const ov::AnyMap& properties) const;-- /**- * @brief Looks for "DISABLE_VERSION_CHECK" and "IMPORT_RAW_BLOB" to determine whether or not the blob to be- * imported should be treated as a "raw" one (i.e. the whole blob is a compiler main schedule).- */- bool should_import_raw_blob(const ov::AnyMap& properties) const;+ void update_global_properties(const ov::AnyMap& properties) const;std::shared_ptr<ov::ICompiledModel> import_model(BlobSource& blobSource, ov::AnyMap& properties) const;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.hppindex 9f2e7e00d3d..29035972eb7 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@@ -4,10 +4,12 @@#pragma once-#include <map>#include <memory>#include <mutex>+#include <optional>#include <string>+#include <tuple>+#include <utility>#include <vector>#include "compiler_option_support_helper.hpp"@@ -20,9 +22,11 @@namespace intel_npu {-class PluginPropertyManager final {+enum class ConfigMergeMode { Compile, Import, Query };++class PluginPropertyManager final : private PropertyRegistrationBase {public:- PluginPropertyManager(const FilteredConfig& config,+ PluginPropertyManager(const std::shared_ptr<OptionsDesc>& options,const ov::SoPtr<IEngineBackend>& backend,const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,Logger& logger);@@ -33,53 +37,27 @@ public:ov::Any getProperty(const std::string& name, const ov::AnyMap& arguments = {}) const;bool isPropertySupported(const std::string& name, const ov::AnyMap& arguments = {}) const;- const FilteredConfig& getConfig() const {- return _config;- }-- FilteredConfig getConfigWithCompilerPropertiesDisabled(const ov::AnyMap& properties) const;- FilteredConfig getConfigForSpecificCompiler(const ov::AnyMap& properties) const;+ std::pair<FilteredConfig, ov::AnyMap> getMergedConfigAndUnknownProperties(const ov::AnyMap& properties,+ ConfigMergeMode mergeMode);std::string determinePlatform(const ov::AnyMap& properties) const;std::string determineDeviceId(const ov::AnyMap& properties) const;ov::intel_npu::CompilerType determineCompilerType(const ov::AnyMap& properties) const;private:- PluginPropertyManager(const PluginPropertyManager& other);- struct CopyState {- FilteredConfig config;- ov::SoPtr<IEngineBackend> backend;- std::shared_ptr<CompilerOptionSupportHelper> optionSupportHelper;- Logger& logger;- ov::intel_npu::CompilerType currentlyUsedCompiler;- ov::intel_npu::CompilerType _compilerForCompatibilityCheck;- bool compatibilityCheckSupported;- std::string currentlyUsedPlatform;- bool compilerConfigsFilteredByCompiler;- bool compatibilityCheckFiltered;- };-- explicit PluginPropertyManager(CopyState&& state);-- void registerProperties() const;- void initializeCompatibilityCheckSupportIfNeeded() const;- bool isPropertyRegistered(const std::string& propertyName) const;-- mutable FilteredConfig _config;+ void registerProperties();+ std::optional<ov::intel_npu::CompilerType> resolveCompilerType(ov::intel_npu::CompilerType compilerType,+ const std::string& deviceId,+ const std::string& platform) const;+ void warnCompilerOnlyOptionSkipped(const std::string& key) const;++ FilteredConfig _config;ov::SoPtr<IEngineBackend> _backend;std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;Logger& _logger;- mutable ov::intel_npu::CompilerType _currentlyUsedCompiler = ov::intel_npu::CompilerType::PREFER_PLUGIN;- mutable ov::intel_npu::CompilerType _compilerForCompatibilityCheck = ov::intel_npu::CompilerType::DRIVER;- mutable bool _compatibilityCheckSupported = false;- mutable std::string _currentlyUsedPlatform;- mutable bool _compilerConfigsFilteredByCompiler = false;- mutable bool _compatibilityCheckFiltered = false;-- mutable std::map<std::string, PropertyDescriptor> _properties;- mutable std::vector<ov::PropertyName> _supportedProperties;+ mutable std::mutex _mutex;const std::vector<ov::PropertyName> _cachingProperties = [] {std::vector<ov::PropertyName> properties = {@@ -112,12 +90,6 @@ private:});return properties;}();-- const std::vector<ov::PropertyName> _internalSupportedProperties = {ov::internal::caching_properties.name(),- ov::internal::caching_with_mmap.name(),- ov::internal::cache_header_alignment.name()};-- mutable std::mutex _mutex;};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/include/property_registration.hpp b/src/plugins/intel_npu/src/plugin/include/property_registration.hppindex 670ee5c6e2e..1a97ec223bf 100644--- a/src/plugins/intel_npu/src/plugin/include/property_registration.hpp+++ b/src/plugins/intel_npu/src/plugin/include/property_registration.hpp@@ -7,238 +7,43 @@#include <functional>#include <map>#include <string>-#include <type_traits>#include <utility>+#include "openvino/core/except.hpp"#include "openvino/runtime/properties.hpp"namespace intel_npu {-class Config;-struct PropertyDescriptor final {bool isPublic;ov::PropertyMutability mutability;- std::function<ov::Any(const Config&)> get;- std::function<ov::Any(const Config&, const ov::AnyMap&)> getWithArgs;+ std::function<bool(const ov::AnyMap&)> isSupported;+ std::function<ov::Any(const ov::AnyMap&)> get;+ std::function<void(const ov::Any&)> set;};-using PropertyMap = std::map<std::string, PropertyDescriptor>;--/**- * @brief Register a simple property backed directly by a config option.- *- * Use this when the property name maps to an option stored in the provided config and- * the getter is just config.get<OPT_TYPE>().- */-template <typename OptionType, typename ConfigLike>-inline void try_register_property_based_on_config(const ConfigLike& config,- PropertyMap& properties,- const std::string& propertyName) {- if (!config.isAvailable(propertyName)) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{option.isPublic(),- option.mutability(),- std::function<ov::Any(const Config&)>([](const Config& configValue) {- return configValue.get<OptionType>();- }),- {}});-}--/**- * @brief Register a config-backed property with explicit public/private visibility.- *- * Use this when the callback is the standard config.get<OPT_TYPE>() but the visibility (public/private)- * must be determined at runtime rather than taken from the option descriptor.- */-template <typename OptionType, typename ConfigLike>-inline void try_register_property_based_on_config_with_visibility(const ConfigLike& config,- PropertyMap& properties,- const std::string& propertyName,- bool isPublic) {- if (!config.isAvailable(propertyName)) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{isPublic,- option.mutability(),- std::function<ov::Any(const Config&)>([](const Config& configValue) {- return configValue.get<OptionType>();- }),- {}});-}--/**- * @brief Register a custom property only when the property is available in the provided config.- *- * Use this when a custom function/implementation is required. Visibility and mutability are taken from the option- * descriptor.- */-template <typename ConfigLike, typename Getter>-inline void try_register_property_based_on_config_with_custom_function(const ConfigLike& config,- PropertyMap& properties,- const std::string& propertyName,- Getter&& getter) {- if (!config.isAvailable(propertyName)) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{option.isPublic(),- option.mutability(),- std::function<ov::Any(const Config&)>(std::forward<Getter>(getter)),- {}});-}--/**- * @brief Register a compiled-model property backed directly by the current config.- */-template <typename OptionType, typename ConfigLike>-inline void try_register_property_based_on_config_as_read_only(const ConfigLike& config,- PropertyMap& properties,- const std::string& propertyName) {- if (!config.isAvailable(propertyName)) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{option.isPublic(),- ov::PropertyMutability::RO,- std::function<ov::Any(const Config&)>([](const Config& configValue) {- return configValue.get<OptionType>();- }),- {}});-}--/**- * @brief Register a compiled-model property only if it was explicitly set before compilation.- *- * Default option values are not materialized into the config, so this form advertises a property only when- * the user or upper layer actually set it.- */-template <typename OptionType, typename ConfigLike>-inline void try_register_property_based_on_config_if_set_as_read_only(const ConfigLike& config,- PropertyMap& properties,- const std::string& propertyName) {- if (!(config.has(propertyName) && config.isAvailable(propertyName))) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{option.isPublic(),- ov::PropertyMutability::RO,- std::function<ov::Any(const Config&)>([](const Config& configValue) {- return configValue.get<OptionType>();- }),- {}});-}--/**- * @brief Register a simple exposed NPUW option property.- *- * Equivalent to try_register_property_based_on_config, but uses OPT_TYPE::key() for the property name.- */-template <typename OptionType, typename ConfigLike>-inline void try_register_npuw_option_property(const ConfigLike& config, PropertyMap& properties) {- const auto propertyName = std::string(OptionType::key());- if (!config.isAvailable(propertyName)) {- return;- }-- const auto& option = config.getOpt(propertyName);- properties.emplace(propertyName,- PropertyDescriptor{option.isPublic(),- option.mutability(),- std::function<ov::Any(const Config&)>([](const Config& configValue) {- return configValue.get<OptionType>();- }),- {}});-}--template <typename GetterOrValue>-inline auto make_metric_getter(GetterOrValue&& getterOrValue) {- using GetterOrValueType = std::decay_t<GetterOrValue>;-- if constexpr (std::is_invocable_v<GetterOrValueType, const Config&>) {- return std::forward<GetterOrValue>(getterOrValue);- } else {- return [value = std::forward<GetterOrValue>(getterOrValue)](const Config&) {- return value;- };- }-}--/**- * @brief Register a simple metric property.- *- * Metrics are read-only properties. Accepts either a plain value or a getter lambda `(const Config&) -> T`.- * Use this as the default form for metric registration.- */-template <typename GetterOrValue>-inline void register_property_with_custom_function(PropertyMap& properties,- const std::string& propertyName,- bool isPublic,- GetterOrValue&& getterOrValue) {- properties.emplace(propertyName,- PropertyDescriptor{isPublic,- ov::PropertyMutability::RO,- std::function<ov::Any(const Config&)>(- make_metric_getter(std::forward<GetterOrValue>(getterOrValue))),- {}});-}--/**- * @brief Conditionally register a metric property with a standard (Config-only) custom function.- *- * Registers the property only when @p shouldRegister is true.- * Use this when a metric property must be conditionally exposed based on device/backend capabilities.- */-template <typename Getter>-inline void try_register_property_with_custom_function(PropertyMap& properties,- const std::string& propertyName,- bool shouldRegister,- bool isPublic,- Getter&& getter) {- if (!shouldRegister) {- return;- }- properties.emplace(propertyName,- PropertyDescriptor{isPublic,- ov::PropertyMutability::RO,- std::function<ov::Any(const Config&)>(std::forward<Getter>(getter)),- {}});-}--/**- * @brief Conditionally register a metric property whose custom function requires additional AnyMap arguments.- *- * Registers the property only when @p shouldRegister is true.- * Use this for properties that accept extra arguments at get_property call time (e.g. compatibility_check).- */-template <typename Getter>-inline void try_register_property_with_custom_function_and_args(PropertyMap& properties,- const std::string& propertyName,- bool shouldRegister,- bool isPublic,- Getter&& getter) {- if (!shouldRegister) {- return;- }- properties.emplace(- propertyName,- PropertyDescriptor{isPublic,- ov::PropertyMutability::RO,- {},- std::function<ov::Any(const Config&, const ov::AnyMap&)>(std::forward<Getter>(getter))});-}+class PropertyRegistrationBase {+protected:+ /**+ * @brief Register a property with explicit support, getter, and setter callbacks.+ *+ * Registers the descriptor unconditionally. The property is exposed only when `isSupported` returns true. The+ * getter receives query-time arguments, and the setter receives the value supplied by the caller. Callers can use+ * these callbacks for config-backed properties or custom property implementations.+ */+ void register_property(std::string propertyName,+ bool isPublic,+ ov::PropertyMutability mutability,+ std::function<bool(const ov::AnyMap&)> isSupported,+ std::function<ov::Any(const ov::AnyMap&)> getter,+ std::function<void(const ov::Any&)> setter) {+ const auto [it, inserted] = _properties.emplace(+ propertyName,+ PropertyDescriptor{isPublic, mutability, std::move(isSupported), std::move(getter), std::move(setter)});+ OPENVINO_ASSERT(inserted, "Property '", propertyName, "' is already registered");+ }++ std::map<std::string, PropertyDescriptor> _properties;+};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/include/transformations.hpp b/src/plugins/intel_npu/src/plugin/include/transformations.hppindex 4d4b8d05c90..893268f6ebf 100644--- a/src/plugins/intel_npu/src/plugin/include/transformations.hpp+++ b/src/plugins/intel_npu/src/plugin/include/transformations.hpp@@ -57,14 +57,14 @@ bool deBatchModel(std::shared_ptr<ov::Model>& model,/*** @brief Handles plugin-side batching logic including validation and model reshaping* @param model The model to process- * @param localConfig Configuration+ * @param batchMode Resolved batch mode, if supported by the active compiler* @param originalBatch Output parameter to store original batch dimension* @param logger Logger instance for diagnostic messages*/std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(std::shared_ptr<const ov::Model> model,- FilteredConfig& localConfig,const std::function<void(ov::intel_npu::BatchMode)>& updateBatchMode,+ std::optional<ov::intel_npu::BatchMode> batchMode,std::optional<ov::Dimension>& originalBatch,Logger logger);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.cppindex 125ec429668..650dfaa3cc9 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@@ -58,7 +58,7 @@ void update_compiler_type_if_perf_count(FilteredConfig& config,CompilerAdapterFactory factory;(void)factory.getCompiler(backend, compilerType, device_name);- config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compilerType)}});+ config.update(ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compilerType));}}@@ -384,7 +384,7 @@ private:void register_compiler_version() {std::optional<uint32_t> compiler_version = m_metadata->get_compiler_version();if (compiler_version.has_value()) {- m_config.update({{ov::intel_npu::compiler_version.name(), std::to_string(compiler_version.value())}});+ m_config.update(ov::intel_npu::compiler_version.name(), std::to_string(compiler_version.value()));m_logger.debug("Imported model was compiled with compiler version: %u.%u",ONEAPI_VERSION_MAJOR(compiler_version.value()),ONEAPI_VERSION_MINOR(compiler_version.value()));diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cppindex 7d47f7439f5..78916c5c1a7 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp@@ -18,7 +18,6 @@#include "intel_npu/utils/utils.hpp"#include "metadata.hpp"#include "openvino/pass/constant_folding.hpp"-#include "openvino/runtime/properties.hpp"#include "transformations/utils/utils.hpp"namespace intel_npu {@@ -28,58 +27,51 @@ CompiledModel::CompiledModel(const std::shared_ptr<const ov::Model>& model,const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,const FilteredConfig& config,+ const ov::AnyMap& properties,const std::optional<int64_t>& batchSize): ICompiledModel(model, plugin, nullptr, nullptr),_logger("CompiledModel", config.get<LOG_LEVEL>()),_device(device),_graph(graph),- _batchSize(batchSize) {+ _batchSize(batchSize),+ _propertiesManager(+ std::make_unique<CompiledModelPropertyManager>(config, properties, _device, _graph, _batchSize, _logger)) {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "CompiledModel::CompiledModel");- // Support for specific properties might depend on the characteristics of the compiled model.- // Adjust lower level config availability to influence the supported properties list if needed- FilteredConfig localConfig = config;-- OV_ITT_TASK_CHAIN(COMPILED_MODEL, itt::domains::NPUPlugin, "CompiledModel::CompiledModel", "initialize_properties");- _propertiesManager = std::make_unique<CompiledModelPropertyManager>(localConfig, _graph, _batchSize, _logger);-OPENVINO_ASSERT(_graph != nullptr, "Invalid graph handle! Failed to initialize compiled model!");_logger.info("The current compiled model is a %s one", to_string(_graph->get_kind()));// Immediate-init path: when weights load is not deferred, initialize the graph now.// The deferred path (CREATE_EXECUTOR off or DEFER_WEIGHTS_LOAD on) is handled in create_infer_request().- const FilteredConfig& modelConfig = _propertiesManager->getConfig();- if (modelConfig.get<CREATE_EXECUTOR>() && !modelConfig.get<DEFER_WEIGHTS_LOAD>()) {- _graph->initialize(modelConfig);+ if (config.get<CREATE_EXECUTOR>() && !config.get<DEFER_WEIGHTS_LOAD>()) {+ _graph->initialize(config);} else {_logger.info("Graph initialize is deferred; weights will be loaded on the first infer request creation.");}-- OV_ITT_TASK_SKIP(COMPILED_MODEL);}std::shared_ptr<ov::IAsyncInferRequest> CompiledModel::create_infer_request() const {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "CompiledModel::create_infer_request");- std::call_once(_streamExecutorsInitFlag, [this] {- const_cast<CompiledModel*>(this)->configure_stream_executors();- });-// sanity checkOPENVINO_ASSERT(_device != nullptr, "No available devices. Failed to create infer request!");- if (!_propertiesManager->getConfig().get<CREATE_EXECUTOR>() ||- _propertiesManager->getConfig().get<DEFER_WEIGHTS_LOAD>()) {+ const auto localConfig = _propertiesManager->getConfig();+ if (!localConfig.get<CREATE_EXECUTOR>() || localConfig.get<DEFER_WEIGHTS_LOAD>()) {OPENVINO_ASSERT(_graph != nullptr, "Invalid graph handle! Failed to create infer request!");- _graph->initialize(_propertiesManager->getConfig());+ _graph->initialize(localConfig);}OPENVINO_ASSERT(_graph != nullptr && _graph->init_completed(),"Graph is unavailable or failed to initialize. The driver may be missing or too old to run ""inference for this blob.");- const std::shared_ptr<InferRequest>& inferRequest =- _device->createInferRequest(shared_from_this(), _propertiesManager->getConfig());+ const std::shared_ptr<InferRequest>& inferRequest = _device->createInferRequest(shared_from_this(), localConfig);++ std::call_once(_streamExecutorsInitFlag, [this, &localConfig] {+ const_cast<CompiledModel*>(this)->configure_stream_executors(localConfig.get<NUM_STREAMS>(),+ localConfig.get<RUN_INFERENCES_SEQUENTIALLY>());+ });return std::make_shared<AsyncInferRequest>(inferRequest,get_task_executor(),@@ -96,7 +88,9 @@ std::shared_ptr<ov::ISyncInferRequest> CompiledModel::create_sync_infer_request(void CompiledModel::export_model(std::ostream& stream) const {_logger.debug("CompiledModel::export_model");- const bool rawBlobExportRequested = _propertiesManager->getConfig().get<EXPORT_RAW_BLOB>();+ const auto localConfig = _propertiesManager->getConfig();++ const bool rawBlobExportRequested = localConfig.get<EXPORT_RAW_BLOB>();if (rawBlobExportRequested) {OPENVINO_ASSERT(_graph->get_blob_type() == BlobType::ELF && _graph->get_kind() == GraphKind::Weightful,"Requested raw blob export, but the graph is not a weightful ELF one.");@@ -106,8 +100,8 @@ void CompiledModel::export_model(std::ostream& stream) const {std::optional<uint64_t> blobSizeAfterEncryption = std::nullopt;std::optional<std::vector<uint64_t>> initBlobSizes;- if (_propertiesManager->getConfig().has(CACHE_ENCRYPTION_CALLBACKS::key().data()) &&- _propertiesManager->getConfig().get<CACHE_ENCRYPTION_CALLBACKS>().encrypt != nullptr) {+ if (localConfig.has<CACHE_ENCRYPTION_CALLBACKS>() &&+ localConfig.get<CACHE_ENCRYPTION_CALLBACKS>().encrypt != nullptr) {std::string encryptedBlobStr;{std::string tmpBlobStr;@@ -117,8 +111,7 @@ void CompiledModel::export_model(std::ostream& stream) const {_graph->export_blob(tmpStringStream); // +1x blob sizetmpBlobStr = tmpStringStream.str(); // +2x blob size} // -1x blob size when deallocating temporary stringstream- encryptedBlobStr =- _propertiesManager->getConfig().get<CACHE_ENCRYPTION_CALLBACKS>().encrypt(tmpBlobStr); // +2x blob size+ encryptedBlobStr = localConfig.get<CACHE_ENCRYPTION_CALLBACKS>().encrypt(tmpBlobStr); // +2x blob sizeblobSizeAfterEncryption = encryptedBlobStr.size();} // -1x blob size when deallocating temporary blob stringstream.write(encryptedBlobStr.c_str(), encryptedBlobStr.size());@@ -145,8 +138,8 @@ void CompiledModel::export_model(std::ostream& stream) const {}std::optional<uint32_t> compilerVersion = std::nullopt;- if (_propertiesManager->getConfig().has(ov::intel_npu::compiler_version.name())) {- compilerVersion = _propertiesManager->getConfig().get<COMPILER_VERSION>();+ if (localConfig.has(ov::intel_npu::compiler_version.name())) {+ compilerVersion = localConfig.get<COMPILER_VERSION>();}Metadata<CURRENT_METADATA_VERSION>(blobSizesBeforeVersioning,@@ -208,23 +201,7 @@ std::shared_ptr<const ov::Model> CompiledModel::get_runtime_model() const {}void CompiledModel::set_property(const ov::AnyMap& properties) {- // 1. Set the property via Properties interface_propertiesManager->setProperty(properties);-- // 2. Extra hooks- if (properties.count(std::string(WORKLOAD_TYPE::key())) != 0) {- if (_graph != nullptr) {- const auto workloadType = properties.at(ov::workload_type.name()).as<ov::WorkloadType>();- _graph->set_workload_type(workloadType);- }- }-- if (properties.count(std::string(MODEL_PRIORITY::key())) != 0) {- if (_graph != nullptr) {- const auto modelPriority = properties.at(ov::hint::model_priority.name()).as<ov::hint::Priority>();- _graph->set_model_priority(modelPriority);- }- }}ov::Any CompiledModel::get_property(const std::string& name) const {@@ -235,29 +212,22 @@ const std::shared_ptr<IGraph>& CompiledModel::get_graph() const {return _graph;}-const FilteredConfig& CompiledModel::get_config() const {- return _propertiesManager->getConfig();-}-void CompiledModel::release_memory() {if (_graph != nullptr) {_graph->evict_memory();}}-void CompiledModel::configure_stream_executors() {- const FilteredConfig& config = get_config();-+void CompiledModel::configure_stream_executors(ov::streams::Num numStreams, bool runInferencesSequentially) {// In case of sequential execution of async requests for the same compiled model, the compiled model must use// dedicated executors with a single thread to ensure sequential execution of its async requests.- if (config.get<RUN_INFERENCES_SEQUENTIALLY>()) {+ if (runInferencesSequentially) {set_task_executor(make_executor("Intel NPU plugin start inferences executor", 1));_resultExecutor = make_executor("Intel NPU plugin wait inferences executor", 1);return;}- const auto numStreams = config.get<NUM_STREAMS>();if (numStreams > 0) {// Use a single thread for start executors to reduce contention on the shared task queue, while scaling wait// executor workers with num_streams to improve result fetch throughput. Callbacks intentionally run on wait@@ -277,7 +247,7 @@ void CompiledModel::configure_stream_executors() {// idle periods (30 s timeout) is derived from the optimal number of parallel infer requests recommended for// the current platform in THROUGHPUT mode. The pool can then grow dynamically to match runtime workload.const size_t keepWorkers = static_cast<size_t>(- utils::getOptimalNumberOfInferRequestsInParallel(config.get<PLATFORM>(),+ utils::getOptimalNumberOfInferRequestsInParallel(_device->getName(),ov::hint::PerformanceMode::THROUGHPUT));set_task_executor(make_executor("Intel NPU plugin run inferences executor", keepWorkers, true));diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cppindex 209734bb37f..729e6783110 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp@@ -24,9 +24,8 @@ std::string buildRuntimeRequirements(const std::shared_ptr<intel_npu::IGraph>& gOPENVINO_ASSERT(graph != nullptr, "Missing graph");auto compatibilityDescriptor = graph->get_compatibility_descriptor();- if (!compatibilityDescriptor.has_value()) {- OPENVINO_THROW("RUNTIME_REQUIREMENTS cannot be generated for this compiled model.");- }+ OPENVINO_ASSERT(compatibilityDescriptor.has_value(),+ "RUNTIME_REQUIREMENTS cannot be generated for this compiled model.");const auto descriptorView = compatibilityDescriptor.value();logger.debug("Runtime requirements from the graph %.*s length: %zu",static_cast<int>(descriptorView.size()),@@ -57,49 +56,44 @@ std::string buildRuntimeRequirements(const std::shared_ptr<intel_npu::IGraph>& gnamespace intel_npu {CompiledModelPropertyManager::CompiledModelPropertyManager(const FilteredConfig& config,+ const ov::AnyMap& properties,+ const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,const std::optional<int64_t>& batchSize,Logger& logger): _config(config),+ _device(device),_graph(graph),_batchSize(batchSize),_logger(logger) {registerProperties();++ // Set the properties from the provided ov::AnyMap into the internal property descriptors+ for (const auto& property : properties) {+ const auto propertyDescriptorIt = _properties.find(property.first);+ OPENVINO_ASSERT(propertyDescriptorIt != _properties.end(), "Unsupported configuration key: ", property.first);+ OPENVINO_ASSERT(propertyDescriptorIt->second.isSupported(properties),+ "Unsupported configuration key: ",+ property.first);+ propertyDescriptorIt->second.set(property.second);+ }}void CompiledModelPropertyManager::setProperty(const ov::AnyMap& properties) {std::lock_guard<std::mutex> lock(_mutex);- if (properties.find(ov::hint::enable_cpu_pinning.name()) != properties.end()) {- logCpuPinningDeprecationWarning(_logger);- }-- std::map<std::string, std::string> configsToSet;- ov::AnyMap specialConfigsToSet;-for (const auto& property : properties) {const auto propertyIt = _properties.find(property.first);- if (propertyIt == _properties.end()) {- OPENVINO_THROW("Unsupported configuration key: ", property.first);- }-- if (propertyIt->second.mutability == ov::PropertyMutability::RO) {- OPENVINO_THROW("READ-ONLY configuration key: ", property.first);- }-- if (property.first == ov::cache_encryption_callbacks.name()) {- specialConfigsToSet.emplace(property.first, property.second);- } else {- configsToSet.emplace(property.first, property.second.as<std::string>());- }- }-- if (!configsToSet.empty()) {- _config.update(configsToSet);+ OPENVINO_ASSERT(propertyIt != _properties.end(), "Unsupported configuration key: ", property.first);+ OPENVINO_ASSERT(propertyIt->second.mutability != ov::PropertyMutability::RO,+ "READ-ONLY configuration key: ",+ property.first);+ OPENVINO_ASSERT(propertyIt->second.isSupported(properties), "Unsupported configuration key: ", property.first);}- if (!specialConfigsToSet.empty()) {- _config.updateAny(specialConfigsToSet);+ for (const auto& property : properties) {+ const auto propertyIt = _properties.find(property.first);+ propertyIt->second.set(property.second);}}@@ -112,11 +106,12 @@ ov::Any CompiledModelPropertyManager::getProperty(const std::string& name) constconst auto propertyIt = _properties.find(name);if (propertyIt != _properties.end()) {+ OPENVINO_ASSERT(propertyIt->second.isSupported(ov::AnyMap{}), "Unsupported configuration key: ", name);if (propertyIt->second.mutability == ov::PropertyMutability::WO) {_logger.warning("Trying to get WRITE-ONLY property: %s. Returning empty `ov::Any` object", name.c_str());return ov::Any();}- return propertyIt->second.get(_config);+ return propertyIt->second.get(ov::AnyMap{});}try {@@ -126,94 +121,200 @@ ov::Any CompiledModelPropertyManager::getProperty(const std::string& name) const}}+FilteredConfig CompiledModelPropertyManager::getConfig() const {+ std::lock_guard<std::mutex> lock(_mutex);+ return _config;+}+void CompiledModelPropertyManager::registerProperties() {_properties.clear();- _supportedProperties.clear();- try_register_property_based_on_config<MODEL_PRIORITY>(_config, _properties, ov::hint::model_priority.name());- try_register_property_based_on_config<WORKLOAD_TYPE>(_config, _properties, ov::workload_type.name());+ const auto hasPropertyValue = [this](const std::string& property_name) {+ return _config.has(property_name);+ };++ const auto readOnlySetter = [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ };++ const auto registerConfigProperty = [this, hasPropertyValue](const auto optionTag, bool requireValue) {+ using OptionType = std::decay_t<decltype(optionTag)>;+ const auto propertyName = std::string(OptionType::key());+ const auto isSupported = [this, propertyName, hasPropertyValue, requireValue](const ov::AnyMap&) {+ return requireValue ? hasPropertyValue(propertyName) : _config.hasOpt(propertyName);+ };+ register_property(+ propertyName,+ true,+ ov::PropertyMutability::RO,+ isSupported,+ [this](const ov::AnyMap&) {+ return _config.get<OptionType>();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ });+ };++ registerConfigProperty(LOADED_FROM_CACHE{}, false);+ registerConfigProperty(LOG_LEVEL{}, false);+ registerConfigProperty(PERFORMANCE_HINT{}, false);+ registerConfigProperty(PERFORMANCE_HINT_NUM_REQUESTS{}, false);+ registerConfigProperty(NUM_STREAMS{}, false);++ registerConfigProperty(BYPASS_UMD_CACHING{}, true);+ registerConfigProperty(CACHE_DIR{}, true);+ registerConfigProperty(CACHE_MODE{}, true);+ registerConfigProperty(COMPILATION_MODE_PARAMS{}, true);+ registerConfigProperty(COMPILATION_NUM_THREADS{}, true);+ registerConfigProperty(COMPILER_DYNAMIC_QUANTIZATION{}, true);+ registerConfigProperty(COMPILER_TYPE{}, true);+ registerConfigProperty(COMPILER_VERSION{}, true);+ registerConfigProperty(DEFER_WEIGHTS_LOAD{}, true);+ registerConfigProperty(ENABLE_STRIDES_FOR{}, true);+ registerConfigProperty(EXECUTION_MODE_HINT{}, true);+ registerConfigProperty(PERF_COUNT{}, true);+ registerConfigProperty(PLATFORM{}, true);+ registerConfigProperty(QDQ_OPTIMIZATION{}, true);+ registerConfigProperty(QDQ_OPTIMIZATION_AGGRESSIVE{}, true);+ registerConfigProperty(RUN_INFERENCES_SEQUENTIALLY{}, true);+ registerConfigProperty(TILES{}, true);+ registerConfigProperty(TURBO{}, true);+ registerConfigProperty(WEIGHTS_PATH{}, true);+ registerConfigProperty(BACKEND_COMPILATION_PARAMS{}, true);+ registerConfigProperty(BATCH_COMPILER_MODE_SETTINGS{}, true);+ registerConfigProperty(BATCH_MODE{}, true);+ registerConfigProperty(COMPILATION_MODE{}, true);+ registerConfigProperty(COMPILE_LOG_LEVEL{}, true);+ registerConfigProperty(DISABLE_VERSION_CHECK{}, true);+ registerConfigProperty(DMA_ENGINES{}, true);+ registerConfigProperty(DYNAMIC_SHAPE_TO_STATIC{}, true);+ registerConfigProperty(ENABLE_WEIGHTLESS{}, true);+ registerConfigProperty(EXPORT_RAW_BLOB{}, true);+ registerConfigProperty(IMPORT_RAW_BLOB{}, true);+ registerConfigProperty(INFERENCE_PRECISION_HINT{}, true);+ registerConfigProperty(PROFILING_TYPE{}, true);+ registerConfigProperty(SEPARATE_WEIGHTS_VERSION{}, true);+ registerConfigProperty(SHARED_COMMON_QUEUE{}, true);// clang-format offOPENVINO_SUPPRESS_DEPRECATED_START- try_register_property_based_on_config_as_read_only<ENABLE_CPU_PINNING>(_config, _properties, ov::hint::enable_cpu_pinning.name());+ register_property(ov::hint::enable_cpu_pinning.name(), false, ov::PropertyMutability::RO,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::hint::enable_cpu_pinning.name());+ },+ [this](const ov::AnyMap&) {+ return _config.get<ENABLE_CPU_PINNING>();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key");+ }+ );OPENVINO_SUPPRESS_DEPRECATED_END- try_register_property_based_on_config_as_read_only<LOG_LEVEL>(_config, _properties, ov::log::level.name());- try_register_property_based_on_config_as_read_only<LOADED_FROM_CACHE>(_config, _properties, ov::loaded_from_cache.name());- try_register_property_based_on_config_as_read_only<PERFORMANCE_HINT>(_config, _properties, ov::hint::performance_mode.name());- try_register_property_based_on_config_as_read_only<EXECUTION_MODE_HINT>(_config, _properties, ov::hint::execution_mode.name());- try_register_property_based_on_config_as_read_only<PERFORMANCE_HINT_NUM_REQUESTS>(_config, _properties, ov::hint::num_requests.name());- try_register_property_based_on_config_as_read_only<COMPILATION_NUM_THREADS>(_config, _properties, ov::compilation_num_threads.name());- try_register_property_based_on_config_as_read_only<INFERENCE_PRECISION_HINT>(_config, _properties, ov::hint::inference_precision.name());- try_register_property_based_on_config_as_read_only<CACHE_MODE>(_config, _properties, ov::cache_mode.name());-- try_register_property_based_on_config_if_set_as_read_only<NUM_STREAMS>(_config, _properties, ov::num_streams.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILER_TYPE>(_config, _properties, ov::intel_npu::compiler_type.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILER_VERSION>(_config, _properties, ov::intel_npu::compiler_version.name());- try_register_property_based_on_config_if_set_as_read_only<WEIGHTS_PATH>(_config, _properties, ov::weights_path.name());- try_register_property_based_on_config_if_set_as_read_only<CACHE_DIR>(_config, _properties, ov::cache_dir.name());- try_register_property_based_on_config_if_set_as_read_only<PERF_COUNT>(_config, _properties, ov::enable_profiling.name());- try_register_property_based_on_config_if_set_as_read_only<PROFILING_TYPE>(_config, _properties, ov::intel_npu::profiling_type.name());- try_register_property_based_on_config_if_set_as_read_only<TURBO>(_config, _properties, ov::intel_npu::turbo.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILATION_MODE_PARAMS>(_config, _properties, ov::intel_npu::compilation_mode_params.name());- try_register_property_based_on_config_if_set_as_read_only<DMA_ENGINES>(_config, _properties, ov::intel_npu::dma_engines.name());- try_register_property_based_on_config_if_set_as_read_only<TILES>(_config, _properties, ov::intel_npu::tiles.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILATION_MODE>(_config, _properties, ov::intel_npu::compilation_mode.name());- try_register_property_based_on_config_if_set_as_read_only<PLATFORM>(_config, _properties, ov::intel_npu::platform.name());- try_register_property_based_on_config_if_set_as_read_only<DYNAMIC_SHAPE_TO_STATIC>(_config, _properties, ov::intel_npu::dynamic_shape_to_static.name());- try_register_property_based_on_config_if_set_as_read_only<BACKEND_COMPILATION_PARAMS>(_config, _properties, ov::intel_npu::backend_compilation_params.name());- try_register_property_based_on_config_if_set_as_read_only<BYPASS_UMD_CACHING>(_config, _properties, ov::intel_npu::bypass_umd_caching.name());- try_register_property_based_on_config_if_set_as_read_only<DEFER_WEIGHTS_LOAD>(_config, _properties, ov::intel_npu::defer_weights_load.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILER_DYNAMIC_QUANTIZATION>(_config, _properties, ov::intel_npu::compiler_dynamic_quantization.name());- try_register_property_based_on_config_if_set_as_read_only<QDQ_OPTIMIZATION>(_config, _properties, ov::intel_npu::qdq_optimization.name());- try_register_property_based_on_config_if_set_as_read_only<QDQ_OPTIMIZATION_AGGRESSIVE>(_config, _properties, ov::intel_npu::qdq_optimization_aggressive.name());- try_register_property_based_on_config_if_set_as_read_only<DISABLE_VERSION_CHECK>(_config, _properties, ov::intel_npu::disable_version_check.name());- try_register_property_based_on_config_if_set_as_read_only<EXPORT_RAW_BLOB>(_config, _properties, ov::intel_npu::export_raw_blob.name());- try_register_property_based_on_config_if_set_as_read_only<IMPORT_RAW_BLOB>(_config, _properties, ov::intel_npu::import_raw_blob.name());- try_register_property_based_on_config_if_set_as_read_only<BATCH_COMPILER_MODE_SETTINGS>(_config, _properties, ov::intel_npu::batch_compiler_mode_settings.name());- try_register_property_based_on_config_if_set_as_read_only<RUN_INFERENCES_SEQUENTIALLY>(_config, _properties, ov::intel_npu::run_inferences_sequentially.name());- try_register_property_based_on_config_if_set_as_read_only<ENABLE_WEIGHTLESS>(_config, _properties, ov::enable_weightless.name());- try_register_property_based_on_config_if_set_as_read_only<SEPARATE_WEIGHTS_VERSION>(_config, _properties, ov::intel_npu::separate_weights_version.name());- try_register_property_based_on_config_if_set_as_read_only<ENABLE_STRIDES_FOR>(_config, _properties, ov::intel_npu::enable_strides_for.name());- try_register_property_based_on_config_if_set_as_read_only<BATCH_MODE>(_config, _properties, ov::intel_npu::batch_mode.name());- try_register_property_based_on_config_if_set_as_read_only<SHARED_COMMON_QUEUE>(_config, _properties, ov::intel_npu::shared_common_queue.name());- try_register_property_based_on_config_if_set_as_read_only<COMPILE_LOG_LEVEL>(_config, _properties, ov::intel_npu::compile_log_level.name());-- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::cache_encryption_callbacks.name(), [](const Config&) {- return ov::EncryptionCallbacks{nullptr, nullptr};- });-- register_property_with_custom_function(_properties, ov::hint::model.name(), true, [](const Config&) {- return std::shared_ptr<const ov::Model>(nullptr);- });- register_property_with_custom_function(_properties, ov::model_name.name(), true, [this](const Config&) {- OPENVINO_ASSERT(_graph != nullptr, "Missing graph");- return ov::Any(_graph->get_metadata().name);- });- register_property_with_custom_function(_properties, ov::optimal_number_of_infer_requests.name(), true, [](const Config& config) {- return ov::Any(utils::getOptimalNumberOfInferRequestsInParallel(config.get<PLATFORM>(), config.get<PERFORMANCE_HINT>()));- });- register_property_with_custom_function(_properties, ov::execution_devices.name(), true, [](const Config&) {- return ov::Any(std::string("NPU"));- });- register_property_with_custom_function(_properties, ov::supported_properties.name(), true, [this](const Config&) {- return ov::Any(_supportedProperties);- });- // clang-format on-- try_register_property_with_custom_function(- _properties,- ov::runtime_requirements.name(),- _graph != nullptr && _graph->get_compatibility_descriptor().has_value(),- true,- [this](const Config&) {- return ov::Any(buildRuntimeRequirements(_graph, _batchSize, _logger));- });-- for (const auto& property : _properties) {- if (property.second.isPublic) {- _supportedProperties.emplace_back(property.first, property.second.mutability);+ register_property(ov::hint::model_priority.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::hint::model_priority.name());+ },+ [this](const ov::AnyMap&) {+ return _config.get<MODEL_PRIORITY>();+ },+ [this](const ov::Any& value) {+ _config.update(ov::hint::model_priority.name(), value.as<std::string>());+ if (_graph != nullptr) {+ _graph->set_model_priority(value.as<ov::hint::Priority>());+ }}- }+ );+ register_property(ov::workload_type.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::workload_type.name());+ },+ [this](const ov::AnyMap&) {+ return _config.get<WORKLOAD_TYPE>();+ },+ [this](const ov::Any& value) {+ _config.update(ov::workload_type.name(), value.as<std::string>());+ if (_graph != nullptr) {+ _graph->set_workload_type(value.as<ov::WorkloadType>());+ }+ }+ );+ register_property(ov::cache_encryption_callbacks.name(), true, ov::PropertyMutability::WO,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::cache_encryption_callbacks.name());+ },+ [](const ov::AnyMap&) {+ return ov::EncryptionCallbacks{nullptr, nullptr};+ },+ [this](const ov::Any& value) {+ _config.updateAny(ov::cache_encryption_callbacks.name(), value);+ }+ );+ register_property(ov::hint::model.name(), true, ov::PropertyMutability::RO,+ [](const ov::AnyMap&) {+ return true;+ },+ [this](const ov::AnyMap&) {+ return _config.get<MODEL_PTR>().lock();+ },+ readOnlySetter+ );+ register_property(ov::model_name.name(), true, ov::PropertyMutability::RO,+ [this](const ov::AnyMap&) {+ return _graph != nullptr;+ },+ [this](const ov::AnyMap&) {+ OPENVINO_ASSERT(_graph != nullptr, "Missing graph");+ return ov::Any(_graph->get_metadata().name);+ },+ readOnlySetter+ );+ register_property(ov::optimal_number_of_infer_requests.name(), true, ov::PropertyMutability::RO,+ [](const ov::AnyMap&) {+ return true;+ },+ [this](const ov::AnyMap&) {+ if (!_device) {+ return ov::Any(uint32_t{0});+ }+ return ov::Any(utils::getOptimalNumberOfInferRequestsInParallel(_device->getName(), _config.get<PERFORMANCE_HINT>()));+ },+ readOnlySetter+ );+ register_property(ov::execution_devices.name(), true, ov::PropertyMutability::RO,+ [](const ov::AnyMap&) {+ return true;+ },+ [](const ov::AnyMap&) {+ return ov::Any(std::vector<std::string>{"NPU"});+ },+ readOnlySetter+ );+ register_property(ov::supported_properties.name(), true, ov::PropertyMutability::RO,+ [](const ov::AnyMap&) {+ return true;+ },+ [this](const ov::AnyMap& arguments) {+ std::vector<ov::PropertyName> supportedProperties;+ for (const auto& property : _properties) {+ if (property.second.isPublic && property.second.isSupported(arguments)) {+ supportedProperties.emplace_back(property.first, property.second.mutability);+ }+ }+ return ov::Any(supportedProperties);+ },+ readOnlySetter+ );+ register_property(ov::runtime_requirements.name(), true, ov::PropertyMutability::RO,+ [this](const ov::AnyMap&) {+ return _graph != nullptr && _graph->get_compatibility_descriptor().has_value();+ },+ [this](const ov::AnyMap&) {+ return ov::Any(buildRuntimeRequirements(_graph, _batchSize, _logger));+ },+ readOnlySetter+ );+ // clang-format on}} // namespace intel_npudiff --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.cppindex c1af354aa46..43e3c110d26 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@@ -30,7 +30,7 @@ const std::shared_ptr<OptionSupportCache>& CompilerOptionSupportHelper::getOptiobool CompilerOptionSupportHelper::isOptionSupported(ov::intel_npu::CompilerType compilerType,const std::string& optionName,const std::optional<std::string>& optionValue) {- const auto& supportedCompilerTypes = CompilerAdapterFactory::getSupportedCompilerTypes();+ const auto supportedCompilerTypes = _adapterFactory.getKnownCompilerTypes();OPENVINO_ASSERT(std::find(supportedCompilerTypes.begin(), supportedCompilerTypes.end(), compilerType) !=supportedCompilerTypes.end(),"Unsupported compiler type");diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex 6b5ea6ab18d..214954575ac 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -11,7 +11,6 @@#include "compiled_model.hpp"#include "intel_npu/common/compiler_adapter_factory.hpp"#include "intel_npu/common/device_helpers.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/icompiler_adapter.hpp"#include "intel_npu/common/igraph.hpp"#include "intel_npu/common/itt.hpp"@@ -114,34 +113,12 @@ std::shared_ptr<ov::ICompiledModel> import_model_npuw(std::istream& stream,return nullptr;}-std::shared_ptr<const ov::Model> get_model_ptr_from_map(const ov::AnyMap& properties) {- if (properties.count(ov::hint::model.name())) {- try {- return properties.at(ov::hint::model.name()).as<std::shared_ptr<const ov::Model>>();- } catch (const ov::Exception&) {- try {- return std::const_pointer_cast<const ov::Model>(- properties.at(ov::hint::model.name()).as<std::shared_ptr<ov::Model>>());- } catch (const ov::Exception&) {- OPENVINO_THROW("The value of the \"ov::hint::model\" configuration option (\"MODEL_PTR\") has the "- "wrong data type. Expected: std::shared_ptr<const ov::Model>.");- }- }- }-- return nullptr;-}--void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredConfig& config) {- // Initialize (note: it will reset registered options)+void register_options(const ov::SoPtr<intel_npu::IEngineBackend>& backend, intel_npu::OptionsDesc& options) {options.reset();-#define REGISTER_OPTION(OPT_TYPE) \- do { \- auto dummyopt = details::makeOptionModel<OPT_TYPE>(); \- std::string o_name = dummyopt.key().data(); \- options.add<OPT_TYPE>(); \- config.enable(std::move(o_name), false); \+#define REGISTER_OPTION(OPT_TYPE) \+ do { \+ options.add<OPT_TYPE>(); \} while (0)REGISTER_OPTION(LOG_LEVEL);@@ -157,11 +134,7 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCoREGISTER_OPTION(PERFORMANCE_HINT);REGISTER_OPTION(EXECUTION_MODE_HINT);REGISTER_OPTION(PERFORMANCE_HINT_NUM_REQUESTS);- OPENVINO_SUPPRESS_DEPRECATED_START- REGISTER_OPTION(ENABLE_CPU_PINNING);- OPENVINO_SUPPRESS_DEPRECATED_ENDREGISTER_OPTION(INFERENCE_PRECISION_HINT);- REGISTER_OPTION(MODEL_PRIORITY);REGISTER_OPTION(COMPILATION_MODE_PARAMS);REGISTER_OPTION(DMA_ENGINES);REGISTER_OPTION(TILES);@@ -194,58 +167,31 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCoREGISTER_OPTION(ENABLE_STRIDES_FOR);REGISTER_OPTION(SHARED_COMMON_QUEUE);REGISTER_OPTION(CACHE_ENCRYPTION_CALLBACKS);- REGISTER_OPTION(RUNTIME_REQUIREMENTS);- REGISTER_OPTION(COMPATIBILITY_CHECK);+ REGISTER_OPTION(MAX_TILES);+ REGISTER_OPTION(MODEL_PTR);+ REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);if (backend) {// Options registered only if drivers is present and supports the corresponding extension- REGISTER_OPTION(MAX_TILES);+ REGISTER_OPTION(MODEL_PRIORITY);if (backend->isCommandQueueExtSupported()) {REGISTER_OPTION(WORKLOAD_TYPE);}- if (backend->isContextExtSupported()) {- REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);- }}- // parse again env_variables to update registered configs which have env vars set- config.parseEnvVars();+ OPENVINO_SUPPRESS_DEPRECATED_START+ REGISTER_OPTION(ENABLE_CPU_PINNING);+ OPENVINO_SUPPRESS_DEPRECATED_END- // NPUW properties are requested by OV Core during caching and have no effect on the NPU plugin. But we still need- // to enable those for OV Core to query. Note: do this last to not filter them out. register npuw caching properties+ // NPUW properties are requested by OV Core during caching and+ // have no effect on the NPU plugin. But we still need to enable+ // those for OV Core to query. Note: do this last to not filter+ // them out. register npuw caching propertiesfor_each_exposed_npuw_option([&](auto tag) {using Opt = typename decltype(tag)::type;REGISTER_OPTION(Opt);});-- config.enableRuntimeOptions();-- // Special cases - options with OptionMode::Both must be enabled for the plugin even if the compiler does not- // support them, because they may be used by the plugin itself or by the driver.- // We still check compiler support to decide whether these options should be removed from the config string.-- // NPU_TURBO might be supported by the driver- if (backend && backend->isCommandQueueExtSupported()) {- config.enable(ov::intel_npu::turbo.name(), true);- }-- // LOG_LEVEL, PERFORMANCE_HINT and PERF_COUNT are needed by runtime options- config.enable(ov::log::level.name(), true);- config.enable(ov::hint::performance_mode.name(), true);- config.enable(ov::enable_profiling.name(), true);-- if (config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && backend != nullptr) {- auto device = backend->getDevice();- if (device) {- auto platformName = device->getName();- CompilerAdapterFactory compilerFactory;- auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);- if (compileType == ov::intel_npu::CompilerType::DRIVER) {- config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});- }- }- }}} // namespace@@ -257,22 +203,20 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {set_device_name("NPU");std::shared_ptr<OptionsDesc> options = std::make_shared<OptionsDesc>();+// parse env_variables to get LOG_LEVEL if neededoptions->add<LOG_LEVEL>();-- FilteredConfig config(options);- config.parseEnvVars();- Logger::global().setLevel(config.get<LOG_LEVEL>());- _logger.setLevel(config.get<LOG_LEVEL>());+ std::shared_ptr<FilteredConfig> config = std::make_shared<FilteredConfig>(options);+ config->parseEnvVars();+ Logger::global().setLevel(config->get<LOG_LEVEL>());+ _logger.setLevel(config->get<LOG_LEVEL>());OV_ITT_TASK_CHAIN(PLUGIN, itt::domains::NPUPlugin, "Plugin::Plugin", "GetBackend");// backend registry shall be created after configs are updated_backendsRegistry = std::make_unique<BackendsRegistry>();_backend = _backendsRegistry->getEngineBackend();- OV_ITT_TASK_NEXT(PLUGIN, "InitConfig");- init_config(_backend._ptr.get(), *options, config);-+ register_options(_backend, *options);if (_backend) {OV_ITT_TASK_NEXT(PLUGIN, "RegisterBackendOptions");_backend->registerOptions(*options);@@ -282,19 +226,16 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {OV_ITT_TASK_NEXT(PLUGIN, "RegisterProperties");_compilerOptionSupportHelper = std::make_shared<CompilerOptionSupportHelper>(_backend, CompilerAdapterFactory());_propertiesManager =- std::make_unique<PluginPropertyManager>(config, _backend, _compilerOptionSupportHelper, _logger);+ std::make_unique<PluginPropertyManager>(options, _backend, _compilerOptionSupportHelper, _logger);}void Plugin::set_property(const ov::AnyMap& properties) {if (properties.empty()) {return;}- update_log_level(properties);-- if (_backend != nullptr) {- _backend->updateInfo(properties);+ if (const auto logLevel = properties.find(ov::log::level.name()); logLevel != properties.end()) {+ _logger.setLevel(logLevel->second.as<ov::log::Level>());}-_propertiesManager->setProperty(properties);}@@ -306,10 +247,31 @@ bool Plugin::is_property_supported(const std::string& name, const ov::AnyMap& arreturn _propertiesManager->isPropertySupported(name, arguments);}+void Plugin::update_global_properties(const ov::AnyMap& properties) const {+ const auto logLevel = properties.find(ov::log::level.name());+ const auto disableIdleMemoryPruning = properties.find(ov::intel_npu::disable_idle_memory_prunning.name());+ if (logLevel == properties.end() && disableIdleMemoryPruning == properties.end()) {+ return;+ }++ if (logLevel != properties.end()) {+ _logger.setLevel(logLevel->second.as<ov::log::Level>());+ Logger::global().setLevel(logLevel->second.as<ov::log::Level>());+ if (_backend != nullptr) {+ _backend->updateInfo({{ov::log::level.name(), logLevel->second}});+ }+ }++ if (disableIdleMemoryPruning != properties.end()) {+ _propertiesManager->setProperty(+ {{ov::intel_npu::disable_idle_memory_prunning.name(), disableIdleMemoryPruning->second}});+ }+}+std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties) const {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::compile_model");- update_log_level(properties);+ update_global_properties(properties);// Before going any further: if// ... 1 - NPUW mode is activated@@ -326,17 +288,9 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<}}- if (_backend != nullptr) {- _backend->updateInfo(localProperties);- }-- // Resolving the requested compiler type based on local and global properties.- // It can still remain PREFER_PLUGIN even after this point- ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);-- auto deviceId = _propertiesManager->determineDeviceId(localProperties);// DEVICE_ID can be passed both as an index and as a platform name.// Identify the right device object to be taken into account when the target compilation platform is determined+ std::string deviceId = _propertiesManager->determineDeviceId(localProperties);std::shared_ptr<IDevice> device = utils::getDeviceById(_backend, deviceId);// Determine the final compilation target based on NPU_PLATFORM, determined device name (if any) and the list of@@ -346,6 +300,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<device == nullptr ? std::move(deviceId) : device->getName(),_backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());+ ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);CompilerAdapterFactory factory;auto compiler = factory.getCompiler(_backend,compilerType,@@ -358,15 +313,12 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<}OV_ITT_TASK_CHAIN(PLUGIN_COMPILE_MODEL, itt::domains::NPUPlugin, "Plugin::compile_model", "fork_local_config");- FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties);- localConfig.update({{ov::intel_npu::compiler_version.name(), std::to_string(compiler->get_version())}});+ auto mergedConfigAndUnknownProperties =+ _propertiesManager->getMergedConfigAndUnknownProperties(localProperties, ConfigMergeMode::Compile);+ auto& localConfig = mergedConfigAndUnknownProperties.first;+ auto& unknownProperties = mergedConfigAndUnknownProperties.second;- auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {- std::stringstream strStream;- strStream << mode;- _logger.info("Setting batching mode to %s.", strStream.str().c_str());- localConfig.update({{ov::intel_npu::batch_mode.name(), strStream.str()}});- };+ localConfig.updateAny(ov::intel_npu::compiler_version.name(), compiler->get_version());// Resolve HostCompile before batching so the selected mode controls subsequent model and batch handling.if (compilerType == ov::intel_npu::CompilerType::PLUGIN && !localConfig.has<COMPILATION_MODE>() &&@@ -404,7 +356,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<if (inputsDynamic && outputsDynamic && allPortsHaveFiniteUpperBounds) {_logger.info("NPU_COMPILATION_MODE not set; selecting 'HostCompile_Interpreter' ""for fully-dynamic model (inputs and outputs both dynamic)");- localConfig.update({{ov::intel_npu::compilation_mode.name(), "HostCompile_Interpreter"}});+ localConfig.update(ov::intel_npu::compilation_mode.name(), "HostCompile_Interpreter");}}@@ -421,8 +373,23 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<bool shouldHandleBatching = false;bool successfullyDebatched = false;- if (localConfig.isAvailable(ov::intel_npu::batch_mode.name())) {- // Set default batch mode if not configured+ auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {+ localConfig.updateAny(ov::intel_npu::batch_mode.name(), mode);+ };++ const auto batchIsAvailable = [&]() {+ bool isSupported = false;+ try {+ isSupported =+ _compilerOptionSupportHelper->isOptionSupported(compilerType, ov::intel_npu::batch_mode.name());+ } catch (...) {+ isSupported = false;+ }++ return isSupported;+ }();++ if (batchIsAvailable) {if (!localConfig.has(ov::intel_npu::batch_mode.name())) {updateBatchMode(ov::intel_npu::BatchMode::AUTO);}@@ -435,8 +402,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<// Handle models with variables (states)if (!model->get_variables().empty()) {if (localConfig.get<BATCH_MODE>() == ov::intel_npu::BatchMode::PLUGIN) {- OPENVINO_THROW(- "This model contains states, thus it is not supported when handling batching on the plugin");+ OPENVINO_THROW("This model contains states, thus it is not supported when handling batching on "+ "the plugin");}updateBatchMode(ov::intel_npu::BatchMode::COMPILER);}@@ -448,9 +415,14 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<}if (shouldHandleBatching) {+ std::optional<ov::intel_npu::BatchMode> batchMode = std::nullopt;+ if (batchIsAvailable) {+ batchMode = localConfig.get<BATCH_MODE>();+ }+// Process batchingstd::tie(batchedModel, successfullyDebatched) =- intel_npu::batch_helpers::handlePluginBatching(model, localConfig, updateBatchMode, originalBatch, _logger);+ intel_npu::batch_helpers::handlePluginBatching(model, updateBatchMode, batchMode, originalBatch, _logger);}if (localConfig.has(ov::intel_npu::enable_strides_for.name())) {@@ -459,8 +431,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<!intel_npu::batch_helpers::checkModelDynamicDims(model),"Dynamic shape tensors are not supported with the dynamic strides feature (ENABLE_STRIDES_FOR).");- OPENVINO_ASSERT(useDynamicGraphForDynamicModel || successfullyDebatched ||- !localConfig.isAvailable(ov::intel_npu::batch_mode.name()) ||+ OPENVINO_ASSERT(useDynamicGraphForDynamicModel || successfullyDebatched || !batchIsAvailable ||localConfig.get<BATCH_MODE>() != ov::intel_npu::BatchMode::COMPILER,"Dynamic batching is not supported with the dynamic strides feature (ENABLE_STRIDES_FOR).");}@@ -468,9 +439,11 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<// Update stepping w/ information from driver, unless provided by user or we are off-device// Ignore if compilation was requested for a platform that is different from the current one- if (!localConfig.has<STEPPING>() && device != nullptr && device->getName() == compilationPlatform) {+ if (!localConfig.has<STEPPING>() &&+ _compilerOptionSupportHelper->isOptionSupported(compilerType, ov::intel_npu::stepping.name()) &&+ device != nullptr && device->getName() == compilationPlatform) {try {- localConfig.update({{ov::intel_npu::stepping.name(), std::to_string(device->getSubDevId())}});+ localConfig.update(ov::intel_npu::stepping.name(), std::to_string(device->getSubDevId()));} catch (...) {_logger.warning("Stepping information not implemented by selected backend. Skipping. Please provide ""NPU_STEPPING if required.");@@ -478,9 +451,11 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<}// Update max_tiles w/ information from driver, unless provided by user or we are off-device// Ignore if compilation was requested for a platform that is different from the current one- if (!localConfig.has<MAX_TILES>() && device != nullptr && device->getName() == compilationPlatform) {+ if (!localConfig.has<MAX_TILES>() &&+ _compilerOptionSupportHelper->isOptionSupported(compilerType, ov::intel_npu::max_tiles.name()) &&+ device != nullptr && device->getName() == compilationPlatform) {try {- localConfig.update({{ov::intel_npu::max_tiles.name(), std::to_string(device->getMaxNumSlices())}});+ localConfig.update(ov::intel_npu::max_tiles.name(), std::to_string(device->getMaxNumSlices()));} catch (...) {_logger.warning("Max tiles information not implemented by selected backend. Default value will be used.");}@@ -488,7 +463,15 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<OV_ITT_TASK_NEXT(PLUGIN_COMPILE_MODEL, "compile");- if (localConfig.isAvailable(ov::enable_weightless.name()) && !localConfig.get<CACHE_DIR>().empty()) {+ const bool isWeightlessSupported = [&]() {+ try {+ return _compilerOptionSupportHelper->isOptionSupported(compilerType, ov::enable_weightless.name());+ } catch (...) {+ return false;+ }+ }();++ if (isWeightlessSupported && !localConfig.get<CACHE_DIR>().empty()) {// If OV caching is enabled, then weights separation is performed only if the user opted for optimizing the// size of the binary objectconst bool cacheModeOptimizeSize = (localConfig.get<CACHE_MODE>() == ov::CacheMode::OPTIMIZE_SIZE);@@ -502,7 +485,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<"was set to false. Weights separation WILL be performed in this case.");}- localConfig.update({{ov::enable_weightless.name(), cacheModeOptimizeSize ? "YES" : "NO"}});+ localConfig.update(ov::enable_weightless.name(), cacheModeOptimizeSize ? "YES" : "NO");}std::shared_ptr<intel_npu::IGraph> graph;@@ -510,10 +493,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<auto compileWithConfig = [&](auto&& modelToCompile, const auto& config) {if (!localConfig.get<ENABLE_WEIGHTLESS>()) {return compiler->compile(modelToCompile, config);- } else {- check_weightless_cache_attribute_occurrence(model);- return compiler->compileWS(std::move(modelToCompile), config);}++ check_weightless_cache_attribute_occurrence(model);+ return compiler->compileWS(std::move(modelToCompile), config);};try {@@ -541,9 +524,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<_logger.info("Setting performance mode to THROUGHPUT for batched model compilation.");auto modifiedConfig = localConfig; // Copy only when needed- std::stringstream strStream;- strStream << ov::hint::PerformanceMode::THROUGHPUT;- modifiedConfig.update({{ov::hint::performance_mode.name(), strStream.str()}});+ modifiedConfig.updateAny(ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT);graph = compileWithConfig(std::move(modelToCompile), modifiedConfig);} else {graph = compileWithConfig(std::move(modelToCompile), localConfig);@@ -573,7 +554,13 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<std::shared_ptr<ov::ICompiledModel> compiledModel;try {- compiledModel = std::make_shared<CompiledModel>(model, shared_from_this(), device, graph, localConfig, batch);+ compiledModel = std::make_shared<CompiledModel>(model,+ shared_from_this(),+ device,+ graph,+ localConfig,+ unknownProperties,+ batch);} catch (const std::exception& ex) {OPENVINO_THROW(ex.what());} catch (...) {@@ -605,23 +592,9 @@ ov::SoPtr<ov::IRemoteContext> Plugin::get_default_context(const ov::AnyMap&) conreturn std::make_shared<RemoteContextImpl>(_backend);}-bool Plugin::should_import_raw_blob(const ov::AnyMap& properties) const {- const bool skipCompatibility = (properties.find(DISABLE_VERSION_CHECK::key().data()) != properties.end())- ? properties.at(DISABLE_VERSION_CHECK::key().data()).as<bool>()- : _propertiesManager->getConfig().get<DISABLE_VERSION_CHECK>();- if (skipCompatibility) {- return true;- }-- const bool importRawBlob = (properties.find(IMPORT_RAW_BLOB::key().data()) != properties.end())- ? properties.at(IMPORT_RAW_BLOB::key().data()).as<bool>()- : _propertiesManager->getConfig().get<IMPORT_RAW_BLOB>();- return importRawBlob;-}-std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, const ov::AnyMap& properties) const {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::import_model(std::istream)");- update_log_level(properties);+ update_global_properties(properties);_logger.debug("Importing a compiled model from the given stream");@@ -638,7 +611,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c}BlobSource blobSource(stream, _logger.level());-try {return import_model(blobSource, localProperties);} catch (const std::exception& ex) {@@ -651,7 +623,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, cstd::shared_ptr<ov::ICompiledModel> Plugin::import_model(const ov::Tensor& compiledBlob,const ov::AnyMap& properties) const {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::import_model(ov::Tensor)");- update_log_level(properties);+ update_global_properties(properties);_logger.debug("Importing a compiled model from the given tensor");@@ -667,7 +639,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(const ov::Tensor& compi}BlobSource blobSource(compiledBlob, _logger.level());-try {return import_model(blobSource, localProperties);} catch (const std::exception& ex) {@@ -682,21 +653,21 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(BlobSource& blobSource,_logger.trace("Importing a compiled model using a BlobSource object");OPENVINO_ASSERT(_backend != nullptr, NO_BACKEND_MESSAGE);- _backend->updateInfo(properties);OV_ITT_TASK_CHAIN(PLUGIN_PARSE_MODEL, itt::domains::NPUPlugin, "Plugin::import_model", "fork_local_config");- FilteredConfig localConfig = _propertiesManager->getConfigWithCompilerPropertiesDisabled(properties);+ auto [runtimeConfig, unknownProperties] =+ _propertiesManager->getMergedConfigAndUnknownProperties(properties, ConfigMergeMode::Import);- std::unique_ptr<IBlobFormatImporter> blobFormatImporter =- blob_format_importer_factory::create(blobSource,- should_import_raw_blob(properties),- get_model_ptr_from_map(properties),- localConfig);+ std::unique_ptr<IBlobFormatImporter> blobFormatImporter = blob_format_importer_factory::create(+ blobSource,+ runtimeConfig.get<DISABLE_VERSION_CHECK>() ? true : runtimeConfig.get<IMPORT_RAW_BLOB>(),+ runtimeConfig.has<MODEL_PTR>() ? runtimeConfig.get<MODEL_PTR>().lock() : nullptr,+ runtimeConfig);- std::shared_ptr<IDevice> device = utils::getDeviceById(_backend, _propertiesManager->determineDeviceId(properties));+ std::shared_ptr<IDevice> device = utils::getDeviceById(_backend, runtimeConfig.get<DEVICE_ID>());OPENVINO_ASSERT(device != nullptr, "Device not found.");- if (!localConfig.get<LOADED_FROM_CACHE>()) {+ if (!runtimeConfig.get<LOADED_FROM_CACHE>()) {_logger.warning("The usage of a compiled model can lead to undefined behavior. Please use OpenVINO IR instead");}@@ -711,6 +682,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(BlobSource& blobSource,device,graph,blobFormatImporter->get_config(),+ unknownProperties,graph->get_batch_size());}@@ -733,17 +705,11 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(const ov::Tensor& compiov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties) const {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::query_model");- update_log_level(properties);+ update_global_properties(properties);auto localProperties = properties;- if (_backend != nullptr) {- _backend->updateInfo(localProperties);- }-- ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);- auto deviceId = _propertiesManager->determineDeviceId(localProperties);-+ std::string deviceId = _propertiesManager->determineDeviceId(localProperties);std::shared_ptr<IDevice> device = utils::getDeviceById(_backend, deviceId);const auto compilationPlatform =@@ -751,6 +717,7 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&device == nullptr ? std::move(deviceId) : device->getName(),_backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());+ ov::intel_npu::CompilerType compilerType = _propertiesManager->determineCompilerType(localProperties);CompilerAdapterFactory factory;auto compiler = factory.getCompiler(_backend,compilerType,@@ -762,7 +729,9 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&localProperties[ov::intel_npu::platform.name()] = compilationPlatform;}- FilteredConfig localConfig = _propertiesManager->getConfigForSpecificCompiler(localProperties);+ auto localConfig =+ _propertiesManager->getMergedConfigAndUnknownProperties(localProperties, ConfigMergeMode::Query).first;+ov::SupportedOpsMap supportedOpsMap;try {supportedOpsMap = compiler->query(model->clone(), localConfig);@@ -775,13 +744,6 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&return supportedOpsMap;}-void Plugin::update_log_level(const ov::AnyMap& properties) const {- if (properties.count(ov::log::level.name()) != 0) {- Logger::global().setLevel(properties.at(ov::log::level.name()).as<ov::log::Level>());- _logger.setLevel(properties.at(ov::log::level.name()).as<ov::log::Level>());- }-}-std::atomic<int> Plugin::_compiledModelLoadCounter{1};static const ov::Version version = {CI_BUILD_NUMBER, NPU_PLUGIN_LIB_NAME.data()};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.cppindex 5ad847a3220..5a81b992b12 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@@ -19,115 +19,34 @@namespace {-constexpr uint32_t maxNumOfOptimalInferRequests = 8u;--const std::vector<std::string> optimizationCapabilities = {- ov::device::capability::FP16,- ov::device::capability::INT8,- ov::device::capability::EXPORT_IMPORT,-};--// Provides a hint for a range for number of async infer requests (bottom bound, upper bound, step)-const std::tuple<uint32_t, uint32_t, uint32_t> rangeForAsyncInferRequests{1u, maxNumOfOptimalInferRequests, 1u};--// Provides information about a range for streams (bottom bound, upper bound)-const std::tuple<uint32_t, uint32_t> rangeForStreams{0u, maxNumOfOptimalInferRequests};--std::map<std::string, std::string> any_copy(const ov::AnyMap& params) {- std::map<std::string, std::string> result;- for (auto&& value : params) {- result.emplace(value.first, value.second.as<std::string>());- }- return result;-}--inline bool isSpecialBothProperty(const std::string& key) {- return key == ov::hint::performance_mode.name() || key == ov::enable_profiling.name() ||- key == ov::log::level.name();-}--inline void logCpuPinningDeprecationWarning(intel_npu::Logger& logger) {+void logCpuPinningDeprecationWarning(intel_npu::Logger& logger) {OPENVINO_SUPPRESS_DEPRECATED_STARTlogger.warning(intel_npu::ENABLE_CPU_PINNING::deprecationMessage());OPENVINO_SUPPRESS_DEPRECATED_END}-void filterPropertiesByCompilerSupport(intel_npu::FilteredConfig& config,- ov::intel_npu::CompilerType compilerType,- intel_npu::CompilerOptionSupportHelper& optionSupportHelper,- const ov::SoPtr<intel_npu::IEngineBackend>& backend,- const intel_npu::Logger& logger) {- using namespace intel_npu;-- config.walkEnables([&](const std::string& key) {- // Special case for some both configs. Don't need compiler for these Both properties.- // Runtime (plugin-only) options are always enabled- if (config.getOpt(key).mode() != OptionMode::RunTime && !isSpecialBothProperty(key)) {- bool isEnabled = optionSupportHelper.isOptionSupported(compilerType, key, std::nullopt);- if (!isEnabled) {- logger.debug("Config option %s not supported! Requirements not met.", key.c_str());- } else {- logger.debug("Enabled config option %s", key.c_str());- }-- // update enable flag- config.enable(key, isEnabled);- }- });-- // Special cases- // NPU_TURBO which might not be supported by compiler, but driver will still use it- // if it exists in config = driver supports it- // if compiler->is_option_supported is false = compiler doesn't support it and gets marked disabled by default logic- // however, if driver supports it, we still need it (and will skip giving it to compiler) = force-enable- if (backend && backend->isCommandQueueExtSupported()) {- config.enable(ov::intel_npu::turbo.name(), true);- }-- if (config.isAvailable(ov::intel_npu::enable_strides_for.name())) {- if (backend && backend->getGraphExtVersion() < ZE_MAKE_VERSION(1, 16)) {- logger.info("Config option %s not supported by the driver! Requirements not met.",- ov::intel_npu::enable_strides_for.name());- config.enable(ov::intel_npu::enable_strides_for.name(), false);- }- }-}--void disableCompilerProperties(intel_npu::FilteredConfig& config, const ov::SoPtr<intel_npu::IEngineBackend>& backend) {- using namespace intel_npu;-- config.walkEnables([&](const std::string& key) {- auto opt = config.getOpt(key);- // Special case for some both configs. Don't need compiler for these Both properties.- // Runtime (plugin-only) options are always enabled- if (opt.mode() != OptionMode::RunTime && !isSpecialBothProperty(key)) {- // Disable all compiler options- config.enable(key, false);- }- });+struct ResolvedRequestContext {+ ov::intel_npu::CompilerType compilerType;+ std::string deviceId;+ std::string platform;+};- // Special cases- // NPU_TURBO might be supported by the driver- if (backend && backend->isCommandQueueExtSupported()) {- config.enable(ov::intel_npu::turbo.name(), true);- }-}+ResolvedRequestContext resolveRequestContext(const ov::AnyMap& arguments,+ ov::intel_npu::CompilerType defaultCompilerType,+ std::string defaultDeviceId,+ std::string defaultPlatform) {+ const auto compilerTypeIt = arguments.find(ov::intel_npu::compiler_type.name());+ const auto compilerType = compilerTypeIt == arguments.end()+ ? defaultCompilerType+ : ::intel_npu::COMPILER_TYPE::parse(compilerTypeIt->second.as<std::string>());-static auto get_specified_device_name(const intel_npu::Config& config) {- if (config.has<intel_npu::DEVICE_ID>()) {- return config.get<intel_npu::DEVICE_ID>();- }- return std::string();-}+ const auto deviceIdIt = arguments.find(std::string(ov::device::id.name()));+ auto deviceId = deviceIdIt == arguments.end() ? std::move(defaultDeviceId) : deviceIdIt->second.as<std::string>();-void exclude_model_ptr_from_map(ov::AnyMap& properties) {- if (properties.count(ov::hint::model.name())) {- properties.erase(ov::hint::model.name());- }-}+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ auto platform = platformIt == arguments.end() ? std::move(defaultPlatform) : platformIt->second.as<std::string>();-std::vector<std::string> getAvailableDevicesNames(const ov::SoPtr<intel_npu::IEngineBackend>& backend) {- return backend == nullptr ? std::vector<std::string>() : backend->getDeviceNames();+ return {compilerType, std::move(deviceId), std::move(platform)};}bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& backend,@@ -146,8 +65,7 @@ bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& b// Fallback to plugin compiler support check routed through the option support helper.try {return optionSupportHelper.isOptionSupported(ov::intel_npu::CompilerType::PLUGIN,- ov::compatibility_check.name(),- std::nullopt);+ ov::compatibility_check.name());} catch (...) {return false;}@@ -207,738 +125,296 @@ ov::CompatibilityCheck validateCompatibilityDescriptor(const ov::SoPtr<intel_npunamespace intel_npu {-PluginPropertyManager::PluginPropertyManager(const FilteredConfig& config,+PluginPropertyManager::PluginPropertyManager(const std::shared_ptr<OptionsDesc>& options,const ov::SoPtr<IEngineBackend>& backend,const std::shared_ptr<CompilerOptionSupportHelper>& optionSupportHelper,Logger& logger)- : _config(config),+ : _config(options),_backend(backend),_compilerOptionSupportHelper(optionSupportHelper),_logger(logger) {- registerProperties();-}--PluginPropertyManager::PluginPropertyManager(const PluginPropertyManager& other)- : PluginPropertyManager([&other]() {- std::lock_guard<std::mutex> lock(other._mutex);- return CopyState{other._config,- other._backend,- other._compilerOptionSupportHelper,- other._logger,- other._currentlyUsedCompiler,- other._compilerForCompatibilityCheck,- other._compatibilityCheckSupported,- other._currentlyUsedPlatform,- other._compilerConfigsFilteredByCompiler,- other._compatibilityCheckFiltered};- }()) {}--PluginPropertyManager::PluginPropertyManager(CopyState&& state)- : _config(std::move(state.config)),- _backend(std::move(state.backend)),- _compilerOptionSupportHelper(std::move(state.optionSupportHelper)),- _logger(state.logger),- _currentlyUsedCompiler(state.currentlyUsedCompiler),- _compilerForCompatibilityCheck(state._compilerForCompatibilityCheck),- _compatibilityCheckSupported(state.compatibilityCheckSupported),- _currentlyUsedPlatform(std::move(state.currentlyUsedPlatform)),- _compilerConfigsFilteredByCompiler(state.compilerConfigsFilteredByCompiler),- _compatibilityCheckFiltered(state.compatibilityCheckFiltered) {- registerProperties();-}--void PluginPropertyManager::registerProperties() const {- _properties.clear();- _supportedProperties.clear();-- // clang-format off- try_register_property_based_on_config<PERF_COUNT>(_config, _properties, ov::enable_profiling.name());- try_register_property_based_on_config<PERFORMANCE_HINT>(_config, _properties, ov::hint::performance_mode.name());- try_register_property_based_on_config<EXECUTION_MODE_HINT>(_config, _properties, ov::hint::execution_mode.name());- try_register_property_based_on_config<PERFORMANCE_HINT_NUM_REQUESTS>(_config, _properties, ov::hint::num_requests.name());- try_register_property_based_on_config<COMPILATION_NUM_THREADS>(_config, _properties, ov::compilation_num_threads.name());- try_register_property_based_on_config<INFERENCE_PRECISION_HINT>(_config, _properties, ov::hint::inference_precision.name());- try_register_property_based_on_config<LOG_LEVEL>(_config, _properties, ov::log::level.name());- try_register_property_based_on_config<CACHE_DIR>(_config, _properties, ov::cache_dir.name());- try_register_property_based_on_config<CACHE_MODE>(_config, _properties, ov::cache_mode.name());- try_register_property_based_on_config<COMPILED_BLOB>(_config, _properties, ov::hint::compiled_blob.name());- try_register_property_based_on_config<DEVICE_ID>(_config, _properties, ov::device::id.name());- try_register_property_based_on_config<NUM_STREAMS>(_config, _properties, ov::num_streams.name());- try_register_property_based_on_config<WEIGHTS_PATH>(_config, _properties, ov::weights_path.name());- try_register_property_based_on_config<COMPILATION_MODE_PARAMS>(_config, _properties, ov::intel_npu::compilation_mode_params.name());- try_register_property_based_on_config<DMA_ENGINES>(_config, _properties, ov::intel_npu::dma_engines.name());- try_register_property_based_on_config<TILES>(_config, _properties, ov::intel_npu::tiles.name());- try_register_property_based_on_config<COMPILATION_MODE>(_config, _properties, ov::intel_npu::compilation_mode.name());- try_register_property_based_on_config<COMPILER_TYPE>(_config, _properties, ov::intel_npu::compiler_type.name());- try_register_property_based_on_config<PLATFORM>(_config, _properties, ov::intel_npu::platform.name());- try_register_property_based_on_config<CREATE_EXECUTOR>(_config, _properties, ov::intel_npu::create_executor.name());- try_register_property_based_on_config<DYNAMIC_SHAPE_TO_STATIC>(_config, _properties, ov::intel_npu::dynamic_shape_to_static.name());- try_register_property_based_on_config<PROFILING_TYPE>(_config, _properties, ov::intel_npu::profiling_type.name());- try_register_property_based_on_config<BACKEND_COMPILATION_PARAMS>(_config, _properties, ov::intel_npu::backend_compilation_params.name());- try_register_property_based_on_config<BATCH_MODE>(_config, _properties, ov::intel_npu::batch_mode.name());- try_register_property_based_on_config<TURBO>(_config, _properties, ov::intel_npu::turbo.name());- try_register_property_based_on_config<MODEL_PRIORITY>(_config, _properties, ov::hint::model_priority.name());- try_register_property_based_on_config<BYPASS_UMD_CACHING>(_config, _properties, ov::intel_npu::bypass_umd_caching.name());- try_register_property_based_on_config<DEFER_WEIGHTS_LOAD>(_config, _properties, ov::intel_npu::defer_weights_load.name());- try_register_property_based_on_config<COMPILER_DYNAMIC_QUANTIZATION>(_config, _properties, ov::intel_npu::compiler_dynamic_quantization.name());- try_register_property_based_on_config<QDQ_OPTIMIZATION>(_config, _properties, ov::intel_npu::qdq_optimization.name());- try_register_property_based_on_config<QDQ_OPTIMIZATION_AGGRESSIVE>(_config, _properties, ov::intel_npu::qdq_optimization_aggressive.name());- try_register_property_based_on_config<DISABLE_VERSION_CHECK>(_config, _properties, ov::intel_npu::disable_version_check.name());- try_register_property_based_on_config<EXPORT_RAW_BLOB>(_config, _properties, ov::intel_npu::export_raw_blob.name());- try_register_property_based_on_config<IMPORT_RAW_BLOB>(_config, _properties, ov::intel_npu::import_raw_blob.name());- try_register_property_based_on_config<BATCH_COMPILER_MODE_SETTINGS>(_config, _properties, ov::intel_npu::batch_compiler_mode_settings.name());- OPENVINO_SUPPRESS_DEPRECATED_START- try_register_property_based_on_config<ENABLE_CPU_PINNING>(_config, _properties, ov::hint::enable_cpu_pinning.name());- OPENVINO_SUPPRESS_DEPRECATED_END- try_register_property_based_on_config<WORKLOAD_TYPE>(_config, _properties, ov::workload_type.name());- try_register_property_based_on_config<ENABLE_WEIGHTLESS>(_config, _properties, ov::enable_weightless.name());- try_register_property_based_on_config<SEPARATE_WEIGHTS_VERSION>(_config, _properties, ov::intel_npu::separate_weights_version.name());- try_register_property_based_on_config<MODEL_SERIALIZER_VERSION>(_config, _properties, ov::intel_npu::model_serializer_version.name());- try_register_property_based_on_config<ENABLE_STRIDES_FOR>(_config, _properties, ov::intel_npu::enable_strides_for.name());- try_register_property_based_on_config<DISABLE_IDLE_MEMORY_PRUNING>(_config, _properties, ov::intel_npu::disable_idle_memory_prunning.name());- try_register_property_based_on_config<SHARED_COMMON_QUEUE>(_config, _properties, ov::intel_npu::shared_common_queue.name());-- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::intel_npu::stepping.name(), [&](const Config& config) {- if (!config.has<STEPPING>()) {- try {- const auto specifiedDeviceName = get_specified_device_name(config);- return static_cast<int64_t>(utils::getSteppingNumber(_backend, specifiedDeviceName));- } catch (...) {- _logger.warning("getSteppingNumber failed to get value from device.");- }- }- return config.get<STEPPING>();- });- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::intel_npu::max_tiles.name(), [&](const Config& config) {- if (!config.has<MAX_TILES>()) {- try {- const auto specifiedDeviceName = get_specified_device_name(config);- return static_cast<int64_t>(utils::getMaxTiles(_backend, specifiedDeviceName));- } catch (...) {- _logger.warning("getMaxTiles failed to get value from device.");- }- }- return config.get<MAX_TILES>();- });- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::cache_encryption_callbacks.name(), [](const Config&) {- return ov::EncryptionCallbacks{nullptr, nullptr};- });- try_register_property_based_on_config_with_custom_function(_config, _properties, ov::intel_npu::compile_log_level.name(),- [](const Config& config) -> ov::Any { return COMPILE_LOG_LEVEL::resolve(config); });- // clang-format on-- // Special case: this property is always registered because it's supported by the implementation,- // but it's not visible in supported_properties if the driver doesn't support it.- try_register_property_based_on_config_with_visibility<RUN_INFERENCES_SEQUENTIALLY>(- _config,- _properties,- ov::intel_npu::run_inferences_sequentially.name(),- [&] {- if (_backend && _backend->getInitStructs()) {- if (_backend->getInitStructs()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {- return true;- }- }- return false;- }());-- for_each_exposed_npuw_option([&](auto tag) {- using Opt = typename decltype(tag)::type;- try_register_npuw_option_property<Opt>(_config, _properties);- });-- // clang-format off- register_property_with_custom_function(_properties, ov::available_devices.name(), true, [&](const Config&) {- return getAvailableDevicesNames(_backend);- });- register_property_with_custom_function(_properties, ov::device::capabilities.name(), true, [&](const Config&) {- return optimizationCapabilities;- });- register_property_with_custom_function(_properties, ov::range_for_async_infer_requests.name(), true, [&](const Config&) {- return rangeForAsyncInferRequests;- });- register_property_with_custom_function(_properties, ov::range_for_streams.name(), true, [&](const Config&) {- return rangeForStreams;- });- register_property_with_custom_function(_properties, ov::device::pci_info.name(), true, [&](const Config& config) {- return utils::getPciInfo(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::device::gops.name(), true, [&](const Config& config) {- return utils::getGops(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::device::type.name(), true, [&](const Config& config) {- return utils::getDeviceType(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::intel_npu::device_alloc_mem_size.name(), true, [&](const Config& config) {- return utils::getDeviceAllocMemSize(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::intel_npu::device_total_mem_size.name(), true, [&](const Config& config) {- return utils::getDeviceTotalMemSize(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::intel_npu::driver_version.name(), true, [&](const Config&) {- if (_backend == nullptr) {- OPENVINO_THROW("No available backend");- }-- return _backend->getDriverVersion();- });- register_property_with_custom_function(_properties, ov::device::uuid.name(), true, [&](const Config& config) {- auto devUuid = utils::getDeviceUuid(_backend, get_specified_device_name(config));- return decltype(ov::device::uuid)::value_type{devUuid};- });- register_property_with_custom_function(_properties, ov::device::luid.name(), _backend == nullptr ? false : _backend->isLUIDExtSupported(), [&](const Config& config) {- return utils::getDeviceLUID(_backend, get_specified_device_name(config));- });- register_property_with_custom_function(_properties, ov::execution_devices.name(), true, [&](const Config& config) {- if (getAvailableDevicesNames(_backend).size() > 1) {- return std::string("NPU." + config.get<DEVICE_ID>());- }- return std::string("NPU");- });- register_property_with_custom_function(_properties, ov::intel_npu::backend_name.name(), false, [&](const Config&) {- if (_backend == nullptr) {- OPENVINO_THROW("No available backend");- }- return _backend->getName();- });-- try_register_property_with_custom_function(_properties, ov::device::architecture.name(), !getAvailableDevicesNames(_backend).empty(), true, [&](const Config& config) {- return utils::getDeviceArchitecture(_backend, get_specified_device_name(config));- });- try_register_property_with_custom_function(_properties, ov::device::full_name.name(), !getAvailableDevicesNames(_backend).empty(), true, [&](const Config& config) {- return utils::getFullDeviceName(_backend, get_specified_device_name(config));- });-- register_property_with_custom_function(_properties, ov::hint::model.name(), true, [](const Config&) {- return std::shared_ptr<const ov::Model>(nullptr);- });- register_property_with_custom_function(_properties, ov::optimal_number_of_infer_requests.name(), true, [&](const Config& config) {- return utils::getOptimalNumberOfInferRequestsInParallel(- utils::getCompilationPlatform(- config.get<PLATFORM>(),- _backend == nullptr ? config.get<DEVICE_ID>()- : _backend->getDevice(config.get<DEVICE_ID>())->getName(),- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames()),- config.get<PERFORMANCE_HINT>());- });- register_property_with_custom_function(_properties, ov::intel_npu::compiler_version.name(), true, [&](const Config& config) {- auto compilerType = config.get<COMPILER_TYPE>();- auto deviceId = config.get<DEVICE_ID>();- auto device = utils::getDeviceById(_backend, deviceId);-- auto compilationPlatform = utils::getCompilationPlatform(- config.get<PLATFORM>(),- device == nullptr ? std::move(deviceId) : device->getName(),- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());-- CompilerAdapterFactory factory;- auto dummyCompiler = factory.getCompiler(_backend, compilerType, compilationPlatform);+ if (_backend == nullptr) {+ _logger.info("No backend is available. Backend/device-dependent properties will be unavailable.");+ }- return dummyCompiler->get_version();- });- register_property_with_custom_function(_properties, ov::internal::supported_properties.name(), false, [&](const Config&) {- return _internalSupportedProperties;- });- register_property_with_custom_function(_properties, ov::internal::cache_header_alignment.name(), false, [&](const Config&) {- return utils::STANDARD_PAGE_SIZE;- });- register_property_with_custom_function(_properties, ov::internal::caching_properties.name(), false, [&](const Config&) {- std::vector<ov::PropertyName> caching_props{};- for (auto prop : _cachingProperties) {- if (_config.isAvailable(prop)) {- caching_props.emplace_back(prop);+ _config.parseEnvVars();+ if (_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && _backend != nullptr) {+ auto device = _backend->getDevice();+ if (device) {+ auto platformName = device->getName();+ CompilerAdapterFactory compilerFactory;+ auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);+ if (compileType == ov::intel_npu::CompilerType::DRIVER) {+ _config.update(ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType));}}- for (auto prop : _cachingProperties) {- if (prop.find("NPUW") != prop.npos) {- caching_props.emplace_back(prop);- }- }- return caching_props;- });- register_property_with_custom_function(_properties, ov::supported_properties.name(), true, [&](const Config&) {- return _supportedProperties;- });- // clang-format on-- try_register_property_with_custom_function_and_args(- _properties,- ov::compatibility_check.name(),- _compatibilityCheckFiltered && _compatibilityCheckSupported,- true,- [this](const Config&, const ov::AnyMap& arguments) {- return validateCompatibilityDescriptor(_backend, arguments, *_compilerOptionSupportHelper);- });-- for (auto& property : _properties) {- if (property.second.isPublic) {- _supportedProperties.emplace_back(ov::PropertyName(property.first, property.second.mutability));- }}-}-void PluginPropertyManager::initializeCompatibilityCheckSupportIfNeeded() const {- if (_compatibilityCheckFiltered) {- return;- }-- _compatibilityCheckSupported = isCompatibilityCheckSupported(_backend, *_compilerOptionSupportHelper);- _compatibilityCheckFiltered = true;-- const auto compatibilityCheckName = std::string(ov::compatibility_check.name());-- // Keep only one descriptor for this property and update it after the one-time probe.- _properties.erase(compatibilityCheckName);-- try_register_property_with_custom_function_and_args(- _properties,- compatibilityCheckName,- _compatibilityCheckSupported,- true,- [this](const Config&, const ov::AnyMap& arguments) {- return validateCompatibilityDescriptor(_backend, arguments, *_compilerOptionSupportHelper);- });-- // Update supported_properties incrementally for compatibility_check only.- _supportedProperties.erase(- std::remove(_supportedProperties.begin(), _supportedProperties.end(), compatibilityCheckName),- _supportedProperties.end());- if (_compatibilityCheckSupported) {- _supportedProperties.emplace_back(ov::PropertyName(compatibilityCheckName, ov::PropertyMutability::RO));- }+ registerProperties();}void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {std::lock_guard<std::mutex> lock(_mutex);- auto resolveCompilerTypeWithoutLock = [&](const ov::AnyMap& propertyMap) {- auto compilerTypeIt = propertyMap.find(ov::intel_npu::compiler_type.name());- if (compilerTypeIt != propertyMap.end()) {- return COMPILER_TYPE::parse(compilerTypeIt->second.as<std::string>());- }- return _config.get<COMPILER_TYPE>();- };-- auto resolveDeviceIdWithoutLock = [&](const ov::AnyMap& propertyMap) {- auto deviceIdIt = propertyMap.find(std::string(ov::device::id.name()));- if (deviceIdIt != propertyMap.end()) {- return deviceIdIt->second.as<std::string>();- }- return _config.get<DEVICE_ID>();- };-- auto resolvePlatformWithoutLock = [&](const ov::AnyMap& propertyMap) {- auto platformIt = propertyMap.find(ov::intel_npu::platform.name());- if (platformIt != propertyMap.end()) {- return platformIt->second.as<std::string>();- }- return _config.get<PLATFORM>();- };-- if (properties.find(ov::compatibility_check.name()) != properties.end()) {- initializeCompatibilityCheckSupportIfNeeded();- }-if (properties.find(ov::hint::enable_cpu_pinning.name()) != properties.end()) {logCpuPinningDeprecationWarning(_logger);}- std::unique_ptr<ICompilerAdapter> compiler = nullptr;- bool propertyIsCompilerConfig = false;- bool propertyIsRegistered = true;- for (const auto& property : properties) {- if (!isPropertyRegistered(property.first)) {- propertyIsRegistered = false;- break;- }- // Special case for some both configs. Don't need to check compiler support for these Both properties.- const bool isNotSpecialBothProperty = !isSpecialBothProperty(property.first);- if (_config.hasOpt(property.first) && isNotSpecialBothProperty) {- auto opt = _config.getOpt(property.first);- if (opt.mode() != OptionMode::RunTime) {- propertyIsCompilerConfig = true;- break;- }- }- }-- // Check if one of the properties is compiler config which needs to return different values based on compiler- // and platform configuration- if (propertyIsCompilerConfig || !propertyIsRegistered) {- auto compilerType = resolveCompilerTypeWithoutLock(properties);- auto deviceId = resolveDeviceIdWithoutLock(properties);- auto device = utils::getDeviceById(_backend, deviceId);-- auto compilationPlatform = utils::getCompilationPlatform(- resolvePlatformWithoutLock(properties),- device == nullptr ? std::move(deviceId) : device->getName(),- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());-- // Create a compiler to get the type and fetch version and supported options if needed- CompilerAdapterFactory factory;- compiler = factory.getCompiler(_backend,- compilerType,- compilationPlatform,- _compilerOptionSupportHelper->getOptionSupportCache());-- if (!(_compilerConfigsFilteredByCompiler && compilerType == _currentlyUsedCompiler &&- compilationPlatform == _currentlyUsedPlatform)) {- // In case properties are not initialized or the compiler/platform was changed since last call -- // filter out options again- filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);-- // reset properties for the new options- registerProperties();- _compilerConfigsFilteredByCompiler = true;- _currentlyUsedCompiler = compilerType;- _currentlyUsedPlatform = std::move(compilationPlatform);- }- }+ auto normalizedArguments = resolveRequestContext(properties,+ _config.get<COMPILER_TYPE>(),+ _config.get<DEVICE_ID>(),+ _config.get<PLATFORM>());+ ov::AnyMap supportCheckArguments = {+ {ov::intel_npu::compiler_type.name(), normalizedArguments.compilerType},+ {ov::device::id.name(), normalizedArguments.deviceId},+ {ov::intel_npu::platform.name(), normalizedArguments.platform},+ };- std::map<std::string, std::string> cfgs_to_set;- ov::AnyMap special_cfgs_to_set;for (auto&& value : properties) {- if (_properties.find(value.first) == _properties.end()) {+ const auto propertyDescriptorIt = _properties.find(value.first);+ if (propertyDescriptorIt == _properties.end()) {// property doesn't exist - checking as internal now+ const auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,+ normalizedArguments.deviceId,+ normalizedArguments.platform);+ OPENVINO_ASSERT(resolvedCompilerType.has_value(), "Unsupported configuration key: ", value.first);bool isSupported = false;try {isSupported =- _compilerOptionSupportHelper->isOptionSupported(_currentlyUsedCompiler, value.first, std::nullopt);+ _compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType.value(), value.first);} catch (...) {// ignore any exceptions from the compiler and treat the property as unsupportedisSupported = false;}- if (!isSupported) {- OPENVINO_THROW("Unsupported configuration key: ", value.first);- }+ OPENVINO_ASSERT(isSupported, "Unsupported configuration key: ", value.first);+ } else {+ const auto& descriptor = propertyDescriptorIt->second;+ OPENVINO_ASSERT(descriptor.mutability != ov::PropertyMutability::RO,+ "READ-ONLY configuration key: ",+ value.first);+ OPENVINO_ASSERT(descriptor.isSupported(supportCheckArguments),+ "Unsupported configuration key: ",+ value.first);+ }+ }+ for (auto&& value : properties) {+ const auto propertyDescriptorIt = _properties.find(value.first);+ if (propertyDescriptorIt == _properties.end()) {// if compiler reports it supported > registering as internal_config.addOrUpdateInternal(value.first, value.second.as<std::string>());} else {- if (_properties[value.first].mutability == ov::PropertyMutability::RO) {- OPENVINO_THROW("READ-ONLY configuration key: ", value.first);- } else if (value.first == ov::cache_encryption_callbacks.name()) {- special_cfgs_to_set.emplace(value.first, value.second);- } else {- cfgs_to_set.emplace(value.first, value.second.as<std::string>());- }+ propertyDescriptorIt->second.set(value.second);}}-- if (!cfgs_to_set.empty()) {- _config.update(cfgs_to_set);- }- if (!special_cfgs_to_set.empty()) {- _config.updateAny(special_cfgs_to_set);- }}ov::Any PluginPropertyManager::getProperty(const std::string& name, const ov::AnyMap& arguments) const {- if (!arguments.empty() && name != ov::compatibility_check.name()) {- auto pluginArguments = arguments;- exclude_model_ptr_from_map(pluginArguments);-- auto copyProperties = PluginPropertyManager(*this);- copyProperties.setProperty(pluginArguments);- return copyProperties.getProperty(name);- }-+ auto propertyArguments = arguments;std::lock_guard<std::mutex> lock(_mutex);if (name == ov::hint::enable_cpu_pinning.name()) {logCpuPinningDeprecationWarning(_logger);}- if (name == ov::supported_properties.name() || name == ov::compatibility_check.name()) {- initializeCompatibilityCheckSupportIfNeeded();- }-- bool propertyIsCompilerConfig = false;- bool propertyIsRegistered = true;- // If the property is not registered, there is no point of checking the config.- if (!isPropertyRegistered(name)) {- propertyIsRegistered = false;- } else if (_config.hasOpt(name) && !isSpecialBothProperty(name)) {- // Property is already registered but need to re-check if the CompilerTime config is still supported by the- // current compiler.- auto opt = _config.getOpt(name);- if (opt.mode() != OptionMode::RunTime) {- propertyIsCompilerConfig = true;- }- }-- // Special case for Supported Properties and Caching Properties as they are compiler dependent. So we need to- // check compiler support for those properties on each getProperty call as well.- if (propertyIsCompilerConfig || !propertyIsRegistered || name == ov::supported_properties.name() ||- name == ov::internal::caching_properties.name()) {- std::unique_ptr<ICompilerAdapter> compiler = nullptr;- auto compilerType = _config.get<COMPILER_TYPE>();- auto deviceId = _config.get<DEVICE_ID>();- auto device = utils::getDeviceById(_backend, deviceId);-- auto compilationPlatform = utils::getCompilationPlatform(- _config.get<PLATFORM>(),- device == nullptr ? std::move(deviceId) : device->getName(),- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());-- // Create a compiler to get the type and fetch version and supported options if needed- CompilerAdapterFactory factory;- try {- compiler = factory.getCompiler(_backend,- compilerType,- compilationPlatform,- _compilerOptionSupportHelper->getOptionSupportCache());- } catch (const std::exception& ex) {- if (_config.hasOpt(name) && _config.getOpt(name).mode() == OptionMode::CompileTime) {- OPENVINO_THROW("Failed to create compiler for getting property ", name, " with error: ", ex.what());- }-- _logger.warning("Failed to create compiler for getting property %s with error: %s."- "Returning only runtime properties and metrics that do not require compiler support.",- name.c_str(),- ex.what());- }-- if (compiler != nullptr && !(_compilerConfigsFilteredByCompiler && compilerType == _currentlyUsedCompiler &&- compilationPlatform == _currentlyUsedPlatform)) {- // In case properties are not initialized or the compiler/platform was changed since last call -- // filter out options again- filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);-- // reset properties for the new options- registerProperties();- _compilerConfigsFilteredByCompiler = true;- _currentlyUsedCompiler = compilerType;- _currentlyUsedPlatform = std::move(compilationPlatform);- }- }-- auto&& configIterator = _properties.find(name);- if (configIterator != _properties.cend()) {- if (configIterator->second.mutability == ov::PropertyMutability::WO) {+ auto normalizedArguments = resolveRequestContext(arguments,+ _config.get<COMPILER_TYPE>(),+ _config.get<DEVICE_ID>(),+ _config.get<PLATFORM>());+ propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;+ propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;+ propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;++ const auto propertyDescriptorIt = _properties.find(name);+ if (propertyDescriptorIt != _properties.cend()) {+ OPENVINO_ASSERT(propertyDescriptorIt->second.isSupported(propertyArguments),+ "Unsupported configuration key: ",+ name);+ if (propertyDescriptorIt->second.mutability == ov::PropertyMutability::WO) {_logger.warning("Trying to get WRITE-ONLY property: %s. Returning empty `ov::Any` object", name.c_str());return ov::Any();}- // Check if property requires arguments- if (configIterator->second.getWithArgs) {- return configIterator->second.getWithArgs(_config, arguments);- }- return configIterator->second.get(_config);+ return propertyDescriptorIt->second.get(propertyArguments);}- try {- return _config.getInternal(name);- } catch (...) {- OPENVINO_THROW("Unsupported configuration key: ", name);- }-}--bool PluginPropertyManager::isPropertySupported(const std::string& name, const ov::AnyMap& arguments) const {- if (!arguments.empty() && name != ov::compatibility_check.name()) {- auto pluginArguments = arguments;- exclude_model_ptr_from_map(pluginArguments);- auto copyProperties = PluginPropertyManager(*this);+ if (_config.hasInternal(name)) {+ auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,+ normalizedArguments.deviceId,+ normalizedArguments.platform);+ OPENVINO_ASSERT(resolvedCompilerType.has_value(), "Unsupported configuration key: ", name);try {- copyProperties.setProperty(pluginArguments);+ if (_compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType.value(), name)) {+ return _config.getInternal(name);+ }} catch (...) {- return false;}-- return copyProperties.isPropertySupported(name);}+ OPENVINO_THROW("Unsupported configuration key: ", name);+}+bool PluginPropertyManager::isPropertySupported(const std::string& name, const ov::AnyMap& arguments) const {+ auto propertyArguments = arguments;std::lock_guard<std::mutex> lock(_mutex);+if (name == ov::hint::enable_cpu_pinning.name()) {logCpuPinningDeprecationWarning(_logger);}- if (name == ov::compatibility_check.name()) {- initializeCompatibilityCheckSupportIfNeeded();- }-- const bool isRegistered = isPropertyRegistered(name);- const bool isConfigOption = _config.hasOpt(name);-- if (!isRegistered && !isConfigOption) {- // Property is neither registered nor known by config+ const auto propertyDescriptorIt = _properties.find(name);+ if (propertyDescriptorIt == _properties.end()) {+ // Property not found in the known properties list.return false;}- if (isRegistered) {- const auto it = _properties.find(name);- return it->second.isPublic;- }-- // Property is compiler config, need to check compiler support- std::unique_ptr<ICompilerAdapter> compiler = nullptr;- auto compilerType = _config.get<COMPILER_TYPE>();- auto deviceId = _config.get<DEVICE_ID>();- auto device = utils::getDeviceById(_backend, deviceId);-- auto compilationPlatform =- utils::getCompilationPlatform(_config.get<PLATFORM>(),- device == nullptr ? std::move(deviceId) : device->getName(),- _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());+ auto normalizedArguments = resolveRequestContext(arguments,+ _config.get<COMPILER_TYPE>(),+ _config.get<DEVICE_ID>(),+ _config.get<PLATFORM>());+ propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;+ propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;+ propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;- // Create a compiler to get the type and fetch version and supported options if needed- CompilerAdapterFactory factory;- try {- compiler = factory.getCompiler(_backend,- compilerType,- compilationPlatform,- _compilerOptionSupportHelper->getOptionSupportCache());- } catch (const std::exception& ex) {- if (_config.hasOpt(name) && _config.getOpt(name).mode() == OptionMode::CompileTime) {- return false;- }-- _logger.warning("Failed to create compiler to query property %s with error: %s. "- "Registering only runtime properties and metrics that do not require compiler support.",- name.c_str(),- ex.what());- }-- if (compiler != nullptr && !(_compilerConfigsFilteredByCompiler && compilerType == _currentlyUsedCompiler &&- compilationPlatform == _currentlyUsedPlatform)) {- // In case properties are not initialized or the compiler/platform was changed since last call -- // filter out options again- filterPropertiesByCompilerSupport(_config, compilerType, *_compilerOptionSupportHelper, _backend, _logger);-- // reset properties for the new options- registerProperties();- _compilerConfigsFilteredByCompiler = true;- _currentlyUsedCompiler = compilerType;- _currentlyUsedPlatform = std::move(compilationPlatform);- }-- const auto it = _properties.find(name);- return it != _properties.end() && it->second.isPublic;+ return propertyDescriptorIt->second.isPublic && propertyDescriptorIt->second.isSupported(propertyArguments);}-FilteredConfig PluginPropertyManager::getConfigWithCompilerPropertiesDisabled(const ov::AnyMap& properties) const {- auto [updatedConfig, compilerConfigsFilteredByCompiler, logger] = [&]() {- std::lock_guard<std::mutex> lock(_mutex);- return std::make_tuple(_config, _compilerConfigsFilteredByCompiler, _logger);- }();-- auto pluginProperties = properties;- exclude_model_ptr_from_map(pluginProperties);-- if (compilerConfigsFilteredByCompiler) {- disableCompilerProperties(updatedConfig, _backend);+std::pair<FilteredConfig, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownProperties(+ const ov::AnyMap& properties,+ ConfigMergeMode mergeMode) {+ bool loadedFromCache = false;+ if (mergeMode == ConfigMergeMode::Import) {+ // In case of importing a model, the loaded_from_cache property is used to determine whether the model was+ // loaded from cache or not. If the model was loaded from cache, we must check for internal compiler configs and+ // not send them to compiled model+ const auto loadedFromCacheIt = properties.find(std::string(ov::loaded_from_cache.name()));+ loadedFromCache = loadedFromCacheIt == properties.end() ? false : loadedFromCacheIt->second.as<bool>();}- if (pluginProperties.find(ov::hint::enable_cpu_pinning.name()) != pluginProperties.end()) {- logCpuPinningDeprecationWarning(logger);+ std::lock_guard<std::mutex> lock(_mutex);++ if (properties.find(ov::hint::enable_cpu_pinning.name()) != properties.end()) {+ logCpuPinningDeprecationWarning(_logger);}- if (pluginProperties.empty()) {- return std::move(updatedConfig);+ ov::AnyMap propertyArguments = properties;+ auto normalizedArguments = resolveRequestContext(properties,+ _config.get<COMPILER_TYPE>(),+ _config.get<DEVICE_ID>(),+ _config.get<PLATFORM>());+ if (mergeMode == ConfigMergeMode::Import) {+ // Make sure the compiler type is removed from the property arguments when importing a model with both+ // compile-time and runtime options to check only runtime availability.+ if (propertyArguments.find(ov::intel_npu::compiler_type.name()) != propertyArguments.end()) {+ _logger.warning("Property '%s' is used to specify the compiler type, will not be used for current "+ "configuration.",+ ov::intel_npu::compiler_type.name());+ propertyArguments.erase(ov::intel_npu::compiler_type.name());+ }+ } else {+ propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;}+ propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;+ propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;- const std::map<std::string, std::string> rawConfig = any_copy(pluginProperties);- std::map<std::string, std::string> cfgsToSet;- ov::AnyMap specialCfgsToSet;- for (const auto& [key, value] : rawConfig) {- if (updatedConfig.hasOpt(key)) {- const auto optionMode = updatedConfig.getOpt(key).mode();+ ov::AnyMap unknownProperties;+ auto updatedConfig = _config;+ for (auto&& value : properties) {+ const auto& key = value.first;+ const auto propertyDescriptorIt = _properties.find(key);++ if (propertyDescriptorIt == _properties.end()) {+ // Property doesn't exist.+ if (mergeMode != ConfigMergeMode::Import || loadedFromCache) {+ // Check whether the compiler supports it as an internal option. Don't check it when user is importing a+ // model and the model was not loaded from cache, as compile-time-only options are not relevant in that+ // case.+ bool isSupportedByCompiler = false;+ const auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,+ normalizedArguments.deviceId,+ normalizedArguments.platform);+ if (resolvedCompilerType.has_value()) {+ try {+ isSupportedByCompiler =+ _compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType.value(), key);+ } catch (...) {+ // ignore any exceptions from the compiler and treat the property as unsupported+ isSupportedByCompiler = false;+ }+ }- if (optionMode == OptionMode::CompileTime) {- logger.info(- "Config key '%s' is recognized as a compiler option, will not be used for current configuration.",- key.c_str());- continue;- }+ if (isSupportedByCompiler) {+ if (mergeMode == ConfigMergeMode::Import) {+ // Compile-time-only options are not relevant when no compiler config is being built.+ warnCompilerOnlyOptionSkipped(key);+ continue;+ }+ // Compiler supports this option, add it as an internal property.+ updatedConfig.addOrUpdateInternal(key, value.second.as<std::string>());+ continue;+ }- if (optionMode == OptionMode::Both && !updatedConfig.isAvailable(key)) {- logger.info("Config key '%s' is not enabled by the plugin, will not be used for current configuration.",- key.c_str());- continue;+ OPENVINO_ASSERT(mergeMode != ConfigMergeMode::Query, "Unsupported configuration key: ", key);}- }- if (key == ov::cache_encryption_callbacks.name()) {- specialCfgsToSet.emplace(key, pluginProperties.at(key));- } else {- cfgsToSet.emplace(key, value);+ // property doesn't exist, send it as it is to compiled model anyway, it may be used by compiled model+ _logger.info("Property '%s' is unknown to the plugin property manager, will be sent to the compiled model.",+ key.c_str());+ unknownProperties.emplace(key, value.second);+ continue;}- }-- updatedConfig.update(cfgsToSet);- updatedConfig.updateAny(specialCfgsToSet);- return std::move(updatedConfig);-}+ // If the property exists, check its mutability before allowing any modifications in the config.+ // If the property doesn't exist, it is considered mutable by default.+ OPENVINO_ASSERT(propertyDescriptorIt->second.mutability != ov::PropertyMutability::RO,+ "READ-ONLY configuration key: ",+ key);-FilteredConfig PluginPropertyManager::getConfigForSpecificCompiler(const ov::AnyMap& properties) const {- auto [updatedConfig, compilerConfigsFilteredByCompiler, currentlyUsedCompiler, currentlyUsedPlatform, logger] =- [&]() {- std::lock_guard<std::mutex> lock(_mutex);- return std::make_tuple(_config,- _compilerConfigsFilteredByCompiler,- _currentlyUsedCompiler,- _currentlyUsedPlatform,- _logger);- }();+ if (!updatedConfig.hasOpt(key)) {+ OPENVINO_ASSERT(propertyDescriptorIt->second.isSupported(propertyArguments),+ "[ NOT_FOUND ] Option '",+ key,+ "' is not supported for current configuration");- if (properties.find(ov::hint::enable_cpu_pinning.name()) != properties.end()) {- logCpuPinningDeprecationWarning(logger);- }+ OPENVINO_THROW("Property '", key, "' can be set only through 'set_property' method");+ }- auto pluginProperties = properties;- exclude_model_ptr_from_map(pluginProperties);+ if (mergeMode == ConfigMergeMode::Import && updatedConfig.getOpt(key).mode() == OptionMode::CompileTime) {+ // Compile-time-only options are not relevant when importing a model, skip them.+ warnCompilerOnlyOptionSkipped(key);+ continue;+ }- std::optional<ov::intel_npu::CompilerType> propertiesCompilerType = std::nullopt;- std::optional<std::string> propertiesPlatform = std::nullopt;- auto compilerType = pluginProperties.find(ov::intel_npu::compiler_type.name());- if (compilerType != pluginProperties.end()) {- propertiesCompilerType = compilerType->second.as<ov::intel_npu::CompilerType>();- }- auto platform = pluginProperties.find(ov::intel_npu::platform.name());- if (platform != pluginProperties.end()) {- propertiesPlatform = platform->second.as<std::string>();- }+ if (!propertyDescriptorIt->second.isSupported(propertyArguments)) {+ // In case of both property is import to not throw an error if they are not supported by the device but may+ // be by the compiler.+ if (mergeMode == ConfigMergeMode::Import && updatedConfig.getOpt(key).mode() == OptionMode::Both) {+ warnCompilerOnlyOptionSkipped(key);+ continue;+ }- const auto effectiveCompilerType = propertiesCompilerType.value_or(currentlyUsedCompiler);- if (!(compilerConfigsFilteredByCompiler && effectiveCompilerType == currentlyUsedCompiler &&- propertiesPlatform.value_or(currentlyUsedPlatform) == currentlyUsedPlatform)) {- // In case the compiler properties are not initialized or the compiler/platform was changed since last call -- // filter out options again- filterPropertiesByCompilerSupport(updatedConfig,- effectiveCompilerType,- *_compilerOptionSupportHelper,- _backend,- logger);- }+ OPENVINO_THROW("[ NOT_FOUND ] Option '", key, "' is not supported for current configuration");+ }- const std::map<std::string, std::string> rawConfig = any_copy(pluginProperties);- std::map<std::string, std::string> cfgsToSet;- ov::AnyMap specialCfgsToSet;- for (const auto& [key, value] : rawConfig) {- if (!updatedConfig.hasOpt(key)) {- // not a known config key- bool isSupported = false;- try {- isSupported = _compilerOptionSupportHelper->isOptionSupported(effectiveCompilerType, key, std::nullopt);- } catch (...) {- // ignore any exceptions from the compiler and treat the property as unsupported- isSupported = false;- }- if (!isSupported) {- OPENVINO_THROW("[ NOT_FOUND ] Option '", key, "' is not supported for current configuration");- }- updatedConfig.addOrUpdateInternal(key, value);+ if (key == ov::hint::model.name()) {+ const auto model = value.second.is<std::shared_ptr<const ov::Model>>()+ ? value.second.as<std::shared_ptr<const ov::Model>>()+ : std::shared_ptr<const ov::Model>(value.second.as<std::shared_ptr<ov::Model>>());+ updatedConfig.updateAny(key, std::weak_ptr<const ov::Model>(model));} else if (key == ov::cache_encryption_callbacks.name()) {- specialCfgsToSet.emplace(key, pluginProperties.at(key));+ updatedConfig.updateAny(key, value.second);} else {- cfgsToSet.emplace(key, value);+ updatedConfig.update(key, value.second.as<std::string>());}}- updatedConfig.update(cfgsToSet);- updatedConfig.updateAny(specialCfgsToSet);+ if (mergeMode == ConfigMergeMode::Import) {+ // Remove the compiler type from the updated configuration as it has been resolved and applied on the import+ // path. Shouldn't be used further in the stack.+ updatedConfig.remove(ov::intel_npu::compiler_type.name());+ // Remove all compile-time-only configurations as they are not relevant for the import path.+ updatedConfig.removeCompileTimeConfigs();+ }- return std::move(updatedConfig);+ return {std::move(updatedConfig), std::move(unknownProperties)};}std::string PluginPropertyManager::determinePlatform(const ov::AnyMap& properties) const {@@ -968,8 +444,592 @@ ov::intel_npu::CompilerType PluginPropertyManager::determineCompilerType(const oreturn _config.get<COMPILER_TYPE>();}-bool PluginPropertyManager::isPropertyRegistered(const std::string& propertyName) const {- return _properties.find(propertyName) != _properties.end();+std::optional<ov::intel_npu::CompilerType> PluginPropertyManager::resolveCompilerType(+ ov::intel_npu::CompilerType compilerType,+ const std::string& deviceId,+ const std::string& platform) const {+ if (compilerType != ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ return compilerType;+ }++ try {+ auto device = utils::getDeviceById(_backend, deviceId);+ auto compilationPlatform = utils::getCompilationPlatform(+ platform,+ device == nullptr ? deviceId : device->getName(),+ _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());++ CompilerAdapterFactory factory;+ factory.decideCompilerType(compilerType, device, compilationPlatform);+ return compilerType;+ } catch (const std::exception& ex) {+ _logger.warning("Failed to resolve compiler type: %s. Compiler-dependent properties will be unsupported.",+ ex.what());+ return std::nullopt;+ }+}++void PluginPropertyManager::warnCompilerOnlyOptionSkipped(const std::string& key) const {+ _logger.warning("Property '%s' is recognized as a compiler option, will not be used for current configuration.",+ key.c_str());+}++void PluginPropertyManager::registerProperties() {+ _properties.clear();++ const bool hasBackend = _backend != nullptr;+ const auto hasBackendPredicate = [hasBackend](const ov::AnyMap&) {+ return hasBackend;+ };++ // Guarded by PluginPropertyManager::_mutex, held by all call sites that invoke this predicate.+ auto hasBackendAndValidDeviceCache = std::make_shared<std::optional<std::pair<std::string, bool>>>();++ const auto getDeviceId = [](const ov::AnyMap& arguments) -> std::string {+ const auto deviceIdIt = arguments.find(ov::device::id.name());+ if (deviceIdIt != arguments.end()) {+ return deviceIdIt->second.as<std::string>();+ }+ return std::string();+ };++ const auto hasBackendAndValidDevice =+ [this, hasBackend, hasBackendAndValidDeviceCache, getDeviceId](const ov::AnyMap& arguments) {+ if (!hasBackend) {+ return false;+ }++ try {+ const auto specifiedDeviceName = getDeviceId(arguments);++ if (hasBackendAndValidDeviceCache->has_value() &&+ hasBackendAndValidDeviceCache->value().first == specifiedDeviceName) {+ return hasBackendAndValidDeviceCache->value().second;+ }++ const bool isValidDevice = utils::getDeviceById(_backend, specifiedDeviceName) != nullptr;++ *hasBackendAndValidDeviceCache = std::make_pair(specifiedDeviceName, isValidDevice);+ return isValidDevice;+ } catch (...) {+ _logger.debug("Property is not supported for current configuration due to unavailable device.");+ }++ return false;+ };++ auto getCompilerTypeOrDefault = [](const ov::AnyMap& arguments) -> std::optional<ov::intel_npu::CompilerType> {+ auto compilerTypeIt = arguments.find(ov::intel_npu::compiler_type.name());+ if (compilerTypeIt == arguments.end()) {+ return std::nullopt;+ }++ try {+ return compilerTypeIt->second.as<ov::intel_npu::CompilerType>();+ } catch (...) {+ return std::nullopt;+ }+ };++ const auto isCompilerOptionSupported =+ [this, getCompilerTypeOrDefault, getDeviceId](const std::string& propertyName, const ov::AnyMap& arguments) {+ const auto compilerType = getCompilerTypeOrDefault(arguments);+ if (!compilerType.has_value()) {+ return false;+ }++ ov::intel_npu::CompilerType resolvedCompilerType;+ if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ const auto platform =+ platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();+ const auto resolvedCompilerTypeOpt =+ resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);+ if (!resolvedCompilerTypeOpt.has_value()) {+ return false;+ }+ resolvedCompilerType = resolvedCompilerTypeOpt.value();+ } else {+ resolvedCompilerType = compilerType.value();+ }++ try {+ return _compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType, propertyName);+ } catch (...) {+ return false;+ }+ };++ const auto registerConfigProperty = [this](const auto optionTag, bool isPublic) {+ using OptionType = std::decay_t<decltype(optionTag)>;+ const auto propertyName = std::string(OptionType::key());+ register_property(+ propertyName,+ isPublic,+ ov::PropertyMutability::RW,+ [this, propertyName](const ov::AnyMap&) {+ return _config.hasOpt(propertyName);+ },+ [this](const ov::AnyMap&) {+ return _config.get<OptionType>();+ },+ [this, propertyName](const ov::Any& value) {+ _config.update(propertyName, value.as<std::string>());+ });+ };++ registerConfigProperty(BYPASS_UMD_CACHING{}, true);+ registerConfigProperty(CACHE_DIR{}, true);+ registerConfigProperty(DEFER_WEIGHTS_LOAD{}, true);+ registerConfigProperty(MODEL_PRIORITY{}, true);+ registerConfigProperty(NUM_STREAMS{}, true);+ registerConfigProperty(PERF_COUNT{}, true);+ registerConfigProperty(PERFORMANCE_HINT{}, true);+ registerConfigProperty(PERFORMANCE_HINT_NUM_REQUESTS{}, true);+ registerConfigProperty(WEIGHTS_PATH{}, true);+ registerConfigProperty(WORKLOAD_TYPE{}, true);++ registerConfigProperty(COMPILED_BLOB{}, false);+ registerConfigProperty(CREATE_EXECUTOR{}, false);+ registerConfigProperty(DISABLE_VERSION_CHECK{}, false);+ registerConfigProperty(EXPORT_RAW_BLOB{}, false);+ registerConfigProperty(IMPORT_RAW_BLOB{}, false);+ registerConfigProperty(PROFILING_TYPE{}, false);+ registerConfigProperty(SHARED_COMMON_QUEUE{}, false);++ // Special case: this property is always registered because it's supported by the implementation,+ // but it's not visible in supported_properties if the driver doesn't support it.+ registerConfigProperty(RUN_INFERENCES_SEQUENTIALLY{}, [this] {+ if (_backend && _backend->getInitStructs()) {+ if (_backend->getInitStructs()->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {+ return true;+ }+ }+ return false;+ }());++ OPENVINO_SUPPRESS_DEPRECATED_START+ registerConfigProperty(ENABLE_CPU_PINNING{}, false);+ OPENVINO_SUPPRESS_DEPRECATED_END++ const auto registerCompilerProperty = [this, isCompilerOptionSupported](const auto optionTag, bool isPublic) {+ using OptionType = std::decay_t<decltype(optionTag)>;+ const auto propertyName = std::string(OptionType::key());+ register_property(+ propertyName,+ isPublic,+ ov::PropertyMutability::RW,+ [this, propertyName, isCompilerOptionSupported](const ov::AnyMap& arguments) {+ return _config.hasOpt(propertyName) && isCompilerOptionSupported(propertyName, arguments);+ },+ [this](const ov::AnyMap&) {+ return _config.get<OptionType>();+ },+ [this, propertyName](const ov::Any& value) {+ _config.update(propertyName, value.as<std::string>());+ });+ };++ registerCompilerProperty(CACHE_MODE{}, true);+ registerCompilerProperty(COMPILATION_MODE_PARAMS{}, true);+ registerCompilerProperty(COMPILATION_NUM_THREADS{}, true);+ registerCompilerProperty(COMPILER_DYNAMIC_QUANTIZATION{}, true);+ registerCompilerProperty(EXECUTION_MODE_HINT{}, true);+ registerCompilerProperty(INFERENCE_PRECISION_HINT{}, true);+ registerCompilerProperty(QDQ_OPTIMIZATION{}, true);+ registerCompilerProperty(QDQ_OPTIMIZATION_AGGRESSIVE{}, true);+ registerCompilerProperty(TILES{}, true);++ registerCompilerProperty(BACKEND_COMPILATION_PARAMS{}, false);+ registerCompilerProperty(BATCH_COMPILER_MODE_SETTINGS{}, false);+ registerCompilerProperty(BATCH_MODE{}, false);+ registerCompilerProperty(COMPILATION_MODE{}, false);+ registerCompilerProperty(DMA_ENGINES{}, false);+ registerCompilerProperty(DYNAMIC_SHAPE_TO_STATIC{}, false);+ registerCompilerProperty(ENABLE_WEIGHTLESS{}, false);+ registerCompilerProperty(MODEL_SERIALIZER_VERSION{}, false);+ registerCompilerProperty(SEPARATE_WEIGHTS_VERSION{}, false);++ // clang-format off+ register_property(ov::log::level.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::log::level.name());+ },+ [this](const ov::AnyMap&) {+ return _config.get<LOG_LEVEL>();+ },+ [this](const ov::Any& value) {+ Logger::global().setLevel(value.as<ov::log::Level>());+ _logger.setLevel(value.as<ov::log::Level>());+ if (_backend != nullptr) {+ _backend->updateInfo( {{ov::log::level.name(), value}} );+ }+ _config.updateAny(ov::log::level.name(), value);+ }+ );+ register_property(ov::intel_npu::disable_idle_memory_prunning.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::intel_npu::disable_idle_memory_prunning.name()) && _backend != nullptr &&+ _backend->isContextExtSupported();+ },+ [this](const ov::AnyMap&) {+ return _config.get<DISABLE_IDLE_MEMORY_PRUNING>();+ },+ [this](const ov::Any& value) {+ if (_backend != nullptr) {+ _backend->updateInfo( {{ov::intel_npu::disable_idle_memory_prunning.name(), value}} );+ }+ // Do not throw in case it is not supported since some users may not check all the time supported properties+ _config.updateAny(ov::intel_npu::disable_idle_memory_prunning.name(), value);+ }+ );+ register_property(ov::device::id.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::device::id.name());+ },+ [this, getDeviceId](const ov::AnyMap& arguments) -> ov::Any {+ const auto deviceId = getDeviceId(arguments);+ return deviceId.empty() ? ov::Any(_config.get<DEVICE_ID>()) : ov::Any(deviceId);+ },+ [this](const ov::Any& value) {+ _config.update(ov::device::id.name(), value.as<std::string>());+ }+ );+ register_property(ov::intel_npu::compiler_type.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::intel_npu::compiler_type.name());+ },+ [this, getCompilerTypeOrDefault](const ov::AnyMap& arguments) -> ov::Any {+ const auto compilerType = getCompilerTypeOrDefault(arguments);+ return compilerType.has_value() ? ov::Any(compilerType.value()) : ov::Any(_config.get<COMPILER_TYPE>());+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::compiler_type.name(), value.as<std::string>());+ }+ );+ register_property(ov::intel_npu::max_tiles.name(), true, ov::PropertyMutability::RO,+ hasBackendAndValidDevice,+ [this, getDeviceId](const ov::AnyMap& arguments) {+ if (!_config.has<MAX_TILES>()) {+ try {+ return static_cast<int64_t>(utils::getMaxTiles(_backend, getDeviceId(arguments)));+ } catch (...) {+ _logger.warning("GetMaxTiles failed to get value from device.");+ }+ }+ return _config.get<MAX_TILES>();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key: ", ov::intel_npu::max_tiles.name());+ }+ );+ register_property(ov::intel_npu::platform.name(), true, ov::PropertyMutability::RW,+ [this, isCompilerOptionSupported](const ov::AnyMap& arguments) {+ return _config.hasOpt(ov::intel_npu::platform.name()) &&+ isCompilerOptionSupported(ov::intel_npu::platform.name(), arguments);+ },+ [this](const ov::AnyMap& arguments) -> ov::Any {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ return platformIt != arguments.end() ? platformIt->second : ov::Any(_config.get<PLATFORM>());+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::platform.name(), value.as<std::string>());+ }+ );+ register_property(ov::intel_npu::turbo.name(), true, ov::PropertyMutability::RW,+ [this, isCompilerOptionSupported](const ov::AnyMap& arguments) {+ return _config.hasOpt(ov::intel_npu::turbo.name()) &&+ ((_backend != nullptr && _backend->isCommandQueueExtSupported()) ||+ isCompilerOptionSupported(ov::intel_npu::turbo.name(), arguments));+ },+ [this](const ov::AnyMap&) {+ return _config.get<TURBO>();+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::turbo.name(), value.as<std::string>());+ }+ );+ register_property(ov::intel_npu::enable_strides_for.name(), true, ov::PropertyMutability::RW,+ [this, isCompilerOptionSupported](const ov::AnyMap& arguments) {+ if (!_config.hasOpt(ov::intel_npu::enable_strides_for.name()) ||+ !isCompilerOptionSupported(ov::intel_npu::enable_strides_for.name(), arguments)) {+ return false;+ }+ if (_backend != nullptr && _backend->getGraphExtVersion() < ZE_MAKE_VERSION(1, 16)) {+ _logger.info("Config option %s not supported by the driver! Requirements not met.", ov::intel_npu::enable_strides_for.name());+ return false;+ }+ return true;+ },+ [this](const ov::AnyMap&) {+ return _config.get<ENABLE_STRIDES_FOR>();+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::enable_strides_for.name(), value.as<std::string>());+ }+ );+ register_property(ov::cache_encryption_callbacks.name(), true, ov::PropertyMutability::WO,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::cache_encryption_callbacks.name());+ },+ [](const ov::AnyMap&) {+ return ov::EncryptionCallbacks{nullptr, nullptr};+ },+ [this](const ov::Any& value) {+ _config.updateAny(ov::cache_encryption_callbacks.name(), value);+ }+ );++ register_property(ov::intel_npu::stepping.name(), false, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::intel_npu::stepping.name());+ },+ [this, getDeviceId](const ov::AnyMap& arguments) {+ if (!_config.has<STEPPING>()) {+ try {+ return static_cast<int64_t>(utils::getSteppingNumber(_backend, getDeviceId(arguments)));+ } catch (...) {+ _logger.warning("GetSteppingNumber failed to get value from device.");+ }+ }+ return _config.get<STEPPING>();+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::stepping.name(), value.as<std::string>());+ }+ );+ register_property(ov::intel_npu::compile_log_level.name(), false, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::intel_npu::compile_log_level.name());+ },+ [this](const ov::AnyMap&) -> ov::Any {+ return COMPILE_LOG_LEVEL::resolve(_config);+ },+ [this](const ov::Any& value) {+ _config.update(ov::intel_npu::compile_log_level.name(), value.as<std::string>());+ }+ );++ const auto alwaysSupported = [](const ov::AnyMap&) {+ return true;+ };+ const auto readOnlySetter = [](const ov::Any&) {+ OPENVINO_THROW("Property is read-only");+ };++ register_property(ov::execution_devices.name(), true, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return std::vector<std::string>{"NPU"};+ }, readOnlySetter);+ register_property(ov::device::capabilities.name(), true, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return std::vector<std::string>{ov::device::capability::FP16, ov::device::capability::INT8, ov::device::capability::EXPORT_IMPORT};+ }, readOnlySetter);+ register_property(ov::range_for_async_infer_requests.name(), true, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return std::tuple<uint32_t, uint32_t, uint32_t>{1u, 8u, 1u};+ }, readOnlySetter);+ register_property(ov::range_for_streams.name(), true, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return std::tuple<uint32_t, uint32_t>{0u, 8u};+ }, readOnlySetter);+ register_property(ov::available_devices.name(), true, ov::PropertyMutability::RO, alwaysSupported, [this](const ov::AnyMap&) {+ return _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames();+ }, readOnlySetter);+ register_property(ov::hint::model.name(), true, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::hint::model.name());+ },+ [this](const ov::AnyMap&) -> ov::Any {+ return _config.get<MODEL_PTR>().lock();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("Property '", ov::hint::model.name(),"' can only be provided when importing a compiled model, it cannot be set otherwise");+ }+ );+ register_property(ov::supported_properties.name(), true, ov::PropertyMutability::RO, alwaysSupported, [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) {+ auto resolvedArguments = arguments;+ if (const auto compilerType = getCompilerTypeOrDefault(arguments); compilerType.has_value() && compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();+ const auto resolvedCompilerType = resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);+ if (resolvedCompilerType.has_value()) {+ resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.value();+ } else {+ resolvedArguments.erase(ov::intel_npu::compiler_type.name());+ }+ }++ std::vector<ov::PropertyName> supportedProperties;+ for (auto& property : _properties) {+ if (property.second.isPublic && property.second.isSupported(resolvedArguments)) {+ supportedProperties.emplace_back(ov::PropertyName(property.first, property.second.mutability));+ }+ }+ return supportedProperties;+ }, readOnlySetter);++ register_property(ov::loaded_from_cache.name(), false, ov::PropertyMutability::RW,+ [this](const ov::AnyMap&) {+ return _config.hasOpt(ov::loaded_from_cache.name());+ },+ [](const ov::AnyMap&) -> ov::Any {+ OPENVINO_THROW("Property '", ov::loaded_from_cache.name(),"' can only be provided when importing a compiled model, and read from compiled model");+ },+ [](const ov::Any&) {+ OPENVINO_THROW("Property '", ov::loaded_from_cache.name(),"' can only be provided when importing a compiled model from OpenVINO Cache, it cannot be set otherwise");+ }+ );+ register_property(ov::internal::caching_with_mmap.name(), false, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return true;+ }, readOnlySetter);+ register_property(ov::internal::supported_properties.name(), false, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return std::vector<ov::PropertyName>{ov::internal::caching_properties.name(),+ ov::internal::caching_with_mmap.name(),+ ov::internal::cache_header_alignment.name()};+ }, readOnlySetter);+ register_property(ov::internal::cache_header_alignment.name(), false, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {+ return utils::STANDARD_PAGE_SIZE;+ }, readOnlySetter);+ register_property(ov::internal::caching_properties.name(), false, ov::PropertyMutability::RO, alwaysSupported, [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) {+ auto resolvedArguments = arguments;+ if (const auto compilerType = getCompilerTypeOrDefault(arguments); compilerType.has_value() && compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();+ const auto resolvedCompilerType = resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);+ if (resolvedCompilerType.has_value()) {+ resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.value();+ } else {+ resolvedArguments.erase(ov::intel_npu::compiler_type.name());+ }+ }++ std::vector<ov::PropertyName> caching_props{};+ for (auto prop : _cachingProperties) {+ const auto propertyIt = _properties.find(prop);+ if (propertyIt != _properties.end() && propertyIt->second.isSupported(resolvedArguments)) {+ caching_props.emplace_back(prop);+ }+ }+ return caching_props;+ }, readOnlySetter);++ register_property(ov::intel_npu::driver_version.name(), true, ov::PropertyMutability::RO, hasBackendPredicate, [this](const ov::AnyMap&) {+ OPENVINO_ASSERT(_backend != nullptr, "No available backend");+ return _backend->getDriverVersion();+ }, readOnlySetter);+ register_property(ov::device::pci_info.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getPciInfo(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::device::gops.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getGops(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::device::type.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getDeviceType(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::intel_npu::device_alloc_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getDeviceAllocMemSize(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::intel_npu::device_total_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getDeviceTotalMemSize(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::device::uuid.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ auto devUuid = utils::getDeviceUuid(_backend, getDeviceId(arguments));+ return decltype(ov::device::uuid)::value_type{devUuid};+ }, readOnlySetter);+ register_property(ov::device::architecture.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ const auto devName = utils::getDeviceName(_backend, getDeviceId(arguments));+ return utils::getPlatformByDeviceName(devName);+ }, readOnlySetter);+ register_property(ov::device::full_name.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getFullDeviceName(_backend, getDeviceId(arguments));+ }, readOnlySetter);+ register_property(ov::device::luid.name(), _backend != nullptr && _backend->isLUIDExtSupported(), ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {+ return utils::getDeviceLUID(_backend, getDeviceId(arguments));+ }, readOnlySetter);++ // Guarded by PluginPropertyManager::_mutex, held by all call sites that invoke this predicate.+ auto compatibilityCheckSupportCache = std::make_shared<std::optional<bool>>();+ register_property(ov::compatibility_check.name(), true, ov::PropertyMutability::RO,+ [this, compatibilityCheckSupportCache](const ov::AnyMap&) {+ if (!compatibilityCheckSupportCache->has_value()) {+ *compatibilityCheckSupportCache = isCompatibilityCheckSupported(_backend, *_compilerOptionSupportHelper);+ }+ return compatibilityCheckSupportCache->value();+ },+ [this](const ov::AnyMap& arguments) {+ return validateCompatibilityDescriptor(_backend, arguments, *_compilerOptionSupportHelper);+ },+ readOnlySetter+ );++ register_property(ov::intel_npu::backend_name.name(), false, ov::PropertyMutability::RO, hasBackendPredicate, [this](const ov::AnyMap&) {+ OPENVINO_ASSERT(_backend != nullptr, "No available backend");+ return _backend->getName();+ }, readOnlySetter);++ register_property(ov::intel_npu::compiler_version.name(), true, ov::PropertyMutability::RO,+ [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) { // support predicate+ auto compilerType = getCompilerTypeOrDefault(arguments);+ if (!compilerType.has_value()) {+ return false;+ }+ std::string compilationPlatform;+ if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();+ auto deviceId = getDeviceId(arguments);+ auto device = utils::getDeviceById(_backend, deviceId);+ compilationPlatform = utils::getCompilationPlatform(+ platform,+ device == nullptr ? deviceId : device->getName(),+ _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());+ }++ try {+ CompilerAdapterFactory factory;+ return factory.getCompiler(_backend, compilerType.value(), compilationPlatform) != nullptr;+ } catch (...) {+ return false;+ }+ },+ [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) { // value getter+ auto compilerType = getCompilerTypeOrDefault(arguments);+ OPENVINO_ASSERT(compilerType.has_value(), "Compiler type is not specified in properties.");+ std::string compilationPlatform;+ if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());+ const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();+ auto deviceId = getDeviceId(arguments);+ auto device = utils::getDeviceById(_backend, deviceId);+ compilationPlatform = utils::getCompilationPlatform(+ platform,+ device == nullptr ? deviceId : device->getName(),+ _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames());+ }++ CompilerAdapterFactory factory;+ return factory.getCompiler(_backend, compilerType.value(), compilationPlatform)->get_version();+ },+ [](const ov::Any&) {+ OPENVINO_THROW("READ-ONLY configuration key: ", ov::intel_npu::compiler_version.name());+ }+ );+ // clang-format on++ for_each_exposed_npuw_option([this](auto tag) {+ using OptionType = typename decltype(tag)::type;+ const auto propertyName = std::string(OptionType::key());+ register_property(+ propertyName,+ false,+ ov::PropertyMutability::RW,+ [this, propertyName](const ov::AnyMap&) {+ return _config.hasOpt(propertyName);+ },+ [this](const ov::AnyMap&) {+ return _config.get<OptionType>();+ },+ [this, propertyName](const ov::Any& value) {+ _config.update(propertyName, value.as<std::string>());+ });+ });}} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/plugin/src/transformations.cpp b/src/plugins/intel_npu/src/plugin/src/transformations.cppindex 9e26373f889..e8b45172dcf 100644--- a/src/plugins/intel_npu/src/plugin/src/transformations.cpp+++ b/src/plugins/intel_npu/src/plugin/src/transformations.cpp@@ -185,8 +185,8 @@ bool deBatchModel(std::shared_ptr<ov::Model>& model,std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(std::shared_ptr<const ov::Model> model,- FilteredConfig& localConfig,const std::function<void(ov::intel_npu::BatchMode)>& updateBatchMode,+ std::optional<ov::intel_npu::BatchMode> batchMode,std::optional<ov::Dimension>& originalBatch,Logger logger) {// Keep the original model for all no-op/early-return paths.@@ -194,26 +194,24 @@ std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(auto resultModel = std::const_pointer_cast<ov::Model>(model);auto successfullyDebatched = false;- auto batchModeIsAvailable = localConfig.isAvailable(ov::intel_npu::batch_mode.name());- ov::intel_npu::BatchMode batchMode;+ auto batchModeIsAvailable = batchMode.has_value();+ ov::intel_npu::BatchMode effectiveBatchMode =+ batchModeIsAvailable ? batchMode.value() : ov::intel_npu::BatchMode::AUTO;+if (batchModeIsAvailable) {- batchMode = localConfig.get<BATCH_MODE>();- const auto isAutoOrPluginBatch =- (batchMode == ov::intel_npu::BatchMode::PLUGIN || batchMode == ov::intel_npu::BatchMode::AUTO);+ const auto isAutoOrPluginBatch = (effectiveBatchMode == ov::intel_npu::BatchMode::PLUGIN ||+ effectiveBatchMode == ov::intel_npu::BatchMode::AUTO);if (!isAutoOrPluginBatch) {return {resultModel, successfullyDebatched};}- } else {- // If the compiler doesn't support BATCH_MODE, we can still try using batching- batchMode = ov::intel_npu::BatchMode::AUTO;}try {const auto pluginBatchingIsSupported = validateModelBatch(model, logger);if (!pluginBatchingIsSupported) {- if (batchModeIsAvailable && batchMode == ov::intel_npu::BatchMode::AUTO) {+ if (batchModeIsAvailable && effectiveBatchMode == ov::intel_npu::BatchMode::AUTO) {logger.info("Batching will be handled by compiler.");updateBatchMode(ov::intel_npu::BatchMode::COMPILER);}@@ -248,12 +246,12 @@ std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(} catch (const std::exception& ex) {// If plugin-side transformation failed, keep the original model and drop the cloneresultModel = std::const_pointer_cast<ov::Model>(model);- if (batchMode == ov::intel_npu::BatchMode::AUTO) {+ if (effectiveBatchMode == ov::intel_npu::BatchMode::AUTO) {logger.info("Couldn't validate and reshape the model. Batching will be handled by compiler. Error: %s",ex.what());if (batchModeIsAvailable) {// If we failed to handle batching on the plugin side, we should reset the batch mode to default- // COMPILER But only if the batch mode is available, otherwise we might be running on older compiler+ // COMPILER but only if the batch mode is available, otherwise we might be running on an older compiler// which doesn't support batch mode at allupdateBatchMode(ov::intel_npu::BatchMode::COMPILER);}diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cppindex dffb64a507f..6538b15a4d8 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp@@ -455,12 +455,6 @@ TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckIsReadOnly) {OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));- // Determine at runtime whether the driver version is sufficient to handle the- // compatibility check without falling back to PluginCompilerAdapter.- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);-auto original_level = core.get_property(deviceName, ov::log::level);OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));{@@ -471,13 +465,10 @@ TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckIsReadOnly) {}OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));+ // DriverCompilerAdapter and PluginCompilerAdapter should not be initialized at all in such a scenario, checking+ // that the corresponding message is not present in the logASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- if (driverHandlesCompatibilityCheck) {- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- } else {- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- }+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);}TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckUsesPluginCompilerFallbackForOlderDriver) {@@ -507,6 +498,8 @@ TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckUsesPluginCompiler}OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));+ // DriverCompilerAdapter should not be initialized at all in such a scenario, checking that the corresponding+ // message is not present in the logASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);if (driverHandlesCompatibilityCheck) {diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cppindex e3ddbfa95d6..eaefb649e1d 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp@@ -398,7 +398,7 @@ TEST_P(CheckCompilerTypeProperty, CheckLogAfterSettingExtraConfigToGetProperty)}ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);compiler_type = core.get_property(deviceName, ov::intel_npu::compiler_type);ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);@@ -438,7 +438,7 @@ TEST_P(CheckCompilerTypeProperty, CheckLogAfterGettingPropertyWithExtraConfig) {ov::intel_npu::qdq_optimization(true)}));}- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);}TEST_P(CheckCompilerTypeProperty, SetRuntimeProperty) {@@ -574,6 +574,99 @@ TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {logs.clear();}+using compatibility_CheckCompilerTypeProperty = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(compatibility_CheckCompilerTypeProperty, GlobalPluginPropertyRespectsDriverCompilerSupport) {+ ov::Core core;++ const auto isDriverCompilerPropertySupported = [&]() {+ try {+ core.get_property(deviceName,+ ov::intel_npu::qdq_optimization_aggressive,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)});+ return true;+ } catch (...) {+ return false;+ }+ }();++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization_aggressive(true)));++ ov::CompiledModel compiled_model;+ if (isDriverCompilerPropertySupported) {+ OV_ASSERT_NO_THROW(compiled_model =+ core.compile_model(model,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::qdq_optimization_aggressive(true)}}));+ } else {+ EXPECT_THROW(+ compiled_model = core.compile_model(model,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::qdq_optimization_aggressive(true)}}),+ ov::Exception);+ return;+ }++ ASSERT_EQ(compiled_model.get_property(ov::intel_npu::compiler_type), ov::intel_npu::CompilerType::DRIVER);+ EXPECT_TRUE(compiled_model.get_property(ov::intel_npu::qdq_optimization_aggressive));+}++TEST_P(compatibility_CheckCompilerTypeProperty, CheckTurboWhenLoadingFromCacheWithCiP) {+ std::string logs;+ std::mutex logs_mutex;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());+ const std::string cache_dir = ov::test::utils::generateTestFilePrefix();++ {+ ov::Core core;+ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::cache_dir(cache_dir)));++ ov::CompiledModel compiled_model;+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName, {{ov::intel_npu::turbo(true)}}));++ ASSERT_EQ(compiled_model.get_property(ov::intel_npu::compiler_type), ov::intel_npu::CompilerType::PLUGIN);+ EXPECT_TRUE(compiled_model.get_property(ov::intel_npu::turbo));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::WARNING)));+ ov::CompiledModel compiled_model_from_cache;+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(compiled_model_from_cache =+ core.compile_model(model, deviceName, {{ov::intel_npu::turbo(true)}}));+ }++ auto backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ if (!backend->isCommandQueueExtSupported()) {+ // Loading from cache must only warn that the compile-time property is not used, not fail.+ ASSERT_NE(logs.find("Property 'NPU_TURBO' is recognized as a compiler option, will not be used for current "+ "configuration."),+ std::string::npos);+ } else {+ EXPECT_THROW(compiled_model_from_cache.get_property(ov::intel_npu::compiler_type), ov::Exception);+ EXPECT_TRUE(compiled_model_from_cache.get_property(ov::intel_npu::turbo));+ EXPECT_TRUE(compiled_model_from_cache.get_property(ov::loaded_from_cache));+ }++ // Release handles before removing the cache directory to avoid file-lock issues on some platforms.+ }++ ov::test::utils::removeFilesWithExt<ov::test::opt::FORCE>(cache_dir, "blob");+ ov::test::utils::removeDir(cache_dir);+}+using CheckCompilerVersionProperty = ClassExecutableNetworkGetPropertiesTestNPU;TEST_P(CheckCompilerVersionProperty, GetCompilerVersionFromCompiledModel) {@@ -650,7 +743,7 @@ TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithCompilercore_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));}- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),+ ASSERT_NE(logs.find("Property 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),std::string::npos);}@@ -697,9 +790,7 @@ TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithRuntimeP{{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),ov::workload_type(ov::WorkloadType::EFFICIENT)}}));- ov::intel_npu::CompilerType compiler_type = ov::intel_npu::CompilerType::PLUGIN;- OV_ASSERT_NO_THROW(compiler_type = imported_model.get_property(ov::intel_npu::compiler_type));- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::compiler_type), ov::Exception);ov::WorkloadType workload_type = ov::WorkloadType::DEFAULT;OV_ASSERT_NO_THROW(workload_type = imported_model.get_property(ov::workload_type));@@ -728,24 +819,30 @@ TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerProperty) {logs.push_back('\n');};+ ov::CompiledModel imported_model;{ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(- core_for_importing.import_model(export_stream,- deviceName,- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::platform("5010"),- ov::intel_npu::qdq_optimization(true)}}));+ OV_ASSERT_NO_THROW(imported_model = core_for_importing.import_model(+ export_stream,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::platform("5010"),+ ov::intel_npu::qdq_optimization(true)}}));}ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "+ ASSERT_NE(logs.find("Property 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current ""configuration."),std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "+ ASSERT_NE(logs.find("Property 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for ""current configuration."),std::string::npos);++ ASSERT_THROW(imported_model.get_property(ov::intel_npu::platform),+ ov::Exception); // Expect to throw due to unsupported property+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::qdq_optimization),+ ov::Exception); // Expect to throw due to unsupported property}TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerPropertyAfterCompiling) {@@ -769,23 +866,30 @@ TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerPropertyAfterClogs.push_back('\n');};+ ov::CompiledModel imported_model;{ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.import_model(export_stream,- deviceName,- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::platform("5010"),- ov::intel_npu::qdq_optimization(true)}}));+ OV_ASSERT_NO_THROW(imported_model =+ core.import_model(export_stream,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::platform("5010"),+ ov::intel_npu::qdq_optimization(true)}}));}ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "+ ASSERT_NE(logs.find("Property 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current ""configuration."),std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "+ ASSERT_NE(logs.find("Property 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for ""current configuration."),std::string::npos);++ ASSERT_THROW(imported_model.get_property(ov::intel_npu::platform),+ ov::Exception); // Expect to throw due to unsupported property+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::qdq_optimization),+ ov::Exception); // Expect to throw due to unsupported property}using CheckCpuPinning = ClassExecutableNetworkGetPropertiesTestNPU;@@ -954,7 +1058,6 @@ std::vector<std::pair<std::string, ov::Any>> plugin_public_immutable_properties{ov::range_for_async_infer_requests.name(),ov::Any(std::tuple<unsigned int, unsigned int, unsigned int>{0, 10, 1})},{ov::range_for_streams.name(), ov::Any(std::tuple<unsigned int, unsigned int>{0, 10})},- {ov::optimal_number_of_infer_requests.name(), ov::Any(4)},{ov::intel_npu::device_alloc_mem_size.name(), ov::Any(2)},{ov::intel_npu::device_total_mem_size.name(), ov::Any(2)},{ov::intel_npu::max_tiles.name(), ov::Any(9999)}};@@ -1044,6 +1147,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CheckCompilerType,::testing::ValuesIn(valid_device_ids)),CheckCompilerTypeProperty::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests_CheckCompilerType,+ compatibility_CheckCompilerTypeProperty,+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),+ ::testing::ValuesIn(valid_device_ids)),+ compatibility_CheckCompilerTypeProperty::getTestCaseName);+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CheckCompilerType,CheckCompilerPropertyWhenImporting,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_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.cppindex 5c82c187e1c..315eebb7e29 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@@ -159,14 +159,9 @@ public:options->add<::intel_npu::BATCH_MODE>();options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);- ::intel_npu::Config::ConfigMap configMap;- npu_config->enable(::intel_npu::PLATFORM::key().data(), true);- npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), true);for (const auto& [propertyName, propertyValue] : configuration) {- configMap[propertyName] = propertyValue.as<std::string>();- npu_config->enable(propertyName, true);+ npu_config->update(propertyName, propertyValue.as<std::string>());}- npu_config->update(configMap);auto zeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>(::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,@@ -220,11 +215,9 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {// WA for error `[NPU_VCL] Unsupported IR API version! Val: 48.0`if (compiler->is_option_supported(::intel_npu::MODEL_SERIALIZER_VERSION::key().data())) {- npu_config->update({{::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),- ::intel_npu::MODEL_SERIALIZER_VERSION::toString(- ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)}});- } else {- npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), false);+ npu_config->update(+ ::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),+ ::intel_npu::MODEL_SERIALIZER_VERSION::toString(ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY));}// logic for batch@@ -235,10 +228,10 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {std::optional<ov::Dimension> originalBatch = std::nullopt;auto [batchedModel, successfullyDebatched] = intel_npu::batch_helpers::handlePluginBatching(ov_model,- *npu_config,[&](ov::intel_npu::BatchMode mode) {- npu_config->update({{::intel_npu::BATCH_MODE::key().data(), ::intel_npu::BATCH_MODE::toString(mode)}});+ npu_config->update(::intel_npu::BATCH_MODE::key().data(), ::intel_npu::BATCH_MODE::toString(mode));},+ std::make_optional(npu_config->get<::intel_npu::BATCH_MODE>()),originalBatch,::intel_npu::Logger::global());OPENVINO_ASSERT(successfullyDebatched, "Couldn't debatch test model!");@@ -251,12 +244,14 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {graph->set_batch_size(batch.value());}+ ov::AnyMap unknownProperties = ov::AnyMap{};auto compiledModel = std::make_shared<intel_npu::CompiledModel>(ov_model,std::make_shared<ov::test::utils::MockPlugin>(), // MockPlugin needed only to avoid throw for nullptrdevice,graph,*npu_config,+ unknownProperties,batch);OPENVINO_ASSERT(compiledModel->inputs()[0].get_element_type() == element_type);OPENVINO_ASSERT(compiledModel->inputs()[1].get_element_type() == element_type);diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cppindex ab3b868dda3..fdb1f2aa60d 100644--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/compile_log_level.cpp@@ -26,11 +26,7 @@ protected:options = std::make_shared<OptionsDesc>();options->add<LOG_LEVEL>();options->add<COMPILE_LOG_LEVEL>();-config = std::make_unique<FilteredConfig>(options);-- config->enable(ov::log::level.name(), true);- config->enableRuntimeOptions();}static ze_graph_compiler_version_info_t modernCompilerVersion() {@@ -49,7 +45,7 @@ protected:};TEST_F(CompileLogLevelSerializeConfigTests, BackwardCompatibleCompilerLogUnsetPluginLogSet) {- config->update({{ov::log::level.name(), "LOG_DEBUG"}});+ config->update(ov::log::level.name(), "LOG_DEBUG");const std::string flags = serialize();@@ -59,7 +55,8 @@ TEST_F(CompileLogLevelSerializeConfigTests, BackwardCompatibleCompilerLogUnsetPl}TEST_F(CompileLogLevelSerializeConfigTests, CompileLogLevelSetPrioritizedOverUnchangedPluginLogLevel) {- config->update({{ov::log::level.name(), "LOG_DEBUG"}, {ov::intel_npu::compile_log_level.name(), "LOG_ERROR"}});+ config->update(ov::log::level.name(), "LOG_DEBUG");+ config->update(ov::intel_npu::compile_log_level.name(), "LOG_ERROR");const std::string flags = serialize();@@ -70,7 +67,7 @@ TEST_F(CompileLogLevelSerializeConfigTests, CompileLogLevelSetPrioritizedOverUnc}TEST_F(CompileLogLevelSerializeConfigTests, CompileLogLevelSetPrioritizedOverChangedPluginLogLevel) {- config->update({{ov::intel_npu::compile_log_level.name(), "LOG_TRACE"}});+ config->update(ov::intel_npu::compile_log_level.name(), "LOG_TRACE");const std::string flags = serialize();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.cppindex f6e6d529fcb..ec058e11117 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@@ -11,6 +11,7 @@#include <cstddef>#include <exception>#include <memory>+#include <optional>#include <random>#include <thread>#include <vector>@@ -30,6 +31,7 @@#include "openvino/core/log.hpp"#include "openvino/runtime/core.hpp"#include "openvino/runtime/intel_npu/properties.hpp"+#include "openvino/util/codec_xor.hpp"#include "plugin_property_manager.hpp"#include "shared_test_classes/base/ov_behavior_test_utils.hpp"#include "zero_backend.hpp"@@ -47,7 +49,6 @@ 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>();- ::intel_npu::FilteredConfig npu_config = ::intel_npu::FilteredConfig(options);ov::SoPtr<::intel_npu::IEngineBackend> backend;std::unique_ptr<::intel_npu::PluginPropertyManager> propertiesManager;@@ -79,16 +80,12 @@ public:OVPluginTestBase::SetUp();backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());-options->reset();--#define REGISTER_OPTION(OPT_TYPE) \- do { \- auto dummyopt = details::makeOptionModel<OPT_TYPE>(); \- std::string o_name = dummyopt.key().data(); \- options->add<OPT_TYPE>(); \- npu_config.enable(std::move(o_name), false); \+#define REGISTER_OPTION(OPT_TYPE) \+ do { \+ options->add<OPT_TYPE>(); \} while (0)+REGISTER_OPTION(LOG_LEVEL);REGISTER_OPTION(COMPILE_LOG_LEVEL);REGISTER_OPTION(CACHE_DIR);@@ -102,16 +99,13 @@ public:REGISTER_OPTION(PERFORMANCE_HINT);REGISTER_OPTION(EXECUTION_MODE_HINT);REGISTER_OPTION(PERFORMANCE_HINT_NUM_REQUESTS);- OPENVINO_SUPPRESS_DEPRECATED_START- REGISTER_OPTION(ENABLE_CPU_PINNING);- OPENVINO_SUPPRESS_DEPRECATED_ENDREGISTER_OPTION(INFERENCE_PRECISION_HINT);- REGISTER_OPTION(MODEL_PRIORITY);REGISTER_OPTION(COMPILATION_MODE_PARAMS);REGISTER_OPTION(DMA_ENGINES);REGISTER_OPTION(TILES);REGISTER_OPTION(COMPILATION_MODE);REGISTER_OPTION(COMPILER_TYPE);+ REGISTER_OPTION(COMPILER_VERSION);REGISTER_OPTION(PLATFORM);REGISTER_OPTION(CREATE_EXECUTOR);REGISTER_OPTION(DYNAMIC_SHAPE_TO_STATIC);@@ -131,65 +125,47 @@ public:REGISTER_OPTION(IMPORT_RAW_BLOB);REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);REGISTER_OPTION(TURBO);+ REGISTER_OPTION(ENABLE_WEIGHTLESS);REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);REGISTER_OPTION(MODEL_SERIALIZER_VERSION);REGISTER_OPTION(ENABLE_STRIDES_FOR);REGISTER_OPTION(SHARED_COMMON_QUEUE);+ REGISTER_OPTION(CACHE_ENCRYPTION_CALLBACKS);+ REGISTER_OPTION(MAX_TILES);+ REGISTER_OPTION(MODEL_PTR);+ REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);if (backend) {- REGISTER_OPTION(MAX_TILES);+ REGISTER_OPTION(MODEL_PRIORITY);if (backend->isCommandQueueExtSupported()) {REGISTER_OPTION(WORKLOAD_TYPE);}- if (backend->isContextExtSupported()) {- REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);- }}+ OPENVINO_SUPPRESS_DEPRECATED_START+ REGISTER_OPTION(ENABLE_CPU_PINNING);+ OPENVINO_SUPPRESS_DEPRECATED_END++ // NPUW properties are requested by OV Core during caching and+ // have no effect on the NPU plugin. But we still need to enable+ // those for OV Core to query. Note: do this last to not filter+ // them out. register npuw caching propertiesfor_each_exposed_npuw_option([&](auto tag) {using Opt = typename decltype(tag)::type;REGISTER_OPTION(Opt);});- npu_config.enableRuntimeOptions();-- // Special cases - options with OptionMode::Both must be enabled for the plugin even if the compiler does not- // support them, because they may be used by the plugin itself or by the driver.- // We still check compiler support to decide whether these options should be removed from the config string.-- // NPU_TURBO might be supported by the driver- if (backend && backend->isCommandQueueExtSupported()) {- npu_config.enable(ov::intel_npu::turbo.name(), true);- }-- // LOG_LEVEL, PERFORMANCE_HINT and PERF_COUNT are needed by runtime options- npu_config.enable(ov::log::level.name(), true);- npu_config.enable(ov::hint::performance_mode.name(), true);- npu_config.enable(ov::enable_profiling.name(), true);-- if (npu_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && backend != nullptr) {- auto device = backend->getDevice();- if (device) {- auto platformName = device->getName();- CompilerAdapterFactory compilerFactory;- auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);- if (compileType == ov::intel_npu::CompilerType::DRIVER) {- npu_config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});- }- }- }-propertiesManager = std::make_unique<PluginPropertyManager>(- npu_config,+ options,backend,std::make_shared<::intel_npu::CompilerOptionSupportHelper>(backend, CompilerAdapterFactory()),::intel_npu::Logger::global());}void TearDown() override {- APIBaseTest::TearDown();+ OVPluginTestBase::TearDown();}};@@ -319,7 +295,7 @@ TEST_P(CompatibilityCheckTests, CompatibilityCheckUsesPluginCompilerAdapterOnlyW}}-TEST_P(CompatibilityCheckTests, ExpectTurboPropertyAndCompatibilityCheckAreSupported) {+TEST_P(CompatibilityCheckTests, ExpectTurboPropertyIsSupported) {std::string logs;std::mutex logs_mutex;bool turboSupported = false;@@ -336,26 +312,26 @@ TEST_P(CompatibilityCheckTests, ExpectTurboPropertyAndCompatibilityCheckAreSuppo{utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}});turboSupported = propertiesManager->isPropertySupported(ov::intel_npu::turbo.name());}if (turboSupportedByDevice) {// Turbo is supported by device, so checking support must not trigger compiler adapters.ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_TRUE(turboSupported);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);} else {- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_FALSE(turboSupported);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);}-}-using ExpectLoadingCompilerPropertySupported = PropertiesManagerTests;+ ASSERT_TRUE(turboSupported);+}-TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupported) {+TEST_P(CompatibilityCheckTests, ExpectCompilerPropertyIsNotSupported) {std::string logs;std::mutex logs_mutex;- bool isSupported = false;+ bool isSupported = true;// Keep this std::function alive while logging is active.std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {@@ -368,20 +344,479 @@ TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupportedutils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});- isSupported = propertiesManager->isPropertySupported(configuration);+ isSupported = propertiesManager->isPropertySupported("DUMMY_PROPERTY");}- ASSERT_TRUE(isSupported);- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_FALSE(isSupported);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}});+ isSupported = propertiesManager->isPropertySupported("DUMMY_PROPERTY");+ }++ ASSERT_FALSE(isSupported);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);}-using ExpectLoadingCompilerPropertyNotSupported = PropertiesManagerTests;+TEST_P(CompatibilityCheckTests, CheckTurboWithGetMergedConfigAndUnknownPropertiesOnImport) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ if (backend->isCommandQueueExtSupported()) {+ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties({{ov::intel_npu::turbo(true)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_TRUE(filteredConfig.has<::intel_npu::TURBO>());+ ASSERT_TRUE(filteredConfig.get<::intel_npu::TURBO>());+ ASSERT_TRUE(unknownProperties.empty());+ } else {+ {+ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties({{ov::intel_npu::turbo(true)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_NE(logs.find("Property 'NPU_TURBO' is recognized as a compiler option, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_FALSE(filteredConfig.has<::intel_npu::TURBO>());+ ASSERT_TRUE(unknownProperties.empty());+ }+ }++ ASSERT_EQ(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}-TEST_P(ExpectLoadingCompilerPropertyNotSupported, ExpectCompilerPropertyIsNotSupported) {+TEST_P(CompatibilityCheckTests, CheckTurboWithGetMergedConfigAndUnknownPropertiesOnCompile) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}});++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties({{ov::intel_npu::turbo(true)}},+ ::intel_npu::ConfigMergeMode::Compile);+ }();++ ASSERT_TRUE(filteredConfig.has<::intel_npu::TURBO>());+ ASSERT_TRUE(filteredConfig.get<::intel_npu::TURBO>());+ ASSERT_TRUE(unknownProperties.empty());++ if (backend->isCommandQueueExtSupported()) {+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ } else {+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnknownPropertiesOnCompile) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{ov::intel_npu::platform("NPU3720"), ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Compile);+ }();++ ASSERT_EQ(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_TRUE(filteredConfig.has<::intel_npu::PLATFORM>());+ ASSERT_EQ(filteredConfig.get<::intel_npu::PLATFORM>(), "NPU3720");+ ASSERT_TRUE(unknownProperties.empty());++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnknownPropertiesOnImport) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{ov::intel_npu::platform("NPU3720"), ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_FALSE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_FALSE(filteredConfig.has<::intel_npu::PLATFORM>());+ ASSERT_FALSE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_TRUE(unknownProperties.empty());++ ASSERT_NE(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("Property 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "+ "configuration."),+ std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckLoadedFromCacheWithGetMergedConfigAndUnknownPropertiesOnImport) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{ov::loaded_from_cache.name(), ov::Any(true)},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_FALSE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_TRUE(filteredConfig.has<::intel_npu::LOADED_FROM_CACHE>());+ ASSERT_TRUE(filteredConfig.get<::intel_npu::LOADED_FROM_CACHE>());+ ASSERT_TRUE(unknownProperties.empty());++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownPropertiesOnCompile) {std::string logs;std::mutex logs_mutex;- bool isSupported = true;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"Dummy_Property", ov::Any(true)}, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Compile);+ }();++ ASSERT_TRUE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_EQ(filteredConfig.get<::intel_npu::COMPILER_TYPE>(), ov::intel_npu::CompilerType::PLUGIN);+ ASSERT_FALSE(unknownProperties.empty());+ ASSERT_EQ(unknownProperties.size(), 1);+ ASSERT_TRUE(unknownProperties.count("Dummy_Property"));++ ASSERT_EQ(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_NE(+ logs.find(+ "Property 'Dummy_Property' is unknown to the plugin property manager, will be sent to the compiled model."),+ std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownPropertiesOnImport) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"Dummy_Property", ov::Any(true)}, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_FALSE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_FALSE(unknownProperties.empty());+ ASSERT_EQ(unknownProperties.size(), 1);+ ASSERT_TRUE(unknownProperties.count("Dummy_Property"));++ ASSERT_NE(+ logs.find("Property 'NPU_COMPILER_TYPE' is used to specify the compiler type, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_NE(+ logs.find(+ "Property 'Dummy_Property' is unknown to the plugin property manager, will be sent to the compiled model."),+ std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownPropertiesOnQuery) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);++ OV_EXPECT_THROW(propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"Dummy_Property", ov::Any(true)},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Query),+ ov::Exception,+ testing::HasSubstr("Unsupported configuration key: Dummy_Property"));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckROPropertyWithGetMergedConfigAndUnknownProperties) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);++ OV_EXPECT_THROW(propertiesManager->getMergedConfigAndUnknownProperties(+ {{{ov::intel_npu::compiler_version.name(), ov::Any(true)}}},+ ::intel_npu::ConfigMergeMode::Compile),+ ov::Exception,+ testing::HasSubstr("READ-ONLY configuration key: NPU_COMPILER_VERSION"));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckUnsupportedConfigWithGetMergedConfigAndUnknownProperties) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ std::shared_ptr<::intel_npu::OptionsDesc> localOptions = std::make_shared<::intel_npu::OptionsDesc>();+ localOptions->add<::intel_npu::COMPILER_TYPE>();+ auto localPropertiesManager = std::make_unique<::intel_npu::PluginPropertyManager>(+ localOptions,+ backend,+ std::make_shared<::intel_npu::CompilerOptionSupportHelper>(backend, ::intel_npu::CompilerAdapterFactory()),+ ::intel_npu::Logger::global());++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);++ OV_EXPECT_THROW(+ localPropertiesManager->getMergedConfigAndUnknownProperties({{ov::device::id("3720")}},+ ::intel_npu::ConfigMergeMode::Compile),+ ov::Exception,+ testing::HasSubstr("[ NOT_FOUND ] Option 'DEVICE_ID' is not supported for current configuration"));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckModelPtrWithGetMergedConfigAndUnknownProperties) {+ auto param = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ auto result = std::make_shared<ov::op::v0::Result>(param);+ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param});+ auto constModel = std::const_pointer_cast<const ov::Model>(model);++ std::optional<::intel_npu::FilteredConfig> filteredConfig;+ for (const auto& modelProperty : {ov::hint::model(model), ov::hint::model(constModel)}) {+ auto [config, unknownProperties] =+ propertiesManager->getMergedConfigAndUnknownProperties({{modelProperty}},+ ::intel_npu::ConfigMergeMode::Import);+ filteredConfig = std::move(config);++ ASSERT_TRUE(filteredConfig->has<::intel_npu::MODEL_PTR>());+ ASSERT_EQ(filteredConfig->get<::intel_npu::MODEL_PTR>().lock(), model);+ ASSERT_TRUE(unknownProperties.empty());+ }++ model.reset();+ constModel.reset();+ ASSERT_EQ(filteredConfig->get<::intel_npu::MODEL_PTR>().lock(), nullptr);+}++TEST_P(CompatibilityCheckTests, CheckCacheEncryptionCallbacksWithGetMergedConfigAndUnknownProperties) {+ auto [filteredConfig, unknownProperties] = [&]() {+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr})}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_TRUE(filteredConfig.has<::intel_npu::CACHE_ENCRYPTION_CALLBACKS>());+ ASSERT_TRUE(unknownProperties.empty());+}++TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnCompile) {+ auto [filteredConfig, unknownProperties] = [&]() {+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Compile);+ }();++ ASSERT_TRUE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));+ ASSERT_TRUE(unknownProperties.empty());+}++TEST_P(CompatibilityCheckTests,+ CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnImportLoadedFromCache) {+ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto [filteredConfig, unknownProperties] = [&]() {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ {ov::loaded_from_cache.name(), ov::Any(true)}}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_FALSE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));+ ASSERT_TRUE(unknownProperties.empty());+ ASSERT_NE(logs.find("Property 'WS_COMPILE_CALL_NUMBER' is recognized as a compiler option, will not be used for "+ "current configuration."),+ std::string::npos);+}++TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithGetMergedConfigAndUnknownPropertiesOnImport) {+ auto [filteredConfig, unknownProperties] = [&]() {+ return propertiesManager->getMergedConfigAndUnknownProperties(+ {{{"WS_COMPILE_CALL_NUMBER", ov::Any(1)},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}},+ ::intel_npu::ConfigMergeMode::Import);+ }();++ ASSERT_FALSE(filteredConfig.hasInternal("WS_COMPILE_CALL_NUMBER"));+ ASSERT_EQ(unknownProperties.size(), 1);+ ASSERT_TRUE(unknownProperties.count("WS_COMPILE_CALL_NUMBER"));+}++TEST_P(CompatibilityCheckTests, CheckInternalCompilerOptionWithSetPropertyAndGetProperty) {+ OV_ASSERT_NO_THROW(+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}}));+ ov::intel_npu::CompilerType compilerType = ov::intel_npu::CompilerType::DRIVER;+ OV_ASSERT_NO_THROW(+ compilerType =+ propertiesManager->getProperty(ov::intel_npu::compiler_type.name()).as<ov::intel_npu::CompilerType>());+ ASSERT_EQ(compilerType, ov::intel_npu::CompilerType::PLUGIN); // make sure plugin compiler is set++ OV_EXPECT_THROW(propertiesManager->getProperty("WS_COMPILE_CALL_NUMBER"),+ ov::Exception,+ testing::HasSubstr("Unsupported configuration key: WS_COMPILE_CALL_NUMBER"));++ OV_ASSERT_NO_THROW(propertiesManager->setProperty({{"WS_COMPILE_CALL_NUMBER", ov::Any(5)}}));+ uint32_t ws_compile_call_number = 0;+ OV_ASSERT_NO_THROW(ws_compile_call_number =+ propertiesManager->getProperty("WS_COMPILE_CALL_NUMBER").as<uint32_t>());+ ASSERT_EQ(ws_compile_call_number, 5);+}++using ExpectLoadingCompilerPropertySupported = PropertiesManagerTests;++TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool isSupported = false;// Keep this std::function alive while logging is active.std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {@@ -397,8 +832,8 @@ TEST_P(ExpectLoadingCompilerPropertyNotSupported, ExpectCompilerPropertyIsNotSupisSupported = propertiesManager->isPropertySupported(configuration);}- ASSERT_FALSE(isSupported);- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_TRUE(isSupported);+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);}@@ -412,7 +847,6 @@ const std::vector<std::string> supported_configs = {{ov::hint::performance_mode.{ov::cache_dir.name()},{ov::intel_npu::driver_version.name()}};const std::vector<std::string> supported_compiler_configs = {{ov::intel_npu::qdq_optimization.name()}};-const std::vector<std::string> unsupported_compiler_configs = {{"DUMMY_PROPERTY"}};INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,PropertiesManagerTests,@@ -432,12 +866,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,::testing::ValuesIn(supported_compiler_configs)),PropertiesManagerTests::getTestCaseName);-INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,- ExpectLoadingCompilerPropertyNotSupported,- ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),- ::testing::ValuesIn(unsupported_compiler_configs)),- PropertiesManagerTests::getTestCaseName);-INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,CompileLogLevelPropertyTests,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cppindex c4048a85808..f058118bacf 100644--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp@@ -72,10 +72,6 @@ const std::vector<ov::AnyMap> compatibilityPublicCompiledModelConfigs = {ov::Any(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})}},};-const std::vector<ov::AnyMap> publicCompiledModelConfigs = {- // execution_mode isn't supported with PV driver.- {{ov::hint::execution_mode.name(), ov::Any(ov::hint::ExecutionMode::PERFORMANCE)}}};-const std::vector<ov::AnyMap> compiledModelIncorrectConfigs = {{{"NPU_INEXISTENT_PROPERTY", "NPU_INEXISTENT_PROPERTY_VALUE"}}};@@ -272,12 +268,6 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTests,::testing::ValuesIn(compatibilityPublicCompiledModelConfigs)),ov::test::utils::appendPlatformTypeTestName<OVClassCompiledModelPropertiesDefaultTests>);-INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,- OVClassCompiledModelPropertiesDefaultTests,- ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),- ::testing::ValuesIn(publicCompiledModelConfigs)),- ov::test::utils::appendPlatformTypeTestName<OVClassCompiledModelPropertiesDefaultTests>);-INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,OVClassCompiledModelSetCorrectConfigTest,::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cppindex 16136939ab1..cc8f0cbee41 100644--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp@@ -89,7 +89,6 @@ const std::vector<ov::AnyMap> CorrectPluginDefaultMutableProperties = {const std::vector<std::string> ImmutableProperties{ov::supported_properties.name(),ov::streams::num.name(),- ov::optimal_number_of_infer_requests.name(),ov::intel_npu::device_alloc_mem_size.name(),ov::intel_npu::device_total_mem_size.name(),ov::intel_npu::driver_version.name(),@@ -117,7 +116,6 @@ const std::vector<ov::AnyMap> CorrectCompiledModelProperties = {};const std::vector<ov::AnyMap> IncorrectImmutableProperties = {- {{ov::optimal_number_of_infer_requests.name(), 4}},{{ov::intel_npu::device_alloc_mem_size.name(), 1024}},{{ov::intel_npu::device_total_mem_size.name(), 2048}},{{ov::intel_npu::driver_version.name(), 3}},diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xmlindex 5c299acd3b0..b5daf5ce90e 100644--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml@@ -396,4 +396,38 @@ Example:</filters></skip_config>+ <!-- C#191823 -->+ <skip_config>+ <message>HostCompile cannot compile the dynamic Add model because AdjustScaleShiftForDWConv requires static Reshape shapes.</message>+ <enable_rules>+ <device>4000</device>+ <device>5010</device>+ </enable_rules>+ <filters>+ <filter>.*DynamicBatchingTests.DynamicCheckMultipleBatchingRun0.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchingTests.DynamicCheckMultipleBatchingRunsSeq.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.DynamicSetInputRemoteTensorsMultipleInfer.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.DynamicSetInputRemoteTensorsDynamicBatchInflation.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.DynamicSetInputRemoteTensorsDynamicBatchDeflation.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.SetInputRemoteSingleBatchedTensorSingleInfer.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.SetInputRemoteSingleBatchedTensorSingleInferWithExportImport.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.SetInputRemoteSingleBatchedTensorDynamicBatchInflation.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.SetInputRemoteSingleBatchedTensorDynamicBatchInflationWithExportImport.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.SetInputRemoteSingleBatchedTensorDynamicBatchDeflation.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*DynamicBatchedTensorsRunTests.DynamicSetInputDifferentTensorsMultipleInfer.*NPU_BATCH_MODE_PLUGIN.*</filter>+ <filter>.*RoiTensorsTestsRun.RunStridedTensorWithDynamicBoundedBatching.*</filter>+ </filters>+ </skip_config>++ <skip_config>+ <message>HostCompile cannot compile the dynamic MaxPool model because ConvertBatchedLayerTo1N requires static AffineReshape shapes.</message>+ <enable_rules>+ <device>4000</device>+ <device>5010</device>+ </enable_rules>+ <filters>+ <filter>.*InferWithDefaultHostCompileTests.CompileDynamicModelWithNoHostCompileMode.*model=MaxPool_NCHW_DynBatch.*</filter>+ </filters>+ </skip_config>+</skip_configs>