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] Merge filtered_config into config and clean config.hpp and options.hpp (#38229)
Bogdan Pereanu725df052ed23
diff --git a/src/inference/include/openvino/runtime/intel_npu/properties.hpp b/src/inference/include/openvino/runtime/intel_npu/properties.hppindex fb7402d6fc9..a21e86ac0c9 100644--- a/src/inference/include/openvino/runtime/intel_npu/properties.hpp+++ b/src/inference/include/openvino/runtime/intel_npu/properties.hpp@@ -29,16 +29,11 @@ namespace intel_npu {* @brief [Only for NPU Plugin]* Type: string* Type of NPU compiler to be used for compilation of a network- * @note Configuration API v 2.0*/enum class CompilerType { PLUGIN, DRIVER, PREFER_PLUGIN };/*** @brief Prints a string representation of ov::intel_npu::CompilerType to a stream- * @param out An output stream to send to- * @param fmt A compiler type value to print to a stream- * @return A reference to the `out` stream- * @note Configuration API v 2.0*/inline std::ostream& operator<<(std::ostream& out, const CompilerType& fmt) {switch (fmt) {@@ -58,6 +53,24 @@ inline std::ostream& operator<<(std::ostream& out, const CompilerType& fmt) {return out;}+/**+ * @brief Reads a string representation of ov::intel_npu::CompilerType from a stream+ */+inline std::istream& operator>>(std::istream& is, CompilerType& fmt) {+ std::string str;+ is >> str;+ if (str == "PLUGIN") {+ fmt = CompilerType::PLUGIN;+ } else if (str == "DRIVER") {+ fmt = CompilerType::DRIVER;+ } else if (str == "PREFER_PLUGIN") {+ fmt = CompilerType::PREFER_PLUGIN;+ } else {+ OPENVINO_THROW("Unsupported value for the compiler type: ", str);+ }+ return is;+}+/*** @brief [Only for NPU Plugin]* Type: Arbitrary string.diff --git a/src/plugins/intel_npu/docs/npu-properties-howto.md b/src/plugins/intel_npu/docs/npu-properties-howto.mdindex 31fe465a0ca..daf3cfc6714 100644--- a/src/plugins/intel_npu/docs/npu-properties-howto.md+++ b/src/plugins/intel_npu/docs/npu-properties-howto.md@@ -146,54 +146,45 @@ struct OptionBase {// static std::string_view key()static constexpr std::string_view getTypeName() {- if constexpr (TypePrinter<T>::hasName()) {- return TypePrinter<T>::name();- }- static_assert(TypePrinter<T>::hasName(),- "Options type is not a standard type, please add `getTypeName()` to your option");- }- // Overload this to provide environment variable support.- static std::string_view envVar() {- return "";- }-- // Overload this to provide deprecated keys names.- static std::vector<std::string_view> deprecatedKeys() {- return {};- }-- // Overload this to provide default value if it wasn't specified by user.- // If it is std::nullopt - exception will be thrown in case of missing option access.- static std::optional<T> defaultValue() {- return std::nullopt;- }-- // Overload this to provide more specific parser.- static ValueType parse(std::string_view val) {- return OptionParser<ValueType>::parse(val);- }-- // Overload this to provide more specific validation- static void validateValue(const ValueType&) {}-- // Overload this to provide more specific implementation.- static OptionMode mode() {- return OptionMode::Both;- }-- // Overload this for private options.- static bool isPublic() {- return false;- }-- // Overload this for read-only properties- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-- static std::string toString(const ValueType& val) {- return OptionPrinter<ValueType>::toString(val);- }+ if constexpr (TypePrinter<T>::hasName()) {+ return TypePrinter<T>::name();+ }+ static_assert(TypePrinter<T>::hasName(),+ "Options type is not a standard type, please add `getTypeName()` to your option");+ }++ // Overload this to provide environment variable support.+ static std::string_view envVar() {+ return "";+ }++ // Overload this to provide deprecated keys names.+ static std::vector<std::string_view> deprecatedKeys() {+ return {};+ }++ // Overload this to provide default value if it wasn't specified by user.+ // If it is std::nullopt - exception will be thrown in case of missing option access.+ static std::optional<T> defaultValue() {+ return std::nullopt;+ }++ // Overload this to provide more specific parser.+ static ValueType parse(std::string_view val) {+ return OptionParser<ValueType>::parse(val);+ }++ // Overload this to provide more specific validation+ static void validateValue(const ValueType&) {}++ // Overload this to provide more specific implementation.+ static OptionMode mode() {+ return OptionMode::Both;+ }++ static std::string toString(const ValueType& val) {+ return OptionPrinter<ValueType>::toString(val);+ }};```@@ -206,13 +197,9 @@ then with the full plugin and backend options before property-manager initializa### Config`Config` is the high-level configuration database that maps `OptionBase` descriptors to typed option values. It maps andstores 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.+get/update/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 theshared `OptionsDesc` is populated and environment variables are reparsed.@@ -256,70 +243,75 @@ Example://// EXAMPLE_PROPERTY//-struct EXAMPLE_PROPERTY final : OptionBase<EXAMPLE_PROPERTY, ov::intel_npu::ExampleType> {+struct EXAMPLE_PROPERTY final : OptionBase<EXAMPLE_PROPERTY, ov::intel_npu::ExampleType> {- static std::string_view key() {+ static std::string_view key() {return ov::intel_npu::example_property.name();- }-- static constexpr std::string_view getTypeName() {- return "ov::intel_npu::ExampleType";- }-- static ov::intel_npu::ExampleType defaultValue() {- return ov::intel_npu::ExampleType::VAL3;- }-- 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 ov::intel_npu::ExampleType parse(std::string_view val) {- if (val == "VAL1") {- return ov::intel_npu::ExampleType::VAL1;- } else if (val == "VAL2") {- return ov::intel_npu::ExampleType::VAL2;- } else if (val == "VAL3") {- return ov::intel_npu::ExampleType::VAL3;- }-- OPENVINO_THROW("Value '", val, "'is not a valid EXAMPLE_PROPERTY option");- }-- static std::string toString(const ov::intel_npu::ExampleType& val) {- std::stringstream strStream;-- strStream << val;-- return strStream.str();- }-};+ }++ static constexpr std::string_view getTypeName() {+ return "ov::intel_npu::ExampleType";+ }++ static ov::intel_npu::ExampleType defaultValue() {+ return ov::intel_npu::ExampleType::VAL3;+ }++ static OptionMode mode() {+ return OptionMode::Both;+ }++ static std::string_view envVar() {+ return "IE_NPU_EXAMPLE_PROPERTY";+ }++ /*+ * @note `parse` / `toString` methods are optional. If the value type provides `operator>>` / `operator<<`,+ * the defaults in `OptionParser` / `OptionPrinter` handle it.+ * Only implement them for types with no stream operators, or when the string form differs from the stream form.+ */+ static ov::intel_npu::ExampleType parse(std::string_view val) {+ if (val == "VAL1") {+ return ov::intel_npu::ExampleType::VAL1;+ } else if (val == "VAL2") {+ return ov::intel_npu::ExampleType::VAL2;+ } else if (val == "VAL3") {+ return ov::intel_npu::ExampleType::VAL3;+ }++ OPENVINO_THROW("Value '", val, "' is not a valid EXAMPLE_PROPERTY option");+ }++ static void validateValue(const ov::intel_npu::ExampleType& val) {+ OPENVINO_ASSERT(val != ov::intel_npu::ExampleType::VAL2,+ "Wrong value ",+ val,+ " for property key ",+ ov::intel_npu::example_property.name(),+ ". Supported values: VAL1, VAL3");+ }++ static std::string toString(const ov::intel_npu::ExampleType& val) {+ std::stringstream strStream;++ strStream << val;++ return strStream.str();+ }+};```Notes:- 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)-- 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)- Runtime (for options only used by plugin and runtime)- Both (for options used by both).**Only options of CompileTime and Both will be sent to compiler at model compilation.**-- mutability: whether the option is **Read-Write** or **Read-Only**- envVar: environment variable (if needed) for this property. The config manager will check if the options have envVar defined. For each option which has envVar, it will look in environment variables and update the option value from there at init.- parse: string to custom datatype parser. If the property will be set with a string value, this parser will convert it into the internal datatype.+- validateValue: additional validation of the option value, called right after parsing (both for string and for `ov::Any` updates) and before the value is stored in the config. Use it to reject values which are of the correct datatype but out of the accepted range/set. If no extra validation is needed, do not define it - the default implementation accepts any parsed value.- toString: for converting the option value from the custom datatype to string**(!!)** None of the member functions are mandatory to be defined.@@ -351,13 +343,13 @@ register_property(return _config.get<EXAMPLE_PROPERTY>();},[this](const ov::Any& value) {- _config.updateAny(EXAMPLE_PROPERTY::key(), value);+ _config.update(EXAMPLE_PROPERTY::key(), value);});```**Explanation:**`register_property` stores the property name, visibility, mutability, support predicate, getter, and setter in onedescriptor. 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`.+`Config`, and the setter validates and stores the supplied value through `update`.### For compiled-model (if required)src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp > function CompiledModelPropertyManager::registerProperties()```cppdiff --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 776b3150c70..26fdc0876f7 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@@ -5,6 +5,7 @@#pragma once#include <cassert>+#include <cctype>#include <chrono>#include <functional>#include <iomanip>@@ -70,8 +71,57 @@ TYPE_PRINTER(std::size_t)// OptionParser//+namespace details {++template <typename T, typename = void>+struct IsIStreamable : std::false_type {};++template <typename T>+struct IsIStreamable<T, std::void_t<decltype(std::declval<std::istream&>() >> std::declval<T&>())>> : std::true_type {};++// NB: detecting `operator<<` instead would be useless for unscoped enums, since those promote to their+// underlying integral type and therefore always match one of the built-in `operator<<` overloads.+template <typename T, typename = void>+struct HasStringifyEnum : std::false_type {};++template <typename T>+struct HasStringifyEnum<T, std::void_t<decltype(stringifyEnum(std::declval<const T&>()))>> : std::true_type {};++// `operator>>` stops at the first character it can't consume, so a successfully parsed prefix alone is not+// enough to accept a value. Returns false when anything besides trailing whitespace is left in the stream.+inline bool isFullyConsumed(std::istream& stream) {+ for (auto next = stream.peek(); next != std::istream::traits_type::eof(); next = stream.peek()) {+ if (!std::isspace(static_cast<unsigned char>(next))) {+ return false;+ }+ stream.ignore();+ }++ return true;+}++} // namespace details++// Default parser, relies on the `operator>>` declared for the value type. All the `ov::` property enums and+// wrappers provide one, so enum options usually don't need any parsing code of their own. Specialize this+// template or override `parse()` inside the option for types which have no such operator.template <typename T>-struct OptionParser;+struct OptionParser {+ static T parse(std::string_view val) {+ static_assert(details::IsIStreamable<T>::value,+ "No `operator>>` is available for the option type, please provide either an `OptionParser` "+ "specialization or a `parse()` implementation inside the option");++ std::istringstream stream{std::string(val)};+ T res{};+ stream >> res;+ OPENVINO_ASSERT(!stream.fail(), "Value '", val, "' is not a valid option value");+ // Reject values whose prefix alone is valid, e.g. "PLUGIN garbage" for an enum option+ OPENVINO_ASSERT(details::isFullyConsumed(stream), "Value '", val, "' is not a valid option value");++ return res;+ }+};template <>struct OptionParser<std::string> final {@@ -110,16 +160,6 @@ struct OptionParser<double> final {static double parse(std::string_view val);};-template <>-struct OptionParser<ov::log::Level> final {- static ov::log::Level parse(std::string_view val);-};--template <>-struct OptionParser<ov::hint::ExecutionMode> final {- static ov::hint::ExecutionMode parse(std::string_view val);-};-void splitAndApply(const std::string& str, char delim, std::function<void(std::string_view)> callback);template <typename T>@@ -153,10 +193,11 @@ struct OptionParser<std::map<K, V>> final {template <typename Rep, typename Period>struct OptionParser<std::chrono::duration<Rep, Period>> final {static std::chrono::duration<Rep, Period> parse(std::string_view val) {- std::istringstream stream(val.data());+ std::istringstream stream{std::string(val)};Rep count{};- if (stream >> count) {+ // Anything left in the stream means the value is malformed, e.g. "12oops"+ if (stream >> count && details::isFullyConsumed(stream)) {OPENVINO_ASSERT(count >= 0,"Value '",count,@@ -164,7 +205,7 @@ struct OptionParser<std::chrono::duration<Rep, Period>> final {return std::chrono::duration<Rep, Period>(count);}- OPENVINO_THROW("Can't parse '", val.data(), "' as time duration");+ OPENVINO_THROW("Can't parse '", val, "' as time duration");}};@@ -178,7 +219,8 @@ struct OptionPrinter final {std::stringstream ss;if constexpr (std::is_floating_point_v<std::decay_t<T>>) {ss << std::fixed << std::setprecision(2) << val;- } else if constexpr (std::is_enum_v<std::decay_t<T>>) {+ } else if constexpr (std::is_enum_v<std::decay_t<T>> && details::HasStringifyEnum<std::decay_t<T>>::value) {+ // A `stringifyEnum` overload wins over an `operator<<`, enums are expected to provide either of the twoss << stringifyEnum(val);} else {ss << val;@@ -219,16 +261,6 @@ struct OptionPrinter<std::chrono::duration<Rep, Period>> final {}};-template <>-struct OptionPrinter<ov::log::Level> final {- static std::string toString(ov::log::Level val);-};--template <>-struct OptionPrinter<ov::hint::ExecutionMode> final {- static std::string toString(ov::hint::ExecutionMode val);-};-//// OptionMode//@@ -260,6 +292,7 @@ struct OptionBase {static_assert(TypePrinter<T>::hasName(),"Options type is not a standard type, please add `getTypeName()` to your option");}+// Overload this to provide environment variable support.static std::string_view envVar() {return "";@@ -289,26 +322,6 @@ struct OptionBase {return OptionMode::Both;}- // Overload this for public options.- static bool isPublic() {- return false;- }-- // Overload this for read-only options (metrics)- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-- static bool isValueSupported(std::string_view val) {- try {- (void)ActualOpt::parse(val);- return true;- } catch (...) {- // failed to parse, return false below- }- return false;- }-static std::string toString(const ValueType& val) {return OptionPrinter<ValueType>::toString(val);}@@ -370,41 +383,40 @@ struct OptionConcept final {std::string_view (*key)() = nullptr;std::string_view (*envVar)() = nullptr;OptionMode (*mode)() = nullptr;- bool (*isPublic)() = nullptr;- ov::PropertyMutability (*mutability)() = nullptr;- bool (*isValueSupportedImpl)(std::string_view val) =- nullptr; // better make this private, but won't be able to use aggregate initialization anymore in- // "makeOptionModel"- std::shared_ptr<OptionValue> (*validateAndParseFromString)(std::string_view val) = nullptr;- std::shared_ptr<OptionValue> (*validateAndParseFromAny)(const ov::Any& val) = nullptr;- std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt = std::nullopt;- bool isValueSupported(std::string_view val) {- if (customValueCheckerOpt.has_value()) {- return customValueCheckerOpt.value()(val);- }- return isValueSupportedImpl(val);- }+ std::shared_ptr<OptionValue> (*validateAndParse)(const ov::Any& val) = nullptr;};-template <class Opt>-std::shared_ptr<OptionValue> validateAndParseFromString(std::string_view val) {- using ValueType = typename Opt::ValueType;-- try {- auto parsedVal = Opt::parse(val);- Opt::validateValue(parsedVal);- return std::make_shared<OptionValueImpl<Opt, ValueType>>(std::move(parsedVal), &Opt::toString);- } catch (const std::exception& e) {- OPENVINO_THROW("Failed to parse '", Opt::key().data(), "' option : ", e.what());- }+// `ov::Any::as<std::string>()` is lenient where the option parsers are not: it yields an empty string both+// for an empty `ov::Any` and for a payload whose type provides neither `operator<<` nor an+// `ov::util::Write` specialization (its `print()` is then a no-op). Parsers which accept an empty spelling as+// "nothing to parse" (`std::string`, `std::vector`, `std::map`) would silently turn such a payload into an+// empty option value, so reject it here instead. An empty spelling is only let through when it really was+// given as a string.+inline std::string stringifyForParsing(const ov::Any& val) {+ OPENVINO_ASSERT(!val.empty(), "No value was provided");++ auto valAsString = val.as<std::string>();+ OPENVINO_ASSERT(!valAsString.empty() || val.is<std::string>(),+ "Value of type '",+ val.type_info().name(),+ "' can't be converted to a string");++ return valAsString;}template <class Opt>-std::shared_ptr<OptionValue> validateAndParseFromAny(const ov::Any& val) {+std::shared_ptr<OptionValue> validateAndParse(const ov::Any& val) {using ValueType = typename Opt::ValueType;try {- auto parsedVal = val.as<ValueType>();+ // Only a payload which already has the option's exact type is taken as is. Everything else - the string+ // spellings coming from `update()` as well as any other type - is routed through the option's own+ // parser, so that string based and `ov::Any` based updates accept exactly the same values and any+ // custom `parse()` is honored. `ov::Any::as<ValueType>()` would otherwise perform an unchecked+ // arithmetic conversion (e.g. -2.0f silently wrapping around into a `uint32_t`, which then passes the+ // option validation) or re-parse a string on its own, through `operator>>`, bypassing the option+ // entirely. For options which are themselves strings the parser is an identity conversion.+ auto parsedVal = val.is<ValueType>() ? val.as<ValueType>() : Opt::parse(stringifyForParsing(val));Opt::validateValue(parsedVal);return std::make_shared<OptionValueImpl<Opt, ValueType>>(std::move(parsedVal), &Opt::toString);} catch (const std::exception& e) {@@ -413,17 +425,8 @@ std::shared_ptr<OptionValue> validateAndParseFromAny(const ov::Any& val) {}template <class Opt>-OptionConcept makeOptionModel(- std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt = std::nullopt) {- return {&Opt::key,- &Opt::envVar,- &Opt::mode,- &Opt::isPublic,- &Opt::mutability,- &Opt::isValueSupported,- &validateAndParseFromString<Opt>,- &validateAndParseFromAny<Opt>,- std::move(customValueCheckerOpt)};+OptionConcept makeOptionModel() {+ return {&Opt::key, &Opt::envVar, &Opt::mode, &validateAndParse<Opt>};}} // namespace details@@ -435,16 +438,12 @@ OptionConcept makeOptionModel(class OptionsDesc final {public:template <class Opt>- void add(std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt = std::nullopt);+ void add();bool has(std::string_view key) const;void reset();- std::vector<std::string> getSupported(bool includePrivate = false) const;- std::vector<ov::PropertyName> getSupportedOptions(bool includePrivate = false) const;- std::string getSupportedAsString(bool includePrivate = false) const;-details::OptionConcept get(std::string_view key) const;void walk(std::function<void(const details::OptionConcept&)> cb) const;@@ -455,9 +454,9 @@ private:};template <class Opt>-void OptionsDesc::add(std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt) {+void OptionsDesc::add() {OPENVINO_ASSERT(_impl.count(Opt::key().data()) == 0, "Option '", Opt::key().data(), "' was already registered");- _impl.insert({Opt::key().data(), details::makeOptionModel<Opt>(std::move(customValueCheckerOpt))});+ _impl.insert({Opt::key().data(), details::makeOptionModel<Opt>()});for (const auto& deprecatedKey : Opt::deprecatedKeys()) {OPENVINO_ASSERT(_deprecated.count(deprecatedKey.data()) == 0,@@ -472,45 +471,137 @@ void OptionsDesc::add(std::optional<std::function<bool(std::string_view)>> custo// Config//-class Config {+class Config final {public:using ConfigMap = std::map<std::string, std::string>;- using ImplMap = std::unordered_map<std::string_view, std::shared_ptr<details::OptionValue>>;+ /**+ * @brief Constructs a configuration bound to the given options descriptor.+ * @param desc Descriptor holding the set of options accepted by this configuration. Must not be null.+ */explicit Config(const std::shared_ptr<const OptionsDesc>& desc);+ /**+ * @brief Parses and stores all the given key/value pairs, overwriting previously set values.+ * @param options Map of option keys to their string representation.+ */void update(const ConfigMap& options);- 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);+ /**+ * @brief Parses and stores a single option value, overwriting a previously set one.+ * @param key The key of the option to set.+ * @param value The value to set, in its native "ov::Any" representation.+ */+ void update(std::string_view key, const ov::Any& value);++ /**+ * @brief Sets the options for which an associated environment variable is defined and exported.+ * Values which cannot be parsed are ignored and only reported as warnings.+ */void parseEnvVars();+ /**+ * @brief Checks if a value has been set for the given option.+ * @tparam Opt The option to check.+ * @return True if a value was set, false if only the default value (if any) is available.+ */template <class Opt>bool has() const;- bool has(std::string key) const;- void remove(std::string key);+ /**+ * @brief Checks if a value has been set for the option identified by the given key.+ * @param key The key of the option to check.+ * @return True if a value was set, false if only the default value (if any) is available.+ */+ bool has(std::string_view key) const;+ /**+ * @brief Erases the value set for the given option key. Does nothing if no value was set.+ * @param key The key of the option to erase.+ */+ void remove(std::string_view key);++ /**+ * @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 removeCompileTimeConfigs();++ /**+ * @brief Retrieves the value of the given option, falling back to its default value if none was set.+ * @tparam Opt The option to retrieve.+ * @return The option's value.+ * @throws ov::Exception If no value was set and the option has no default value.+ */template <class Opt>typename Opt::ValueType get() const;+ /**+ * @brief Retrieves the value of the given option as a string, using the same fallback rules as "get".+ * @tparam Opt The option to retrieve.+ * @return The string representation of the option's value.+ */template <class Opt>typename std::string getString() const;+ /**+ * @brief Restores the configuration from a string previously produced by "toString".+ * @param str A space-separated sequence of KEY="VALUE" entries.+ */void fromString(const std::string& str);// Returns a string with all config keys which have set valuesstd::string toString() const;- virtual ~Config() = default;+ /**+ * @brief Checks if a specific option exists in the configuration's descriptor.+ * @param key The key of the option to check.+ * @return True if the option exists, false otherwise.+ */+ bool hasOpt(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.+ * @return The `OptionConcept` object representing the option's details.+ */+ details::OptionConcept getOpt(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.+ */+ void addOrUpdateInternal(std::string key, std::string value);++ /**+ * @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.+ */+ bool hasInternal(std::string_view key) const;++ /**+ * @brief Retrieves an internal configuration value by its key.+ * @param key The key of the internal configuration to retrieve.+ * @return The value associated with the specified internal configuration key.+ */+ std::string getInternal(std::string_view key) const;++ /**+ * @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::function<bool(const std::string&)>& isSupported) const;-protected:+private:std::shared_ptr<const OptionsDesc> _desc;- ImplMap _impl;+ std::unordered_map<std::string_view, std::shared_ptr<details::OptionValue>> _impl;++ ConfigMap _internal_compiler_configs; ///< Map to store internal (hidden) configurations used for compiler.-private:Logger _log{Logger::global().clone("Config")};};@@ -568,10 +659,4 @@ typename std::string Config::getString() const {return Opt::toString(value);}-//-// envVarStrToBool-//--bool envVarStrToBool(const char* varName, const char* varValue);-} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hppindex c74626f3f50..c7bad4d2db7 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/npuw.hpp@@ -83,10 +83,6 @@ void registerNPUWKokoroOptions(OptionsDesc& desc);\static OptionMode mode() { \return OptionMode::RunTime; \- } \- \- static bool isPublic() { \- return false; \} \};@@ -313,10 +309,6 @@ struct NPUWStringEnumOptionBase : OptionBase<ActualOpt, typename Traits::ValueTystatic OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return false;- }};#define DEFINE_NPUW_STRING_ENUM_OPT(Name, Traits, KeyLiteral) \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 25bd371c90f..22b3d4855fc 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@@ -27,50 +27,9 @@ struct PERFORMANCE_HINT final : OptionBase<PERFORMANCE_HINT, ov::hint::Performanreturn ov::hint::PerformanceMode::LATENCY;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::Both;}-- static ov::hint::PerformanceMode parse(std::string_view val) {- if (val.empty()) {- return ov::hint::PerformanceMode::LATENCY;- } else if (val == "LATENCY") {- return ov::hint::PerformanceMode::LATENCY;- } else if (val == "THROUGHPUT") {- return ov::hint::PerformanceMode::THROUGHPUT;- } else if (val == "CUMULATIVE_THROUGHPUT") {- return ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT;- }-- OPENVINO_THROW("Value '", val, "' is not a valid PERFORMANCE_HINT option");- }-- static std::string toString(const ov::hint::PerformanceMode& val) {- std::stringstream strStream;- switch (val) {- case ov::hint::PerformanceMode::LATENCY:- strStream << "LATENCY";- break;- case ov::hint::PerformanceMode::THROUGHPUT:- strStream << "THROUGHPUT";- break;- case ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT:- strStream << "CUMULATIVE_THROUGHPUT";- break;- default:- OPENVINO_THROW("Invalid ov::hint::PerformanceMode setting");- break;- }- return strStream.str();- }};struct PERFORMANCE_HINT_NUM_REQUESTS final : OptionBase<PERFORMANCE_HINT_NUM_REQUESTS, uint32_t> {@@ -78,44 +37,12 @@ struct PERFORMANCE_HINT_NUM_REQUESTS final : OptionBase<PERFORMANCE_HINT_NUM_REQreturn ov::hint::num_requests.name();}- /**- * @brief Returns configuration value if it is valid, otherwise throws- * @details This is the same function as "InferenceEngine::PerfHintsConfig::CheckPerformanceHintRequestValue",- * slightly modified as to not rely on the legacy API anymore.- * @param configuration value as string- * @return configuration value as number- */- static uint32_t parse(std::string_view val) {- int val_i = -1;- try {- val_i = std::stoi(val.data());- if (val_i >= 0)- return val_i;- else- throw std::logic_error("wrong val");- } catch (const std::exception&) {- OPENVINO_THROW("Wrong value of ",- val.data(),- " for property key ",- ov::hint::num_requests.name(),- ". Expected only positive integer numbers");- }- }-static uint32_t defaultValue() {// Default value depends on PERFORMANCE_HINT, see getOptimalNumberOfInferRequestsInParallel// 1 corresponds to LATENCY and default mode (hints not specified)return 1u;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -134,31 +61,18 @@ struct INFERENCE_PRECISION_HINT final : OptionBase<INFERENCE_PRECISION_HINT, ov:return ov::element::f16;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::CompileTime;}- static ov::element::Type parse(std::string_view val) {- if (val.empty() || (val == "f16")) {- return ov::element::f16;- } else if (val == "i8") {- return ov::element::i8;- } else {- OPENVINO_THROW("Wrong value ",- val.data(),- " for property key ",- ov::hint::inference_precision.name(),- ". Supported values: f16, i8");- }- };+ static void validateValue(const ov::element::Type& val) {+ OPENVINO_ASSERT(val == ov::element::f16 || val == ov::element::i8,+ "Wrong value ",+ val.to_string(),+ " for property key ",+ ov::hint::inference_precision.name(),+ ". Supported values: f16, i8");+ }};struct PERF_COUNT final : OptionBase<PERF_COUNT, bool> {@@ -170,14 +84,6 @@ struct PERF_COUNT final : OptionBase<PERF_COUNT, bool> {return false;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::Both;}@@ -207,10 +113,6 @@ struct LOG_LEVEL final : OptionBase<LOG_LEVEL, ov::log::Level> {return ov::log::Level::ERR;#endif}-- static bool isPublic() {- return true;- }};// The option is intentionally left without a default value: an unset option means it inherits LOG_LEVEL, which@@ -236,10 +138,6 @@ struct COMPILE_LOG_LEVEL final : OptionBase<COMPILE_LOG_LEVEL, ov::log::Level> {return OptionMode::RunTime;}- static bool isPublic() {- return false;- }-/*** @brief Returns the effective compile log level.* @param config The configuration to resolve the compile log level against.@@ -269,17 +167,9 @@ struct PLATFORM final : OptionBase<PLATFORM, std::string> {}#endif- static bool isPublic() {- return true;- }-static OptionMode mode() {return OptionMode::CompileTime;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct DEVICE_ID final : OptionBase<DEVICE_ID, std::string> {@@ -291,14 +181,6 @@ struct DEVICE_ID final : OptionBase<DEVICE_ID, std::string> {return {};}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -313,14 +195,6 @@ struct CACHE_DIR final : OptionBase<CACHE_DIR, std::string> {return {};}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -339,30 +213,9 @@ struct CACHE_MODE final : OptionBase<CACHE_MODE, ov::CacheMode> {return ov::CacheMode::OPTIMIZE_SPEED;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::CompileTime;}-- static ov::CacheMode parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::CacheMode cacheMode;- stringStream >> cacheMode;- return cacheMode;- }-- static std::string toString(const ov::CacheMode& val) {- std::stringstream strStream;- strStream << val;- return strStream.str();- }};struct COMPILED_BLOB final : OptionBase<COMPILED_BLOB, ov::Tensor> {@@ -378,22 +231,16 @@ struct COMPILED_BLOB final : OptionBase<COMPILED_BLOB, ov::Tensor> {return ov::Tensor();}- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}static ov::Tensor parse(std::string_view) {- // Cannot/shouldn't parse this due to conversion and ownership reasons. The config option is added only to- // comply with the OV API without inserting multiple workarounds.- return defaultValue();+ OPENVINO_THROW("Option ", ov::hint::compiled_blob.name(), " cannot be parsed from string");}static std::string toString(const ov::Tensor&) {- return "";+ OPENVINO_THROW("Option ", ov::hint::compiled_blob.name(), " cannot be converted to string");}};@@ -406,10 +253,6 @@ struct LOADED_FROM_CACHE final : OptionBase<LOADED_FROM_CACHE, bool> {return false;}- static bool isPublic() {- return true;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -424,10 +267,6 @@ struct CACHING_PROPERTIES final : OptionBase<CACHING_PROPERTIES, std::string> {return {};}- static bool isPublic() {- return false;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -447,33 +286,9 @@ struct BATCH_MODE final : OptionBase<BATCH_MODE, ov::intel_npu::BatchMode> {return ov::intel_npu::BatchMode::AUTO;}- static bool isPublic() {- return false;- }-static OptionMode mode() {return OptionMode::CompileTime;}-- static ov::intel_npu::BatchMode parse(std::string_view val) {- if (val == "AUTO") {- return ov::intel_npu::BatchMode::AUTO;- } else if (val == "COMPILER") {- return ov::intel_npu::BatchMode::COMPILER;- } else if (val == "PLUGIN") {- return ov::intel_npu::BatchMode::PLUGIN;- }-- OPENVINO_THROW("Value '", val, "'is not a valid BATCH_MODE option");- }-- static std::string toString(const ov::intel_npu::BatchMode& val) {- std::stringstream strStream;-- strStream << val;-- return strStream.str();- }};struct PROFILING_TYPE final : OptionBase<PROFILING_TYPE, ov::intel_npu::ProfilingType> {@@ -489,40 +304,9 @@ struct PROFILING_TYPE final : OptionBase<PROFILING_TYPE, ov::intel_npu::Profilinreturn ov::intel_npu::ProfilingType::MODEL;}- static ov::intel_npu::ProfilingType parse(std::string_view val) {- if (val == "MODEL") {- return ov::intel_npu::ProfilingType::MODEL;- } else if (val == "INFER") {- return ov::intel_npu::ProfilingType::INFER;- }-- OPENVINO_THROW("Value '", val, "' is not a valid PROFILING_TYPE option");- }-- static std::string toString(const ov::intel_npu::ProfilingType& val) {- std::stringstream strStream;- if (val == ov::intel_npu::ProfilingType::MODEL) {- strStream << "MODEL";- } else if (val == ov::intel_npu::ProfilingType::INFER) {- strStream << "INFER";- } else {- OPENVINO_THROW("No valid string for current PROFILING_TYPE option");- }-- return strStream.str();- }-static OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct MODEL_PRIORITY final : OptionBase<MODEL_PRIORITY, ov::hint::Priority> {@@ -538,34 +322,9 @@ struct MODEL_PRIORITY final : OptionBase<MODEL_PRIORITY, ov::hint::Priority> {return ov::hint::Priority::MEDIUM;}- static ov::hint::Priority parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::hint::Priority priority;-- stringStream >> priority;-- return priority;- }-- static std::string toString(const ov::hint::Priority& val) {- std::ostringstream stringStream;-- stringStream << val;-- return stringStream.str();- }-static OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct MODEL_PTR final : OptionBase<MODEL_PTR, std::weak_ptr<const ov::Model>> {@@ -609,14 +368,6 @@ struct CREATE_EXECUTOR final : OptionBase<CREATE_EXECUTOR, int64_t> {}#endif- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -626,20 +377,17 @@ struct DEFER_WEIGHTS_LOAD final : OptionBase<DEFER_WEIGHTS_LOAD, bool> {static std::string_view key() {return ov::intel_npu::defer_weights_load.name();}- static int64_t defaultValue() {++ static bool defaultValue() {return false;}- static constexpr std::string_view getTypeName() {- return "bool";- }+#ifdef NPU_PLUGIN_DEVELOPER_BUILDstatic std::string_view envVar() {return "OV_NPU_DEFER_WEIGHTS_LOAD";}#endif- static bool isPublic() {- return true;- }+static OptionMode mode() {return OptionMode::RunTime;}@@ -650,10 +398,6 @@ struct WEIGHTS_PATH final : OptionBase<WEIGHTS_PATH, std::string> {return ov::weights_path.name();}- static constexpr std::string_view getTypeName() {- return "std::string";- }-static std::string defaultValue() {return "";}@@ -661,14 +405,6 @@ struct WEIGHTS_PATH final : OptionBase<WEIGHTS_PATH, std::string> {static OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct NUM_STREAMS final : OptionBase<NUM_STREAMS, ov::streams::Num> {@@ -684,21 +420,6 @@ struct NUM_STREAMS final : OptionBase<NUM_STREAMS, ov::streams::Num> {return ov::streams::AUTO;}- static ov::streams::Num parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::streams::Num numberOfStreams;- stringStream >> numberOfStreams;-- return numberOfStreams;- }-- static std::string toString(const ov::streams::Num& val) {- std::ostringstream stringStream;- stringStream << val;-- return stringStream.str();- }-static void validateValue(const ov::streams::Num& num) {if (num != ov::streams::AUTO && num < 0) {OPENVINO_THROW("NUM_STREAMS cannot be set to this value: ",@@ -710,14 +431,6 @@ struct NUM_STREAMS final : OptionBase<NUM_STREAMS, ov::streams::Num> {static OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};OPENVINO_SUPPRESS_DEPRECATED_START@@ -737,10 +450,6 @@ struct OPENVINO_DEPRECATED("This property is deprecated and has no effect on the"be removed in the OpenVINO 2027.0 release.";}- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -756,10 +465,6 @@ struct WORKLOAD_TYPE final : OptionBase<WORKLOAD_TYPE, ov::WorkloadType> {return ov::WorkloadType::DEFAULT;}- static bool isPublic() {- return true;- }-static constexpr std::string_view getTypeName() {return "ov::WorkloadType";}@@ -767,25 +472,6 @@ struct WORKLOAD_TYPE final : OptionBase<WORKLOAD_TYPE, ov::WorkloadType> {static OptionMode mode() {return OptionMode::RunTime;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-- static ov::WorkloadType parse(std::string_view val) {- std::istringstream ss = std::istringstream(std::string(val));- ov::WorkloadType workloadType;-- ss >> workloadType;-- return workloadType;- }-- static std::string toString(const ov::WorkloadType& val) {- std::ostringstream ss;- ss << val;- return ss.str();- }};struct TURBO final : OptionBase<TURBO, bool> {@@ -797,17 +483,9 @@ struct TURBO final : OptionBase<TURBO, bool> {return false;}- static bool isPublic() {- return true;- }-static OptionMode mode() {return OptionMode::Both;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct COMPILER_TYPE final : OptionBase<COMPILER_TYPE, ov::intel_npu::CompilerType> {@@ -831,44 +509,9 @@ struct COMPILER_TYPE final : OptionBase<COMPILER_TYPE, ov::intel_npu::CompilerTyreturn ov::intel_npu::CompilerType::PREFER_PLUGIN;}- static ov::intel_npu::CompilerType parse(std::string_view val) {- if (val == "PLUGIN") {- return ov::intel_npu::CompilerType::PLUGIN;- } else if (val == "DRIVER") {- return ov::intel_npu::CompilerType::DRIVER;- } else if (val == "PREFER_PLUGIN") {- return ov::intel_npu::CompilerType::PREFER_PLUGIN;- }-- OPENVINO_THROW("Value '", val, "' is not a valid COMPILER_TYPE option");- }-- static std::string toString(const ov::intel_npu::CompilerType& val) {- std::stringstream strStream;- if (val == ov::intel_npu::CompilerType::PLUGIN) {- strStream << "PLUGIN";- } else if (val == ov::intel_npu::CompilerType::DRIVER) {- strStream << "DRIVER";- } else if (val == ov::intel_npu::CompilerType::PREFER_PLUGIN) {- strStream << "PREFER_PLUGIN";- } else {- OPENVINO_THROW("No valid string for current COMPILER_TYPE option");- }-- return strStream.str();- }-static OptionMode mode() {return OptionMode::RunTime;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-- static bool isPublic() {- return true;- }};struct COMPILER_VERSION final : OptionBase<COMPILER_VERSION, uint32_t> {@@ -883,14 +526,6 @@ struct COMPILER_VERSION final : OptionBase<COMPILER_VERSION, uint32_t> {static OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RO;- }};struct COMPILATION_MODE final : OptionBase<COMPILATION_MODE, std::string> {@@ -911,14 +546,6 @@ struct COMPILATION_MODE final : OptionBase<COMPILATION_MODE, std::string> {static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct EXECUTION_MODE_HINT final : OptionBase<EXECUTION_MODE_HINT, ov::hint::ExecutionMode> {@@ -937,14 +564,6 @@ struct EXECUTION_MODE_HINT final : OptionBase<EXECUTION_MODE_HINT, ov::hint::Exestatic OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct DYNAMIC_SHAPE_TO_STATIC final : OptionBase<DYNAMIC_SHAPE_TO_STATIC, bool> {@@ -965,14 +584,6 @@ struct DYNAMIC_SHAPE_TO_STATIC final : OptionBase<DYNAMIC_SHAPE_TO_STATIC, bool>static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct COMPILATION_MODE_PARAMS final : OptionBase<COMPILATION_MODE_PARAMS, std::string> {@@ -987,14 +598,6 @@ struct COMPILATION_MODE_PARAMS final : OptionBase<COMPILATION_MODE_PARAMS, std::static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct TILES final : OptionBase<TILES, int64_t> {@@ -1014,14 +617,6 @@ struct TILES final : OptionBase<TILES, int64_t> {return OptionMode::CompileTime;}- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-#ifdef NPU_PLUGIN_DEVELOPER_BUILDstatic std::string_view envVar() {return "IE_NPU_TILES";@@ -1045,14 +640,6 @@ struct STEPPING final : OptionBase<STEPPING, int64_t> {static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct MAX_TILES final : OptionBase<MAX_TILES, int64_t> {@@ -1071,14 +658,6 @@ struct MAX_TILES final : OptionBase<MAX_TILES, int64_t> {static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RO;- }};struct DMA_ENGINES final : OptionBase<DMA_ENGINES, int64_t> {@@ -1098,14 +677,6 @@ struct DMA_ENGINES final : OptionBase<DMA_ENGINES, int64_t> {return OptionMode::CompileTime;}- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-#ifdef NPU_PLUGIN_DEVELOPER_BUILDstatic std::string_view envVar() {return "IE_NPU_DMA_ENGINES";@@ -1125,14 +696,6 @@ struct BACKEND_COMPILATION_PARAMS final : OptionBase<BACKEND_COMPILATION_PARAMS,static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return false;- }-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct COMPILATION_NUM_THREADS final : OptionBase<COMPILATION_NUM_THREADS, int32_t> {@@ -1153,14 +716,6 @@ struct COMPILATION_NUM_THREADS final : OptionBase<COMPILATION_NUM_THREADS, int32static OptionMode mode() {return OptionMode::CompileTime;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }-- static bool isPublic() {- return true;- }};struct COMPILER_DYNAMIC_QUANTIZATION final : OptionBase<COMPILER_DYNAMIC_QUANTIZATION, bool> {@@ -1175,10 +730,6 @@ struct COMPILER_DYNAMIC_QUANTIZATION final : OptionBase<COMPILER_DYNAMIC_QUANTIZstatic OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }};struct BYPASS_UMD_CACHING final : OptionBase<BYPASS_UMD_CACHING, bool> {@@ -1190,17 +741,9 @@ struct BYPASS_UMD_CACHING final : OptionBase<BYPASS_UMD_CACHING, bool> {return false;}- static bool isPublic() {- return true;- }-static OptionMode mode() {return OptionMode::RunTime;}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::RW;- }};struct RUN_INFERENCES_SEQUENTIALLY final : OptionBase<RUN_INFERENCES_SEQUENTIALLY, bool> {@@ -1212,10 +755,6 @@ struct RUN_INFERENCES_SEQUENTIALLY final : OptionBase<RUN_INFERENCES_SEQUENTIALLreturn false;}- static bool isPublic() {- return true;- }-static OptionMode mode() {return OptionMode::RunTime;}@@ -1233,10 +772,6 @@ struct QDQ_OPTIMIZATION final : OptionBase<QDQ_OPTIMIZATION, bool> {static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }};struct QDQ_OPTIMIZATION_AGGRESSIVE final : OptionBase<QDQ_OPTIMIZATION_AGGRESSIVE, bool> {@@ -1251,10 +786,6 @@ struct QDQ_OPTIMIZATION_AGGRESSIVE final : OptionBase<QDQ_OPTIMIZATION_AGGRESSIVstatic OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }};struct DISABLE_VERSION_CHECK final : OptionBase<DISABLE_VERSION_CHECK, bool> {@@ -1343,10 +874,6 @@ struct BATCH_COMPILER_MODE_SETTINGS final : OptionBase<BATCH_COMPILER_MODE_SETTIstatic OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return false;- }};struct ENABLE_WEIGHTLESS final : OptionBase<ENABLE_WEIGHTLESS, bool> {@@ -1378,19 +905,6 @@ struct SEPARATE_WEIGHTS_VERSION final : OptionBase<SEPARATE_WEIGHTS_VERSION, ov:return ov::intel_npu::WSVersion::ITERATIVE;}- static ov::intel_npu::WSVersion parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::intel_npu::WSVersion wsVersion;- stringStream >> wsVersion;- return wsVersion;- }-- static std::string toString(const ov::intel_npu::WSVersion& val) {- std::stringstream strStream;- strStream << val;- return strStream.str();- }-static OptionMode mode() {return OptionMode::CompileTime;}@@ -1405,24 +919,6 @@ struct WS_COMPILE_CALL_NUMBER final : OptionBase<WS_COMPILE_CALL_NUMBER, uint32_return 0;}- static uint32_t parse(std::string_view val) {- int val_i = -1;- try {- val_i = std::stoi(val.data());- if (val_i >= 0) {- return val_i;- } else {- throw std::logic_error("wrong val");- }- } catch (const std::exception&) {- OPENVINO_THROW("Wrong value of ",- val.data(),- " for property key ",- ov::intel_npu::ws_compile_call_number.name(),- ". Expected only positive integer numbers");- }- }-static OptionMode mode() {return OptionMode::CompileTime;}@@ -1441,19 +937,6 @@ struct MODEL_SERIALIZER_VERSION final : OptionBase<MODEL_SERIALIZER_VERSION, ov:return ov::intel_npu::ModelSerializerVersion::AUTO;}- static ov::intel_npu::ModelSerializerVersion parse(std::string_view val) {- std::istringstream stringStream = std::istringstream(std::string(val));- ov::intel_npu::ModelSerializerVersion version;- stringStream >> version;- return version;- }-- static std::string toString(const ov::intel_npu::ModelSerializerVersion& val) {- std::stringstream strStream;- strStream << val;- return strStream.str();- }-static OptionMode mode() {return OptionMode::CompileTime;}@@ -1471,10 +954,6 @@ struct ENABLE_STRIDES_FOR final : OptionBase<ENABLE_STRIDES_FOR, std::string> {static OptionMode mode() {return OptionMode::CompileTime;}-- static bool isPublic() {- return true;- }};struct DISABLE_IDLE_MEMORY_PRUNING final : OptionBase<DISABLE_IDLE_MEMORY_PRUNING, bool> {@@ -1489,10 +968,6 @@ struct DISABLE_IDLE_MEMORY_PRUNING final : OptionBase<DISABLE_IDLE_MEMORY_PRUNINstatic OptionMode mode() {return OptionMode::RunTime;}-- static bool isPublic() {- return true;- }};struct SHARED_COMMON_QUEUE final : OptionBase<SHARED_COMMON_QUEUE, bool> {@@ -1522,10 +997,6 @@ struct CACHE_ENCRYPTION_CALLBACKS final : OptionBase<CACHE_ENCRYPTION_CALLBACKS,return OptionMode::RunTime;}- static bool isPublic() {- return true;- }-static std::string toString(const ov::EncryptionCallbacks&) {OPENVINO_THROW("Option ", ov::cache_encryption_callbacks.name(), " cannot be converted to string");}@@ -1533,10 +1004,6 @@ struct CACHE_ENCRYPTION_CALLBACKS final : OptionBase<CACHE_ENCRYPTION_CALLBACKS,static ov::EncryptionCallbacks parse(std::string_view) {OPENVINO_THROW("Option ", ov::cache_encryption_callbacks.name(), " cannot be parsed from string");}-- static ov::PropertyMutability mutability() {- return ov::PropertyMutability::WO;- }};} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hppindex 987c28d4df0..ebedecb2224 100644--- a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp+++ b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp@@ -45,7 +45,6 @@ inline std::string standardize(const std::string_view platform) {/*** @enum ColorFormat* @brief Extra information about input color format for preprocessing- * @note Configuration API v 2.0*/enum ColorFormat : uint32_t {RAW = 0u, ///< Plain blob (default), no extra color processing required@@ -57,10 +56,6 @@ enum ColorFormat : uint32_t {/*** @brief Prints a string representation of ov::intel_npu::ColorFormat to a stream- * @param out An output stream to send to- * @param fmt A color format value to print to a stream- * @return A reference to the `out` stream- * @note Configuration API v 2.0*/inline std::ostream& operator<<(std::ostream& out, const ColorFormat& fmt) {switch (fmt) {@@ -100,10 +95,6 @@ enum class BatchMode {/*** @brief Prints a string representation of ov::intel_npu::BatchMode to a stream- * @param out An output stream to send to- * @param fmt A value for batching on plugin to print to a stream- * @return A reference to the `out` stream- * @note Configuration API v 2.0*/inline std::ostream& operator<<(std::ostream& out, const BatchMode& fmt) {switch (fmt) {@@ -123,6 +114,24 @@ inline std::ostream& operator<<(std::ostream& out, const BatchMode& fmt) {return out;}+/**+ * @brief Reads a string representation of ov::intel_npu::BatchMode from a stream+ */+inline std::istream& operator>>(std::istream& is, BatchMode& fmt) {+ std::string str;+ is >> str;+ if (str == "AUTO") {+ fmt = BatchMode::AUTO;+ } else if (str == "COMPILER") {+ fmt = BatchMode::COMPILER;+ } else if (str == "PLUGIN") {+ fmt = BatchMode::PLUGIN;+ } else {+ OPENVINO_THROW("Unsupported value for the batch mode: ", str);+ }+ return is;+}+/*** @brief [Only for NPU Plugin]* Default is "ITERATIVE".@@ -209,7 +218,6 @@ inline std::istream& operator>>(std::istream& is, ModelSerializerVersion& modelS* @brief [Only for NPU Plugin]* Type: string, default is MODEL.* Type of profiling to execute. Can be Model (default) or INFER (based on npu timestamps)- * @note Configuration API v 2.0*/enum class ProfilingType { MODEL, INFER };@@ -218,7 +226,6 @@ enum class ProfilingType { MODEL, INFER };* @param out An output stream to send to* @param fmt A profiling type value to print to a stream* @return A reference to the `out` stream- * @note Configuration API v 2.0*/inline std::ostream& operator<<(std::ostream& out, const ProfilingType& fmt) {switch (fmt) {@@ -235,6 +242,22 @@ inline std::ostream& operator<<(std::ostream& out, const ProfilingType& fmt) {return out;}+/**+ * @brief Reads a string representation of ov::intel_npu::ProfilingType from a stream+ */+inline std::istream& operator>>(std::istream& is, ProfilingType& fmt) {+ std::string str;+ is >> str;+ if (str == "MODEL") {+ fmt = ProfilingType::MODEL;+ } else if (str == "INFER") {+ fmt = ProfilingType::INFER;+ } else {+ OPENVINO_THROW("Unsupported value for the profiling type: ", str);+ }+ return is;+}+/*** @brief Defines the options corresponding to the legacy set of values.*/diff --git a/src/plugins/intel_npu/src/al/src/config/config.cpp b/src/plugins/intel_npu/src/al/src/config/config.cppindex 6c5925ebdfa..ef3ef91b970 100644--- a/src/plugins/intel_npu/src/al/src/config/config.cpp+++ b/src/plugins/intel_npu/src/al/src/config/config.cpp@@ -4,8 +4,53 @@#include "intel_npu/config/config.hpp"+#include <cctype>+#include <charconv>+#include <string_view>++#include "openvino/util/common_util.hpp"+namespace intel_npu {+namespace {++// `std::from_chars` does the range checking for the exact target type on its own (unlike the `std::sto*`+// functions, which either need a wider signed intermediate or silently wrap negative values around), but it+// neither skips leading whitespace nor reports anything about the characters left after the number. Hence+// the surrounding whitespace is trimmed upfront and the parse is required to reach the end of the value, so+// that a valid prefix alone ("12oops") is not enough to accept it.+template <typename T>+T parseNumber(std::string_view val, std::string_view typeName) {+ auto trimmed = ov::util::trim(val);+ // Unlike `std::from_chars`, the `std::sto*` functions used before accepted an explicit plus sign. Only a+ // plus directly followed by a digit is dropped, so that "+-1" is still rejected instead of being turned+ // into a well formed "-1".+ if (trimmed.size() > 1 && trimmed.front() == '+' && std::isdigit(static_cast<unsigned char>(trimmed[1]))) {+ trimmed.remove_prefix(1);+ }++ T parsed{};+ // `ov::util::trim` hands back a default constructed view for a blank value, whose `data()` is null+ auto errorCode = std::errc::invalid_argument;+ auto parseEnd = trimmed.data();+ if (!trimmed.empty()) {+ const auto parseResult = std::from_chars(trimmed.data(), trimmed.data() + trimmed.size(), parsed);+ parseEnd = parseResult.ptr;+ errorCode = parseResult.ec;+ }++ OPENVINO_ASSERT(errorCode == std::errc{} && parseEnd == trimmed.data() + trimmed.size(),+ "Value '",+ val,+ "' is not a valid ",+ typeName,+ " option");++ return parsed;+}++} // namespace+// Splits the `str` string onto separate elements using `delim` as delimiter and// call `callback` for each element.void splitAndApply(const std::string& str, char delim, std::function<void(std::string_view)> callback) {@@ -35,11 +80,11 @@ void splitAndApply(const std::string& str, char delim, std::function<void(std::sbool OptionParser<bool>::parse(std::string_view val) {std::string strVal(val);std::transform(strVal.begin(), strVal.end(), strVal.begin(), [](char c) {- return std::toupper(c);+ return static_cast<char>(std::toupper(static_cast<unsigned char>(c)));});- if (strVal == "YES" || strVal == "TRUE" || strVal == "1") {+ if (strVal == "YES" || strVal == "TRUE" || strVal == "ON" || strVal == "1") {return true;- } else if (strVal == "NO" || strVal == "FALSE" || strVal == "0") {+ } else if (strVal == "NO" || strVal == "FALSE" || strVal == "OFF" || strVal == "0") {return false;}@@ -47,61 +92,41 @@ bool OptionParser<bool>::parse(std::string_view val) {}int32_t OptionParser<int32_t>::parse(std::string_view val) {- try {- return std::stol(val.data());- } catch (...) {- OPENVINO_THROW("Value '", val.data(), "' is not a valid INT32 option");- }+ return parseNumber<int32_t>(val, "INT32");}uint32_t OptionParser<uint32_t>::parse(std::string_view val) {- try {- return std::stoul(val.data());- } catch (...) {- OPENVINO_THROW("Value '", val.data(), "' is not a valid UINT32 option");- }+ // Note: `std::from_chars` rejects negative values for unsigned types instead of wrapping them around+ return parseNumber<uint32_t>(val, "UINT32");}int64_t OptionParser<int64_t>::parse(std::string_view val) {- try {- return std::stoll(val.data());- } catch (...) {- OPENVINO_THROW("Value '", val.data(), "' is not a valid INT64 option");- }+ return parseNumber<int64_t>(val, "INT64");}uint64_t OptionParser<uint64_t>::parse(std::string_view val) {- try {- return std::stoull(val.data());- } catch (...) {- OPENVINO_THROW("Value '", val.data(), "' is not a valid UINT64 option");- }+ return parseNumber<uint64_t>(val, "UINT64");}double OptionParser<double>::parse(std::string_view val) {+ // `std::from_chars` has no floating point overload in every supported standard library, so `std::stod` is+ // used here. Same as in `parseNumber`, the surrounding whitespace is trimmed upfront and the parse is+ // required to reach the end of the value, so that a valid prefix alone ("1.5oops") is not enough.try {- return std::stod(val.data());+ const auto trimmed = ov::util::trim(val);+ // `ov::util::trim` hands back a default constructed view for a blank value, whose `data()` is null+ OPENVINO_ASSERT(!trimmed.empty(), "Value '", val, "' holds no number at all");++ const std::string str(trimmed);+ size_t pos = 0;+ const auto parsed = std::stod(str, &pos);+ OPENVINO_ASSERT(pos == str.size(), "Value '", val, "' has leftover characters after the number");+ return parsed;} catch (...) {- OPENVINO_THROW("Value '", val.data(), "' is not a valid FP64 option");+ OPENVINO_THROW("Value '", val, "' is not a valid FP64 option");}}-ov::log::Level OptionParser<ov::log::Level>::parse(std::string_view val) {- std::string strVal(val);- std::istringstream is(strVal);- ov::log::Level level;- is >> level;- return level;-}--ov::hint::ExecutionMode OptionParser<ov::hint::ExecutionMode>::parse(std::string_view val) {- std::string strVal(val);- std::istringstream is(strVal);- ov::hint::ExecutionMode mode;- is >> mode;- return mode;-}-//// OptionPrinter//@@ -110,18 +135,6 @@ std::string OptionPrinter<bool>::toString(bool val) {return val ? "YES" : "NO";}-std::string OptionPrinter<ov::log::Level>::toString(ov::log::Level val) {- std::ostringstream os;- os << val;- return os.str();-}--std::string OptionPrinter<ov::hint::ExecutionMode>::toString(ov::hint::ExecutionMode val) {- std::ostringstream os;- os << val;- return os.str();-}-//// OptionMode//@@ -168,6 +181,7 @@ details::OptionConcept OptionsDesc::get(std::string_view key) const {void OptionsDesc::reset() {_impl.clear();+ _deprecated.clear();}bool OptionsDesc::has(std::string_view key) const {@@ -183,45 +197,6 @@ bool OptionsDesc::has(std::string_view key) const {return false;}-std::vector<std::string> OptionsDesc::getSupported(bool includePrivate) const {- std::vector<std::string> res;- res.reserve(_impl.size());-- for (const auto& p : _impl) {- if (p.second.isPublic() || includePrivate) {- res.push_back(p.first.data());- }- }-- return res;-}--std::vector<ov::PropertyName> OptionsDesc::getSupportedOptions(bool includePrivate) const {- std::vector<ov::PropertyName> res;- res.reserve(_impl.size());-- for (const auto& p : _impl) {- if (p.second.isPublic() || includePrivate) {- res.push_back({p.first.data(), p.second.mutability()});- }- }-- return res;-}--std::string OptionsDesc::getSupportedAsString(bool includePrivate) const {- std::string res;-- for (const auto& p : _impl) {- if (p.second.isPublic() || includePrivate) {- res += p.first;- res += " ";- }- }-- return res;-}-void OptionsDesc::walk(std::function<void(const details::OptionConcept&)> cb) const {for (const auto& itr : _impl) {cb(itr.second);@@ -246,7 +221,7 @@ void Config::parseEnvVars() {opt.envVar().data());try {- _impl[opt.key().data()] = opt.validateAndParseFromString(envVar);+ _impl[opt.key().data()] = opt.validateAndParse(std::string(envVar));} catch (const std::exception& e) {_log.warning("Environment variable '%s' with value '%s' was ignored for option '%s' due to error:\n%s",@@ -260,11 +235,11 @@ void Config::parseEnvVars() {});}-bool Config::has(std::string key) const {+bool Config::has(std::string_view key) const {return _impl.count(key) != 0;}-void Config::remove(std::string key) {+void Config::remove(std::string_view key) {_impl.erase(key);}@@ -273,31 +248,15 @@ void Config::update(const ConfigMap& options) {_log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());const auto opt = _desc->get(p.first);- _impl[opt.key().data()] = opt.validateAndParseFromString(p.second);- }-}--void Config::updateAny(const ov::AnyMap& options) {- for (const auto& p : options) {- _log.trace("Update option '%s' to given 'ov::Any' value", p.first.c_str());-- const auto opt = _desc->get(p.first);- _impl[opt.key().data()] = opt.validateAndParseFromAny(p.second);+ _impl[opt.key().data()] = opt.validateAndParse(p.second);}}-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());+void Config::update(std::string_view key, const ov::Any& value) {+ _log.trace("Update option '%s'", std::string(key).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);+ _impl[opt.key().data()] = opt.validateAndParse(value);}std::string Config::toString() const {@@ -337,20 +296,94 @@ void Config::fromString(const std::string& str) {parse_token(str_cfg);}-//-// envVarStrToBool-//+bool Config::hasOpt(std::string_view key) const {+ return _desc->has(key);+}-bool envVarStrToBool(const char* varName, const char* varValue) {- try {- const auto intVal = std::stoi(varValue);- if (intVal != 0 && intVal != 1) {- throw std::invalid_argument("Only 0 and 1 values are supported");+details::OptionConcept Config::getOpt(std::string_view key) const {+ return _desc->get(key);+}++void Config::addOrUpdateInternal(std::string key, std::string value) {+ const auto [it, inserted] = _internal_compiler_configs.insert_or_assign(std::move(key), std::move(value));+ if (inserted) {+ _log.trace("Store internal compiler option %s: %s", it->first.c_str(), it->second.c_str());+ } else {+ _log.warning("Internal compiler option '%s' was already registered! Updating value only!", it->first.c_str());+ }+}++bool Config::hasInternal(std::string_view key) const {+ return _internal_compiler_configs.count(std::string(key)) != 0;+}++void Config::removeCompileTimeConfigs() {+ for (auto it = _impl.begin(); it != _impl.end();) {+ if (_desc->get(it->first).mode() == OptionMode::CompileTime) {+ it = _impl.erase(it);+ } else {+ ++it;}- return (intVal != 0);- } catch (const std::exception& e) {- OPENVINO_THROW(std::string("Environment variable ") + varName + " has wrong value : " + e.what());}++ _internal_compiler_configs.clear();+}++std::string Config::getInternal(std::string_view key) const {+ // `ConfigMap` is keyed by `std::string` and uses the default comparator, so it has no heterogeneous lookup+ const auto it = _internal_compiler_configs.find(std::string(key));+ if (it == _internal_compiler_configs.end()) {+ OPENVINO_THROW("Internal compiler option ", key, " does not exist!");+ }++ return it->second;+}++std::string Config::toStringForCompiler(const std::function<bool(const std::string&)>& isSupported) const {+ if (!isSupported) {+ OPENVINO_THROW("Config::toStringForCompiler requires a valid support predicate");+ }++ std::stringstream resultStream;+ bool hasSerializedValue = false;++ const auto append = [&](std::string_view key, std::string_view 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");+ }++ 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;+ }++ append(key, value->toString());+ }++ for (const auto& [key, value] : _internal_compiler_configs) {+ if (!isSupported(key)) {+ OPENVINO_THROW("[ NOT_FOUND ] Option '" + key + "' is not supported for current configuration");+ }+ append(key, value);+ }++ return resultStream.str();}} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/common/CMakeLists.txt b/src/plugins/intel_npu/src/common/CMakeLists.txtindex 9b42c23cd72..d70c9112b92 100644--- a/src/plugins/intel_npu/src/common/CMakeLists.txt+++ b/src/plugins/intel_npu/src/common/CMakeLists.txt@@ -8,7 +8,6 @@ set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/compiler_adapter_factory.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/option_support_cache.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/device_helpers.hpp- ${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/filtered_config.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/icompiled_model.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/icompiler_adapter.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/igraph.hpp@@ -18,7 +17,6 @@ set(SOURCES${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/npu.hpp${CMAKE_CURRENT_SOURCE_DIR}/include/intel_npu/common/parser_factory.hpp${CMAKE_CURRENT_SOURCE_DIR}/src/device_helpers.cpp- ${CMAKE_CURRENT_SOURCE_DIR}/src/filtered_config.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/igraph.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/network_metadata.cpp${CMAKE_CURRENT_SOURCE_DIR}/src/npu.cppdiff --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.hppdeleted file mode 100644index 774fe390509..00000000000--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp+++ /dev/null@@ -1,91 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--// Plugin Config Engine--#pragma once--#include "intel_npu/config/config.hpp"--namespace intel_npu {--/**- * @class FilteredConfig- * @brief A derived configuration class that extends the base `Config` class with filtering capabilities.- *- * This class provides additional functionality to manage and filter configuration options,- * including enabling/disabling specific options, managing internal configurations, and- * generating filtered configuration strings for compiler-specific needs.- */-class FilteredConfig final : public Config {-public:- using EnableMap =- std::unordered_map<std::string, bool>; ///< Map to track enabled/disabled state of configuration keys.-- /**- * @brief Constructs a `FilteredConfig` object with a given options descriptor.- * @param desc Shared pointer to an `OptionsDesc` object that describes available options.- */- explicit FilteredConfig(const std::shared_ptr<const OptionsDesc>& desc) : Config(desc) {}-- /**- * @brief Checks if a specific option exists in the configuration's descriptorDesc.- * @param key The key of the option to check.- * @return True if the option exists, false otherwise.- */- bool hasOpt(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.- * @return The `OptionConcept` object representing the option's details.- */- details::OptionConcept getOpt(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.- */- void addOrUpdateInternal(std::string key, std::string value);-- /**- * @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.- */- bool hasInternal(std::string_view key) const;-- /**- * @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 removeCompileTimeConfigs();-- /**- * @brief Retrieves an internal configuration value by its key.- * @param key The key of the internal configuration to retrieve.- * @return The value associated with the specified internal configuration key.- */- std::string getInternal(std::string key) 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.- */- void walkInternals(std::function<void(const std::string&)> cb) const;-- /**- * @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::function<bool(const std::string&)>& isSupported) const;--private:- ConfigMap _internal_compiler_configs; ///< Map to store internal (hidden) configurations used for compiler.-};--} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hppindex b1488a57d06..d42a4299b98 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp@@ -4,15 +4,15 @@#pragma once-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/igraph.hpp"+#include "intel_npu/config/config.hpp"namespace intel_npu {class ICompilerAdapter {public:virtual std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const = 0;+ const Config& config) const = 0;/*** @brief Compiles the model, weights separation enabled.@@ -28,11 +28,9 @@ public:* "icompiler.hpp".* @return A "WeightlessGraph" type of object.*/- virtual std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model,- const FilteredConfig& config) const = 0;+ virtual std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const Config& config) const = 0;- virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const = 0;+ virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0;virtual uint32_t get_version() const = 0;virtual std::vector<std::string> get_supported_options() const = 0;virtual bool is_option_supported(const std::string& optName,diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hppindex 3a7e88d4710..3363e28dbe3 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp@@ -10,8 +10,8 @@#include <mutex>#include <vector>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/network_metadata.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/utils/zero/zero_wrappers.hpp"#include "openvino/runtime/itensor.hpp"#include "openvino/runtime/profiling_info.hpp"@@ -56,7 +56,7 @@ public:const void* data,const std::vector<size_t>& strides) const;- void initialize(const FilteredConfig& config);+ void initialize(const Config& config);virtual ~IGraph() = default;@@ -115,7 +115,7 @@ public:virtual std::optional<std::string_view> get_compatibility_descriptor() const;protected:- virtual void initialize_impl(const FilteredConfig& config);+ virtual void initialize_impl(const Config& config);// Used to protect graph initialization (including zero pipeline creation) in the graph. Initialization should// happen only once per graph, typically when the graph is first used (e.g. when the first inference starts)diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hppindex 12c5cee0256..f886c08e3fa 100644--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/iparser.hpp@@ -6,8 +6,8 @@#include <variant>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/igraph.hpp"+#include "intel_npu/config/config.hpp"namespace ov {class ICore;@@ -35,7 +35,7 @@ public:*/virtual std::shared_ptr<IGraph> parse(const ov::Tensor& mainBlob,- const FilteredConfig& config,+ const Config& config,std::variant<std::monostate,std::shared_ptr<const ov::Model>,std::pair<std::string, std::shared_ptr<ov::ICore>>>&& weightsSource,diff --git a/src/plugins/intel_npu/src/common/src/filtered_config.cpp b/src/plugins/intel_npu/src/common/src/filtered_config.cppdeleted file mode 100644index f956cfe079c..00000000000--- a/src/plugins/intel_npu/src/common/src/filtered_config.cpp+++ /dev/null@@ -1,106 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#include "intel_npu/common/filtered_config.hpp"--namespace intel_npu {--bool FilteredConfig::hasOpt(std::string_view key) const {- return _desc->has(key);-}--details::OptionConcept FilteredConfig::getOpt(std::string_view key) const {- return _desc->get(key);-}--void FilteredConfig::walkInternals(std::function<void(const std::string&)> cb) const {- for (const auto& itr : _internal_compiler_configs) {- cb(itr.first);- }-}--void FilteredConfig::addOrUpdateInternal(std::string key, std::string value) {- auto log = Logger::global().clone("Config");- if (_internal_compiler_configs.count(key) != 0) {- log.warning("Internal compiler option '%s' was already registered! Updating value only!", key.c_str());- _internal_compiler_configs.at(key) = std::move(value);- } else {- // manual insert- log.trace("Store internal compiler option %s: %s", key.c_str(), value.c_str());- _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 {- if (_internal_compiler_configs.count(key) == 0) {- OPENVINO_THROW(std::string("Internal compiler option " + key + " does not exist! "));- }- return _internal_compiler_configs.at(key);-}--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;-- 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");- }-- 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;- }-- 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();-}--} // namespace intel_npudiff --git a/src/plugins/intel_npu/src/common/src/igraph.cpp b/src/plugins/intel_npu/src/common/src/igraph.cppindex 95e78a1efb6..225c3614d61 100644--- a/src/plugins/intel_npu/src/common/src/igraph.cpp+++ b/src/plugins/intel_npu/src/common/src/igraph.cpp@@ -28,7 +28,7 @@ std::optional<std::string_view> IGraph::get_compatibility_descriptor() const {OPENVINO_THROW("get_compatibility_descriptor not implemented");}-void IGraph::initialize(const FilteredConfig& config) {+void IGraph::initialize(const Config& config) {std::lock_guard<std::mutex> lock(_initialize_mutex);if (_init_completed.load(std::memory_order_acquire)) {@@ -38,7 +38,7 @@ void IGraph::initialize(const FilteredConfig& config) {initialize_impl(config);}-void IGraph::initialize_impl(const FilteredConfig&) {+void IGraph::initialize_impl(const Config&) {OPENVINO_THROW("initialize_impl not implemented");}diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hppindex 23089a3640f..90cefbe3629 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/compiler_impl.hpp@@ -11,9 +11,9 @@#include <utility>#include <vector>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/npu.hpp"#include "intel_npu/common/option_support_cache.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/utils/vcl/vcl_api.hpp"#include "openvino/core/except.hpp"#include "openvino/core/model.hpp"@@ -46,7 +46,7 @@ public:* string with runtime requirements for the blob*/std::pair<ov::Tensor, std::optional<std::string>> compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const;+ const Config& config) const;/*** @brief Compiles the model, weights separation enabled. All init schedules along with the main one are compiled in@@ -56,7 +56,7 @@ public:*/std::pair<std::vector<ov::Tensor>, std::optional<std::string>> compileWsOneShot(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config) const;+ const Config& config) const;/*** @brief Sequential compilation of Init(s) and Main*@@ -72,7 +72,7 @@ public:* Plugin does not know total numbers of Init schedules*/std::pair<ov::Tensor, std::optional<std::string>> compileWsIterative(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config,+ const Config& config,size_t callNumber) const;/*** @brief Returns information about supported layers of the network passed@@ -81,7 +81,7 @@ public:* including config options related to compilation* @returns SupportedOpsMap structure with information about supported layers*/- ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const FilteredConfig& config) const;+ ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const;/*** @brief Returns the compiler version@@ -120,7 +120,7 @@ private:* @note Storing the "WeightlessCacheAttribute" is necessary if the "weights separation" flow is being used.*/std::pair<ov::Tensor, std::optional<std::string>> compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config,+ const Config& config,const bool storeWeightlessCacheAttributeFlag) const;std::shared_ptr<const VCLFunctionTable> _functions;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hppindex 3df51802804..e6b377f0117 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp@@ -23,13 +23,11 @@ public:DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr);- std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const override;+ std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;- std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const FilteredConfig& config) const override;+ std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const Config& config) const override;- ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const override;+ ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;std::vector<std::string> get_supported_options() const override;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hppindex c08eed812f2..a5abdefe9a4 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/dynamic_graph.hpp@@ -20,7 +20,7 @@ class DynamicGraph final : public IGraph {public:DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,ov::Tensor blob,- const FilteredConfig& config,+ const Config& config,BlobType blobType = BlobType::LLVM);std::pair<uint64_t, std::optional<std::vector<uint64_t>>> export_blob(std::ostream& stream) const override;@@ -57,11 +57,10 @@ public:BlobType get_blob_type() const override;private:- void initialize_impl(const FilteredConfig& config) override;-- bool release_blob(const FilteredConfig& config);- void initialize_engine(const FilteredConfig& config);- void create_execution_engine(const FilteredConfig& config);+ void initialize_impl(const Config& config) override;+ bool release_blob(const Config& config);+ void initialize_engine(const Config& config);+ void create_execution_engine(const Config& config);void prepare_metadata();std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hppindex b27209a0034..11459d87ead 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp@@ -25,7 +25,7 @@ public:const GraphDescriptor& graphDesc,NetworkMetadata metadata,std::optional<ov::Tensor> blob,- const FilteredConfig& config,+ const Config& config,const std::optional<std::string>& compatibilityDescriptor = std::nullopt,const bool blobIsPersistent = false);@@ -67,9 +67,9 @@ public:~Graph() override;protected:- void initialize_impl(const FilteredConfig& config) override;+ void initialize_impl(const Config& config) override;- bool release_blob(const FilteredConfig& config);+ bool release_blob(const Config& config);std::optional<size_t> determine_batch_size();std::shared_ptr<ZeGraphExtWrappers> _zeGraphExt;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hppindex 146ad3057a5..5a8c6036f6f 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/model_serializer.hpp@@ -9,7 +9,7 @@#include <iostream>#include <string>-#include "intel_npu/common/filtered_config.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"#include "intel_npu/utils/logger/logger.hpp"@@ -74,7 +74,7 @@ SerializedIR serializeIR(const std::shared_ptr<const ov::Model>& model,*/std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, const bool useIndices);-std::string serializeConfig(const FilteredConfig& config,+std::string serializeConfig(const Config& config,const ze_graph_compiler_version_info_t& compilerVersion,const std::function<bool(const std::string&)>& isOptionSupportedByCompiler);diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hppindex 4b5e3062951..e17541a1184 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/parser.hpp@@ -19,7 +19,7 @@ public:Parser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct);std::shared_ptr<IGraph> parse(const ov::Tensor& mainBlob,- const FilteredConfig& config,+ const Config& config,std::variant<std::monostate,std::shared_ptr<const ov::Model>,std::pair<std::string, std::shared_ptr<ov::ICore>>>&& weightsSource,diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hppindex c7119fcdb89..8aefc7c0d17 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp@@ -25,13 +25,11 @@ public:const std::shared_ptr<OptionSupportCache>& optionSupportCache = nullptr,const std::optional<IDevice::DeviceProperties>& deviceProperties = std::nullopt);- std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const override;+ std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;- std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const FilteredConfig& config) const override;+ std::shared_ptr<IGraph> compileWS(std::shared_ptr<ov::Model>&& model, const Config& config) const override;- ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const override;+ ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;std::vector<std::string> get_supported_options() const override;diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hppindex c5f05a695e2..237c9190282 100644--- a/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp+++ b/src/plugins/intel_npu/src/compiler_adapter/include/weightless_graph.hpp@@ -40,7 +40,7 @@ public:std::variant<std::monostate,std::shared_ptr<const ov::Model>,std::pair<std::string, std::shared_ptr<ov::ICore>>>&& weightsSource,- const FilteredConfig& config,+ const Config& config,const bool blobIsPersistent = false,const std::optional<std::string>& compatibilityDescriptor = std::nullopt);@@ -58,7 +58,7 @@ public:* In addition to this, the init schedules are run and the result of this is set as inputs to the main* compiled model.*/- void initialize_impl(const FilteredConfig& config) override;+ void initialize_impl(const Config& config) override;// TODO: public for multi-threaded executionstruct InputData {diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cppindex 087376b4a82..f58ab298387 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@@ -231,13 +231,13 @@ VCLCompilerImpl::~VCLCompilerImpl() {std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {return compile(model, config, false);}std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config,+ const Config& config,const bool storeWeightlessCacheAttributeFlag) const {_logger.debug("compile start");@@ -270,7 +270,7 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(isOptionSupportedByCompiler,false,storeWeightlessCacheAttributeFlag);- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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));@@ -368,7 +368,7 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(std::pair<std::vector<ov::Tensor>, std::optional<std::string>> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {_logger.debug("compileWsOneShot start");/// Check the linked vcl version whether supported in plugin@@ -400,7 +400,7 @@ std::pair<std::vector<ov::Tensor>, std::optional<std::string>> VCLCompilerImpl::isOptionSupportedByCompiler,false,true);- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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));@@ -481,10 +481,10 @@ std::pair<std::vector<ov::Tensor>, std::optional<std::string>> VCLCompilerImpl::std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compileWsIterative(const std::shared_ptr<ov::Model>& model,- const FilteredConfig& config,+ const Config& config,size_t callNumber) const {_logger.debug("compileWsIterative start");- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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);@@ -544,8 +544,7 @@ uint32_t VCLCompilerImpl::get_version() const {return ZE_MAKE_VERSION(_compilerProperties.version.major, _compilerProperties.version.minor);}-ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model>& model, const Config& config) const {_logger.debug("query start");/// Check the linked vcl version whether supported in plugin@@ -565,7 +564,7 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Modelze_graph_compiler_version_info_t compilerVersion;compilerVersion.major = _compilerProperties.version.major;compilerVersion.minor = _compilerProperties.version.minor;- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;const auto isOptionSupportedByCompiler = [this](const std::string& optionName,const std::optional<std::string>& optionValue = std::nullopt) {return is_option_supported(optionName, optionValue);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 86ba221e831..d2a01ba2fcd 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@@ -11,9 +11,9 @@#include <vector>#include "graph.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/itt.hpp"#include "intel_npu/common/option_support_cache.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "mem_usage.hpp"@@ -88,7 +88,7 @@ DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStruc}std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "DriverCompilerAdapter", "compile");const ze_graph_compiler_version_info_t& compilerVersion = _compilerProperties.compilerVersion;@@ -107,7 +107,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<conconfig.get<MODEL_SERIALIZER_VERSION>(),isOptionValueSupportedByCompiler,_zeGraphExt->isPluginModelHashSupported());- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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));@@ -149,7 +149,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con}std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Model>&& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "DriverCompilerAdapter", "compileWS");const ze_graph_compiler_version_info_t& compilerVersion = _compilerProperties.compilerVersion;@@ -181,7 +181,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::ModisOptionValueSupportedByCompiler,_zeGraphExt->isPluginModelHashSupported(),true);- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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));@@ -270,7 +270,7 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(std::shared_ptr<ov::Mod}ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(query_BLOB, itt::domains::NPUPlugin, "DriverCompilerAdapter", "query");const ze_graph_compiler_version_info_t& compilerVersion = _compilerProperties.compilerVersion;@@ -288,7 +288,7 @@ ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov:config.get<MODEL_SERIALIZER_VERSION>(),isOptionValueSupportedByCompiler);- FilteredConfig updatedConfig = config;+ Config updatedConfig = config;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));diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cppindex 0c0e5f1dd8f..7f5c9ff1752 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp@@ -19,7 +19,7 @@namespace intel_npu {namespace {-void populateRuntimeConfigChain(NpuVMRuntimeConfigChain& configChain, const FilteredConfig& config) {+void populateRuntimeConfigChain(NpuVMRuntimeConfigChain& configChain, const Config& config) {configChain.append(NPU_VM_RUNTIME_CONFIG_TYPE_QUEUE_PRIORITY,static_cast<npu_vm_runtime_config_value_t>(zeroUtils::toZeQueuePriority(config.get<MODEL_PRIORITY>())));@@ -42,7 +42,7 @@ void populateRuntimeConfigChain(NpuVMRuntimeConfigChain& configChain, const Filt} // namespace-void DynamicGraph::create_execution_engine(const FilteredConfig& config) {+void DynamicGraph::create_execution_engine(const Config& config) {npu_vm_runtime_blob_desc_t blobDesc;blobDesc.pInput = reinterpret_cast<const uint8_t*>(_blob.value().data());blobDesc.inputSize = _blob.value().get_byte_size();@@ -186,7 +186,7 @@ void DynamicGraph::prepare_metadata() {_metadata.bindRelatedDescriptors();}-void DynamicGraph::initialize_engine(const FilteredConfig& config) {+void DynamicGraph::initialize_engine(const Config& config) {if (!_engineInitialized) {create_execution_engine(config);prepare_metadata();@@ -222,7 +222,7 @@ void DynamicGraph::initialize_engine(const FilteredConfig& config) {DynamicGraph::DynamicGraph(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct,ov::Tensor blob,- const FilteredConfig& config,+ const Config& config,BlobType blobType): _zeroInitStruct(zeroInitStruct),_blob(std::move(blob)),@@ -352,7 +352,7 @@ void* DynamicGraph::get_handle() const {return _engine;}-void DynamicGraph::initialize_impl(const FilteredConfig& config) {+void DynamicGraph::initialize_impl(const Config& config) {_logger.debug("Graph initialize start");if (!_engineInitialized) {@@ -403,10 +403,10 @@ void DynamicGraph::initialize_impl(const FilteredConfig& config) {_init_completed.store(true, std::memory_order_release);}-bool DynamicGraph::release_blob(const FilteredConfig& config) {+bool DynamicGraph::release_blob(const Config& config) {_logger.warning("Release blob is skipped, no handle for DynamicGraph");return false;-};+}uint32_t DynamicGraph::get_unique_id() {return _uniqueId++;diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cppindex 011426d1afa..78efbd5c6fc 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp@@ -23,7 +23,7 @@ Graph::Graph(const std::shared_ptr<ZeGraphExtWrappers>& zeGraphExt,const GraphDescriptor& graphDesc,NetworkMetadata metadata,std::optional<ov::Tensor> blob,- const FilteredConfig& config,+ const Config& config,const std::optional<std::string>& compatibilityDescriptor,const bool blobIsPersistent): IGraph(),@@ -179,7 +179,7 @@ void Graph::set_argument_value_with_strides(uint32_t id, const void* data, const_zeGraphExt->setGraphArgumentValueWithStrides(_graphDesc, id, data, strides);}-void Graph::initialize_impl(const FilteredConfig& config) {+void Graph::initialize_impl(const Config& config) {_logger.debug("Graph initialize start");if (_zeGraphExt == nullptr || _graphDesc._handle == nullptr || _zeroInitStruct == nullptr) {@@ -242,7 +242,7 @@ void Graph::initialize_impl(const FilteredConfig& config) {_init_completed.store(true, std::memory_order_release);}-bool Graph::release_blob(const FilteredConfig& config) {+bool Graph::release_blob(const Config& config) {if ((_zeGraphExt != nullptr && _zeGraphExt->isBlobDataImported(_graphDesc)) || _blobIsPersistent ||_blob == std::nullopt || _zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 8) ||config.get<PERF_COUNT>()) {diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/model_serializer.cppindex f4e3a1a25ba..9faf2fbd517 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@@ -11,7 +11,7 @@#include <streambuf>#include "custom_stream_buffer.hpp"-#include "intel_npu/common/filtered_config.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/weights_pointer_attribute.hpp"#include "openvino/core/rt_info/weightless_caching_attributes.hpp"@@ -701,7 +701,7 @@ std::string serializeIOInfo(const std::shared_ptr<const ov::Model>& model, constoutputsPrecisionSS.str() + VALUES_SEPARATOR.data() + outputsLayoutSS.str();}-std::string serializeConfig(const FilteredConfig& originalConfig,+std::string serializeConfig(const Config& originalConfig,const ze_graph_compiler_version_info_t& compilerVersion,const std::function<bool(const std::string&)>& isOptionSupportedByCompiler) {Logger logger("serializeConfig", Logger::global().level());@@ -711,14 +711,14 @@ std::string serializeConfig(const FilteredConfig& originalConfig,// use the copy for the remainder of this function so every subsequent read observes the compiler-specific// level instead of the plugin one. When NPU_COMPILE_LOG_LEVEL is unset, no copy// is made and the compiler keeps inheriting the plugin LOG_LEVEL exactly as before.- std::optional<FilteredConfig> configWithCompileLogLevel;+ std::optional<Config> configWithCompileLogLevel;if (originalConfig.has<COMPILE_LOG_LEVEL>()) {std::ostringstream levelStr;levelStr << originalConfig.get<COMPILE_LOG_LEVEL>();configWithCompileLogLevel = originalConfig;configWithCompileLogLevel->update(ov::log::level.name(), levelStr.str());}- const FilteredConfig& config = configWithCompileLogLevel.has_value() ? *configWithCompileLogLevel : originalConfig;+ const Config& config = configWithCompileLogLevel.has_value() ? *configWithCompileLogLevel : originalConfig;std::string content = {};diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cppindex 914ec7c537e..eefcce68c44 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/parser.cpp@@ -27,7 +27,7 @@ Parser::Parser(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)std::shared_ptr<IGraph> Parser::parse(const ov::Tensor& mainBlob,- const FilteredConfig& config,+ const Config& config,std::variant<std::monostate, std::shared_ptr<const ov::Model>, std::pair<std::string, std::shared_ptr<ov::ICore>>>&&weightsSource,const std::optional<std::vector<ov::Tensor>>& initBlobs,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 48d0122ca10..340acadaa4a 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@@ -76,7 +76,7 @@ PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr<ZeroInitStruc}std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "compile");_logger.debug("compile start");@@ -129,11 +129,11 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<con}std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Model>&& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "compileWS");_logger.debug("compile start");- FilteredConfig localConfig = config;+ Config localConfig = config;if (!localConfig.has<SEPARATE_WEIGHTS_VERSION>()) {localConfig.update(ov::intel_npu::separate_weights_version.name(), "ONE_SHOT");}@@ -286,7 +286,7 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compileWS(std::shared_ptr<ov::Mod}ov::SupportedOpsMap PluginCompilerAdapter::query(const std::shared_ptr<const ov::Model>& model,- const FilteredConfig& config) const {+ const Config& config) const {OV_ITT_TASK_CHAIN(QUERY_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "query");return _compiler->query(model, config);diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cppindex b56d95b5f2c..2a54cd5525d 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp@@ -263,7 +263,7 @@ WeightlessGraph::WeightlessGraph(std::optional<std::vector<ov::Tensor>> initBlobs,std::variant<std::monostate, std::shared_ptr<const ov::Model>, std::pair<std::string, std::shared_ptr<ov::ICore>>>&&weightsSource,- const FilteredConfig& config,+ const Config& config,const bool blobIsPersistent,const std::optional<std::string>& compatibilityDescriptor): Graph(zeGraphExt,@@ -370,7 +370,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> WeightlessGraph::exporreturn std::make_pair(totalBlobSize, initSizes);}-void WeightlessGraph::initialize_impl(const FilteredConfig& config) {+void WeightlessGraph::initialize_impl(const Config& config) {if (_zeGraphExt == nullptr || _graphDesc._handle == nullptr || _zeroInitStruct == nullptr) {// To ensure that does not throw an issue when subsequently calling `_zeroInitStruct->getDevice()`return;diff --git a/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp b/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hppindex ba93585bf87..689cd68cff4 100644--- a/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp+++ b/src/plugins/intel_npu/src/plugin/include/blob_format_importers.hpp@@ -8,9 +8,9 @@#include <string>#include "blob_source.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/igraph.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "metadata.hpp"#include "openvino/runtime/tensor.hpp"@@ -35,7 +35,7 @@ public:* @param logger A logger that should already use the name of the subclass.*/IBlobFormatImporter(const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config,+ const Config& config,const Logger& logger);/**@@ -67,12 +67,12 @@ public:*/std::shared_ptr<ov::Model> create_dummy_model() const;- FilteredConfig get_config() const;+ Config get_config() const;virtual ~IBlobFormatImporter() = default;protected:- FilteredConfig m_config;+ Config m_config;Logger m_logger;private:@@ -134,7 +134,7 @@ namespace blob_format_importer_factory {std::unique_ptr<IBlobFormatImporter> create(BlobSource& npu_formatted_blob,const bool is_raw_blob,const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config);+ const Config& config);} // namespace blob_format_importer_factorydiff --git a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp b/src/plugins/intel_npu/src/plugin/include/compiled_model.hppindex 84eb2082260..ea34dbf4e92 100644--- a/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp+++ b/src/plugins/intel_npu/src/plugin/include/compiled_model.hpp@@ -34,7 +34,7 @@ public:const std::shared_ptr<const ov::IPlugin>& plugin,const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,- const FilteredConfig& config,+ const Config& config,const ov::AnyMap& properties,const std::optional<int64_t>& batchSize);diff --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 9a622bcbcfa..20449faba7d 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@@ -11,9 +11,9 @@#include <string>#include <vector>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/igraph.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/runtime/properties.hpp"#include "property_registration.hpp"@@ -22,7 +22,7 @@ namespace intel_npu {class CompiledModelPropertyManager final : private PropertyRegistrationBase {public:- CompiledModelPropertyManager(const FilteredConfig& config,+ CompiledModelPropertyManager(const Config& config,const ov::AnyMap& properties,const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,@@ -32,12 +32,12 @@ public:void setProperty(const ov::AnyMap& properties);ov::Any getProperty(const std::string& name) const;- FilteredConfig getConfig() const;+ Config getConfig() const;private:void registerProperties();- FilteredConfig _config;+ Config _config;const std::shared_ptr<IDevice> _device;std::shared_ptr<IGraph> _graph;diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hppindex 723313b2409..24c6dcdf0f5 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp@@ -11,8 +11,8 @@#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/config/config.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "openvino/runtime/iplugin.hpp"#include "openvino/runtime/so_ptr.hpp"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 a1aad5015d7..f980b2441ee 100644--- a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp+++ b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp@@ -13,9 +13,9 @@#include <vector>#include "compiler_option_support_helper.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/icompiler_adapter.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/npuw.hpp"#include "intel_npu/utils/logger/logger.hpp"#include "property_registration.hpp"@@ -37,8 +37,8 @@ public:ov::Any getProperty(const std::string& name, const ov::AnyMap& arguments = {}) const;bool isPropertySupported(const std::string& name, const ov::AnyMap& arguments = {}) const;- std::pair<FilteredConfig, ov::AnyMap> getMergedConfigAndUnknownProperties(const ov::AnyMap& properties,- ConfigMergeMode mergeMode);+ std::pair<Config, 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;@@ -51,7 +51,7 @@ private:const std::string& platform) const;void warnCompilerOnlyOptionSkipped(const std::string& key) const;- FilteredConfig _config;+ Config _config;ov::SoPtr<IEngineBackend> _backend;std::shared_ptr<CompilerOptionSupportHelper> _compilerOptionSupportHelper;diff --git a/src/plugins/intel_npu/src/plugin/include/transformations.hpp b/src/plugins/intel_npu/src/plugin/include/transformations.hppindex 893268f6ebf..6349b89389e 100644--- a/src/plugins/intel_npu/src/plugin/include/transformations.hpp+++ b/src/plugins/intel_npu/src/plugin/include/transformations.hpp@@ -10,7 +10,6 @@#include <set>#include <string>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/utils/logger/logger.hpp"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 650dfaa3cc9..274698c19ec 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@@ -49,7 +49,7 @@ const std::vector<size_t> CONSTANT_NODE_DUMMY_SHAPE{1};/*** @brief Special case for PERF_COUNT as it requires compiler_type detection in case it is still set to PREFER_PLUGIN*/-void update_compiler_type_if_perf_count(FilteredConfig& config,+void update_compiler_type_if_perf_count(Config& config,const ov::SoPtr<IEngineBackend>& backend,const std::string_view device_name) {if (config.has<PERF_COUNT>() && config.get<PERF_COUNT>() &&@@ -178,7 +178,7 @@ class RawBlobImporter : public IBlobFormatImporter {public:explicit RawBlobImporter(BlobSource& compiler_main_schedule,const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config)+ const Config& config): IBlobFormatImporter(original_model,config,Logger(RAW_BLOB_HANDLER_LOGGER_NAME.data(), config.get<LOG_LEVEL>())) {@@ -269,7 +269,7 @@ class BlobFormatV1Importer : public IBlobFormatImporter {public:explicit BlobFormatV1Importer(BlobSource& npu_formatted_blob,const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config)+ const Config& config): IBlobFormatImporter(original_model,config,Logger(BLOB_V1_HANDLER_LOGGER_NAME.data(), config.get<LOG_LEVEL>())) {@@ -403,7 +403,7 @@ private:namespace intel_npu {IBlobFormatImporter::IBlobFormatImporter(const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config,+ const Config& config,const Logger& logger): m_config(config),m_logger(logger),@@ -477,7 +477,7 @@ std::shared_ptr<ov::Model> IBlobFormatImporter::create_dummy_model() const {layouts.has_value() ? std::make_optional<>(layouts->second) : std::nullopt);}-FilteredConfig IBlobFormatImporter::get_config() const {+Config IBlobFormatImporter::get_config() const {return m_config;}@@ -486,7 +486,7 @@ namespace blob_format_importer_factory {std::unique_ptr<IBlobFormatImporter> create(BlobSource& npu_formatted_blob,const bool is_raw_blob,const std::shared_ptr<const ov::Model>& original_model,- const FilteredConfig& config) {+ const Config& config) {OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "blob_format_importer_factory::create");const size_t input_size = npu_formatted_blob.get_remaining_size();OPENVINO_ASSERT(input_size > 0, EMPTY_BLOB_MESSAGE);diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cppindex 23a147d1a60..c89b2f4bfd5 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp@@ -26,7 +26,7 @@ CompiledModel::CompiledModel(const std::shared_ptr<const ov::Model>& model,const std::shared_ptr<const ov::IPlugin>& plugin,const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,- const FilteredConfig& config,+ const Config& config,const ov::AnyMap& properties,const std::optional<int64_t>& batchSize): ICompiledModel(model, plugin, nullptr, nullptr),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 a1ed30426fc..f4f68631b9c 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@@ -55,7 +55,7 @@ std::string buildRuntimeRequirements(const std::shared_ptr<intel_npu::IGraph>& gnamespace intel_npu {-CompiledModelPropertyManager::CompiledModelPropertyManager(const FilteredConfig& config,+CompiledModelPropertyManager::CompiledModelPropertyManager(const Config& config,const ov::AnyMap& properties,const std::shared_ptr<IDevice>& device,const std::shared_ptr<IGraph>& graph,@@ -123,7 +123,7 @@ ov::Any CompiledModelPropertyManager::getProperty(const std::string& name) const}}-FilteredConfig CompiledModelPropertyManager::getConfig() const {+Config CompiledModelPropertyManager::getConfig() const {std::lock_guard<std::mutex> lock(_mutex);return _config;}@@ -266,7 +266,7 @@ void CompiledModelPropertyManager::registerProperties() {return ov::EncryptionCallbacks{nullptr, nullptr};},[this](const ov::Any& value) {- _config.updateAny(ov::cache_encryption_callbacks.name(), value);+ _config.update(ov::cache_encryption_callbacks.name(), value);});register_property(ov::hint::model.name(), true, ov::PropertyMutability::RO,diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex 3ce9b1e9ed4..a4589516f9f 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -176,7 +176,7 @@ Plugin::Plugin() : _logger("NPUPlugin", Logger::global().level()) {// parse env_variables to get LOG_LEVEL if neededoptions->add<LOG_LEVEL>();- std::shared_ptr<FilteredConfig> config = std::make_shared<FilteredConfig>(options);+ std::shared_ptr<Config> config = std::make_shared<Config>(options);config->parseEnvVars();Logger::global().setLevel(config->get<LOG_LEVEL>());_logger.setLevel(config->get<LOG_LEVEL>());@@ -288,7 +288,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<auto& localConfig = mergedConfigAndUnknownProperties.first;auto& unknownProperties = mergedConfigAndUnknownProperties.second;- localConfig.updateAny(ov::intel_npu::compiler_version.name(), compiler->get_version());+ localConfig.update(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>() &&@@ -344,7 +344,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<bool successfullyDebatched = false;auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {- localConfig.updateAny(ov::intel_npu::batch_mode.name(), mode);+ localConfig.update(ov::intel_npu::batch_mode.name(), mode);};const auto batchIsAvailable = [&]() {@@ -482,13 +482,13 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<const bool shouldDisablePerfCountForInferProfiling =localConfig.get<PROFILING_TYPE>() == ov::intel_npu::ProfilingType::INFER && localConfig.get<PERF_COUNT>();- FilteredConfig compilerConfig = localConfig;+ Config compilerConfig = localConfig;if (shouldDisablePerfCountForInferProfiling) {_logger.info("%s=INFER: overriding compiler-only PERF_COUNT from YES to NO; runtime configuration remains unchanged",ov::intel_npu::profiling_type.name());- compilerConfig.update(ov::enable_profiling.name(), PERF_COUNT::toString(false));+ compilerConfig.update(ov::enable_profiling.name(), false);}if (shouldWarnAboutLatency) {@@ -503,7 +503,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<if (shouldForceThroughput) {_logger.info("Setting performance mode to THROUGHPUT for batched model compilation.");- compilerConfig.updateAny(ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT);+ compilerConfig.update(ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT);}graph = compileWithConfig(std::move(modelToCompile), compilerConfig);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 6836de99126..c042e5ecc58 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@@ -265,9 +265,8 @@ bool PluginPropertyManager::isPropertySupported(const std::string& name, const oreturn propertyDescriptorIt->second.isPublic && propertyDescriptorIt->second.isSupported(propertyArguments);}-std::pair<FilteredConfig, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownProperties(- const ov::AnyMap& properties,- ConfigMergeMode mergeMode) {+std::pair<Config, 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@@ -386,11 +385,9 @@ std::pair<FilteredConfig, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUconst 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()) {- updatedConfig.updateAny(key, value.second);+ updatedConfig.update(key, std::weak_ptr<const ov::Model>(model));} else {- updatedConfig.update(key, value.second.as<std::string>());+ updatedConfig.update(key, value.second);}}@@ -562,7 +559,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<OptionType>();},[this, propertyName](const ov::Any& value) {- _config.update(propertyName, value.as<std::string>());+ _config.update(propertyName, value);});};@@ -603,7 +600,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<OptionType>();},[this, propertyName](const ov::Any& value) {- _config.update(propertyName, value.as<std::string>());+ _config.update(propertyName, value);});};@@ -641,7 +638,7 @@ void PluginPropertyManager::registerProperties() {if (_backend != nullptr) {_backend->updateInfo( {{ov::log::level.name(), value}} );}- _config.updateAny(ov::log::level.name(), value);+ _config.update(ov::log::level.name(), value);});register_property(ov::intel_npu::disable_idle_memory_prunning.name(), true, ov::PropertyMutability::RW,@@ -657,7 +654,7 @@ void PluginPropertyManager::registerProperties() {_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);+ _config.update(ov::intel_npu::disable_idle_memory_prunning.name(), value);});register_property(ov::device::id.name(), true, ov::PropertyMutability::RW,@@ -669,7 +666,7 @@ void PluginPropertyManager::registerProperties() {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>());+ _config.update(ov::device::id.name(), value);});register_property(ov::intel_npu::compiler_type.name(), true, ov::PropertyMutability::RW,@@ -681,7 +678,7 @@ void PluginPropertyManager::registerProperties() {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>());+ _config.update(ov::intel_npu::compiler_type.name(), value);});register_property(ov::intel_npu::max_tiles.name(), true, ov::PropertyMutability::RO,@@ -710,7 +707,7 @@ void PluginPropertyManager::registerProperties() {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>());+ _config.update(ov::intel_npu::platform.name(), value);});register_property(ov::intel_npu::turbo.name(), true, ov::PropertyMutability::RW,@@ -723,7 +720,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<TURBO>();},[this](const ov::Any& value) {- _config.update(ov::intel_npu::turbo.name(), value.as<std::string>());+ _config.update(ov::intel_npu::turbo.name(), value);});register_property(ov::intel_npu::enable_strides_for.name(), true, ov::PropertyMutability::RW,@@ -742,7 +739,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<ENABLE_STRIDES_FOR>();},[this](const ov::Any& value) {- _config.update(ov::intel_npu::enable_strides_for.name(), value.as<std::string>());+ _config.update(ov::intel_npu::enable_strides_for.name(), value);});register_property(ov::cache_encryption_callbacks.name(), true, ov::PropertyMutability::WO,@@ -753,7 +750,7 @@ void PluginPropertyManager::registerProperties() {return ov::EncryptionCallbacks{nullptr, nullptr};},[this](const ov::Any& value) {- _config.updateAny(ov::cache_encryption_callbacks.name(), value);+ _config.update(ov::cache_encryption_callbacks.name(), value);});@@ -801,7 +798,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<RUN_INFERENCES_SEQUENTIALLY>();},[this](const ov::Any& value) {- _config.updateAny(ov::intel_npu::run_inferences_sequentially.name(), value);+ _config.update(ov::intel_npu::run_inferences_sequentially.name(), value);});@@ -834,7 +831,7 @@ void PluginPropertyManager::registerProperties() {return _config.get<SHARED_COMMON_QUEUE>();},[this](const ov::Any& value) {- _config.updateAny(ov::intel_npu::shared_common_queue.name(), value);+ _config.update(ov::intel_npu::shared_common_queue.name(), value);});register_property(ov::intel_npu::stepping.name(), false, ov::PropertyMutability::RW,diff --git a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cppindex d9f9f8568d0..9af73a12428 100644--- a/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp+++ b/src/plugins/intel_npu/tests/functional/common/npu_test_env_cfg.cpp@@ -10,6 +10,22 @@#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"+namespace {++bool envVarStrToBool(const char* varName, const char* varValue) {+ try {+ const auto intVal = std::stoi(varValue);+ if (intVal != 0 && intVal != 1) {+ throw std::invalid_argument("Only 0 and 1 values are supported");+ }+ return (intVal != 0);+ } catch (const std::exception& e) {+ OPENVINO_THROW(std::string("Environment variable ") + varName + " has wrong value : " + e.what());+ }+}++} // namespace+namespace ov::test::utils {NpuTestEnvConfig::NpuTestEnvConfig() {@@ -27,47 +43,47 @@ NpuTestEnvConfig::NpuTestEnvConfig() {}if (auto var = std::getenv("IE_KMB_TESTS_RUN_COMPILER")) {- IE_NPU_TESTS_RUN_COMPILER = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_RUN_COMPILER", var);+ IE_NPU_TESTS_RUN_COMPILER = envVarStrToBool("IE_KMB_TESTS_RUN_COMPILER", var);}if (auto var = std::getenv("IE_KMB_TESTS_RUN_EXPORT")) {- IE_NPU_TESTS_RUN_EXPORT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_RUN_EXPORT", var);+ IE_NPU_TESTS_RUN_EXPORT = envVarStrToBool("IE_KMB_TESTS_RUN_EXPORT", var);}if (auto var = std::getenv("IE_KMB_TESTS_RUN_IMPORT")) {- IE_NPU_TESTS_RUN_IMPORT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_RUN_IMPORT", var);+ IE_NPU_TESTS_RUN_IMPORT = envVarStrToBool("IE_KMB_TESTS_RUN_IMPORT", var);}if (auto var = std::getenv("IE_KMB_TESTS_RUN_INFER")) {- IE_NPU_TESTS_RUN_INFER = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_RUN_INFER", var);+ IE_NPU_TESTS_RUN_INFER = envVarStrToBool("IE_KMB_TESTS_RUN_INFER", var);}if (auto var = std::getenv("IE_KMB_TESTS_EXPORT_INPUT")) {- IE_NPU_TESTS_EXPORT_INPUT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_EXPORT_INPUT", var);+ IE_NPU_TESTS_EXPORT_INPUT = envVarStrToBool("IE_KMB_TESTS_EXPORT_INPUT", var);}if (auto var = std::getenv("IE_KMB_TESTS_EXPORT_OUTPUT")) {- IE_NPU_TESTS_EXPORT_OUTPUT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_EXPORT_OUTPUT", var);+ IE_NPU_TESTS_EXPORT_OUTPUT = envVarStrToBool("IE_KMB_TESTS_EXPORT_OUTPUT", var);}if (auto var = std::getenv("IE_KMB_TESTS_EXPORT_REF")) {- IE_NPU_TESTS_EXPORT_REF = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_EXPORT_REF", var);+ IE_NPU_TESTS_EXPORT_REF = envVarStrToBool("IE_KMB_TESTS_EXPORT_REF", var);}if (auto var = std::getenv("IE_KMB_TESTS_IMPORT_INPUT")) {- IE_NPU_TESTS_IMPORT_INPUT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_IMPORT_INPUT", var);+ IE_NPU_TESTS_IMPORT_INPUT = envVarStrToBool("IE_KMB_TESTS_IMPORT_INPUT", var);}if (auto var = std::getenv("IE_KMB_TESTS_IMPORT_REF")) {- IE_NPU_TESTS_IMPORT_REF = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_IMPORT_REF", var);+ IE_NPU_TESTS_IMPORT_REF = envVarStrToBool("IE_KMB_TESTS_IMPORT_REF", var);}if (auto var = std::getenv("IE_KMB_TESTS_RAW_EXPORT")) {- IE_NPU_TESTS_RAW_EXPORT = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_RAW_EXPORT", var);+ IE_NPU_TESTS_RAW_EXPORT = envVarStrToBool("IE_KMB_TESTS_RAW_EXPORT", var);}if (auto var = std::getenv("IE_KMB_TESTS_LONG_FILE_NAME")) {- IE_NPU_TESTS_LONG_FILE_NAME = ::intel_npu::envVarStrToBool("IE_KMB_TESTS_LONG_FILE_NAME", var);+ IE_NPU_TESTS_LONG_FILE_NAME = envVarStrToBool("IE_KMB_TESTS_LONG_FILE_NAME", var);}if (auto var = std::getenv("IE_KMB_TESTS_PLATFORM")) {@@ -88,47 +104,47 @@ NpuTestEnvConfig::NpuTestEnvConfig() {}if (auto var = std::getenv("IE_NPU_TESTS_RUN_COMPILER")) {- IE_NPU_TESTS_RUN_COMPILER = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_RUN_COMPILER", var);+ IE_NPU_TESTS_RUN_COMPILER = envVarStrToBool("IE_NPU_TESTS_RUN_COMPILER", var);}if (auto var = std::getenv("IE_NPU_TESTS_RUN_EXPORT")) {- IE_NPU_TESTS_RUN_EXPORT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_RUN_EXPORT", var);+ IE_NPU_TESTS_RUN_EXPORT = envVarStrToBool("IE_NPU_TESTS_RUN_EXPORT", var);}if (auto var = std::getenv("IE_NPU_TESTS_RUN_IMPORT")) {- IE_NPU_TESTS_RUN_IMPORT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_RUN_IMPORT", var);+ IE_NPU_TESTS_RUN_IMPORT = envVarStrToBool("IE_NPU_TESTS_RUN_IMPORT", var);}if (auto var = std::getenv("IE_NPU_TESTS_RUN_INFER")) {- IE_NPU_TESTS_RUN_INFER = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_RUN_INFER", var);+ IE_NPU_TESTS_RUN_INFER = envVarStrToBool("IE_NPU_TESTS_RUN_INFER", var);}if (auto var = std::getenv("IE_NPU_TESTS_EXPORT_INPUT")) {- IE_NPU_TESTS_EXPORT_INPUT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_EXPORT_INPUT", var);+ IE_NPU_TESTS_EXPORT_INPUT = envVarStrToBool("IE_NPU_TESTS_EXPORT_INPUT", var);}if (auto var = std::getenv("IE_NPU_TESTS_EXPORT_OUTPUT")) {- IE_NPU_TESTS_EXPORT_OUTPUT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_EXPORT_OUTPUT", var);+ IE_NPU_TESTS_EXPORT_OUTPUT = envVarStrToBool("IE_NPU_TESTS_EXPORT_OUTPUT", var);}if (auto var = std::getenv("IE_NPU_TESTS_EXPORT_REF")) {- IE_NPU_TESTS_EXPORT_REF = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_EXPORT_REF", var);+ IE_NPU_TESTS_EXPORT_REF = envVarStrToBool("IE_NPU_TESTS_EXPORT_REF", var);}if (auto var = std::getenv("IE_NPU_TESTS_IMPORT_INPUT")) {- IE_NPU_TESTS_IMPORT_INPUT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_IMPORT_INPUT", var);+ IE_NPU_TESTS_IMPORT_INPUT = envVarStrToBool("IE_NPU_TESTS_IMPORT_INPUT", var);}if (auto var = std::getenv("IE_NPU_TESTS_IMPORT_REF")) {- IE_NPU_TESTS_IMPORT_REF = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_IMPORT_REF", var);+ IE_NPU_TESTS_IMPORT_REF = envVarStrToBool("IE_NPU_TESTS_IMPORT_REF", var);}if (auto var = std::getenv("IE_NPU_TESTS_RAW_EXPORT")) {- IE_NPU_TESTS_RAW_EXPORT = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_RAW_EXPORT", var);+ IE_NPU_TESTS_RAW_EXPORT = envVarStrToBool("IE_NPU_TESTS_RAW_EXPORT", var);}if (auto var = std::getenv("IE_NPU_TESTS_LONG_FILE_NAME")) {- IE_NPU_TESTS_LONG_FILE_NAME = ::intel_npu::envVarStrToBool("IE_NPU_TESTS_LONG_FILE_NAME", var);+ IE_NPU_TESTS_LONG_FILE_NAME = envVarStrToBool("IE_NPU_TESTS_LONG_FILE_NAME", var);}if (auto var = std::getenv("IE_NPU_TESTS_PLATFORM")) {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 315eebb7e29..44e0290b494 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@@ -94,7 +94,7 @@ protected:bool withResetInferRequest;uint32_t zeGraphNpuExtVersion;uint32_t zeMutableCommandListExtVersion;- std::unique_ptr<::intel_npu::FilteredConfig> npu_config;+ std::unique_ptr<::intel_npu::Config> npu_config;std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zeroInitStruct;std::shared_ptr<ov::Model> ov_model;@@ -158,7 +158,7 @@ public:options->add<::intel_npu::COMPILER_TYPE>();options->add<::intel_npu::BATCH_MODE>();options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();- npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);+ npu_config = std::make_unique<::intel_npu::Config>(options);for (const auto& [propertyName, propertyValue] : configuration) {npu_config->update(propertyName, propertyValue.as<std::string>());}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 fdb1f2aa60d..57d8e75ce70 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@@ -7,7 +7,6 @@#include <memory>#include <string>-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "model_serializer.hpp"@@ -18,7 +17,7 @@ namespace {class CompileLogLevelSerializeConfigTests : public ::testing::Test {protected:std::shared_ptr<::intel_npu::OptionsDesc> options;- std::unique_ptr<::intel_npu::FilteredConfig> config;+ std::unique_ptr<::intel_npu::Config> config;void SetUp() override {using namespace ::intel_npu;@@ -26,7 +25,7 @@ protected:options = std::make_shared<OptionsDesc>();options->add<LOG_LEVEL>();options->add<COMPILE_LOG_LEVEL>();- config = std::make_unique<FilteredConfig>(options);+ config = std::make_unique<Config>(options);}static ze_graph_compiler_version_info_t modernCompilerVersion() {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 598c3fd8622..fca0b901173 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@@ -21,8 +21,8 @@#include "compiler_option_support_helper.hpp"#include "functional_test_utils/ov_plugin_cache.hpp"#include "intel_npu/common/compiler_adapter_factory.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/npuw.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"@@ -377,19 +377,19 @@ TEST_P(CompatibilityCheckTests, CheckTurboWithGetMergedConfigAndUnknownPropertie};if (backend->isCommandQueueExtSupported()) {- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, 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(config.has<::intel_npu::TURBO>());+ ASSERT_TRUE(config.get<::intel_npu::TURBO>());ASSERT_TRUE(unknownProperties.empty());} else {{- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, 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)}},@@ -399,7 +399,7 @@ TEST_P(CompatibilityCheckTests, CheckTurboWithGetMergedConfigAndUnknownPropertieASSERT_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_FALSE(config.has<::intel_npu::TURBO>());ASSERT_TRUE(unknownProperties.empty());}}@@ -425,15 +425,15 @@ TEST_P(CompatibilityCheckTests, CheckTurboWithGetMergedConfigAndUnknownPropertiepropertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}});- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, 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(config.has<::intel_npu::TURBO>());+ ASSERT_TRUE(config.get<::intel_npu::TURBO>());ASSERT_TRUE(unknownProperties.empty());if (backend->isCommandQueueExtSupported()) {@@ -460,7 +460,7 @@ TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnknologs.push_back('\n');};- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, unknownProperties] = [&]() {utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);return propertiesManager->getMergedConfigAndUnknownProperties(@@ -472,8 +472,8 @@ TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnknologs.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(config.has<::intel_npu::PLATFORM>());+ ASSERT_EQ(config.get<::intel_npu::PLATFORM>(), "NPU3720");ASSERT_TRUE(unknownProperties.empty());ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);@@ -491,7 +491,7 @@ TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnknologs.push_back('\n');};- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, unknownProperties] = [&]() {utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);return propertiesManager->getMergedConfigAndUnknownProperties(@@ -499,9 +499,9 @@ TEST_P(CompatibilityCheckTests, CheckCompilerPropertyWithGetMergedConfigAndUnkno::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_FALSE(config.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_FALSE(config.has<::intel_npu::PLATFORM>());+ ASSERT_FALSE(config.has<::intel_npu::COMPILER_TYPE>());ASSERT_TRUE(unknownProperties.empty());ASSERT_NE(@@ -526,7 +526,7 @@ TEST_P(CompatibilityCheckTests, CheckLoadedFromCacheWithGetMergedConfigAndUnknowlogs.push_back('\n');};- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, unknownProperties] = [&]() {utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);return propertiesManager->getMergedConfigAndUnknownProperties(@@ -535,9 +535,9 @@ TEST_P(CompatibilityCheckTests, CheckLoadedFromCacheWithGetMergedConfigAndUnknow::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_FALSE(config.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_TRUE(config.has<::intel_npu::LOADED_FROM_CACHE>());+ ASSERT_TRUE(config.get<::intel_npu::LOADED_FROM_CACHE>());ASSERT_TRUE(unknownProperties.empty());ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);@@ -555,7 +555,7 @@ TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownPlogs.push_back('\n');};- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, unknownProperties] = [&]() {utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);return propertiesManager->getMergedConfigAndUnknownProperties(@@ -563,8 +563,8 @@ TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownP::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_TRUE(config.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_EQ(config.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"));@@ -592,7 +592,7 @@ TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownPlogs.push_back('\n');};- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, unknownProperties] = [&]() {utils::LogCallbackGuard log_callback_guard(log_cb);utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);return propertiesManager->getMergedConfigAndUnknownProperties(@@ -600,7 +600,7 @@ TEST_P(CompatibilityCheckTests, CheckDummyPropertyWithGetMergedConfigAndUnknownP::intel_npu::ConfigMergeMode::Import);}();- ASSERT_FALSE(filteredConfig.has<::intel_npu::COMPILER_TYPE>());+ ASSERT_FALSE(config.has<::intel_npu::COMPILER_TYPE>());ASSERT_FALSE(unknownProperties.empty());ASSERT_EQ(unknownProperties.size(), 1);ASSERT_TRUE(unknownProperties.count("Dummy_Property"));@@ -710,31 +710,31 @@ TEST_P(CompatibilityCheckTests, CheckModelPtrWithGetMergedConfigAndUnknownProperauto 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;+ std::optional<::intel_npu::Config> config;for (const auto& modelProperty : {ov::hint::model(model), ov::hint::model(constModel)}) {- auto [config, unknownProperties] =+ auto [localConfig, unknownProperties] =propertiesManager->getMergedConfigAndUnknownProperties({{modelProperty}},::intel_npu::ConfigMergeMode::Import);- filteredConfig = std::move(config);+ config = std::move(localConfig);- ASSERT_TRUE(filteredConfig->has<::intel_npu::MODEL_PTR>());- ASSERT_EQ(filteredConfig->get<::intel_npu::MODEL_PTR>().lock(), model);+ ASSERT_TRUE(config->has<::intel_npu::MODEL_PTR>());+ ASSERT_EQ(config->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);+ ASSERT_EQ(config->get<::intel_npu::MODEL_PTR>().lock(), nullptr);}TEST_P(CompatibilityCheckTests, CheckCacheEncryptionCallbacksWithGetMergedConfigAndUnknownProperties) {- auto [filteredConfig, unknownProperties] = [&]() {+ auto [config, 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(config.has<::intel_npu::CACHE_ENCRYPTION_CALLBACKS>());ASSERT_TRUE(unknownProperties.empty());}diff --git a/src/plugins/intel_npu/tests/unit/npu/blob_format_importers.cpp b/src/plugins/intel_npu/tests/unit/npu/blob_format_importers.cppindex 65d36437f64..2647878d547 100644--- a/src/plugins/intel_npu/tests/unit/npu/blob_format_importers.cpp+++ b/src/plugins/intel_npu/tests/unit/npu/blob_format_importers.cpp@@ -56,7 +56,7 @@ struct BlobFormatImportersTest : public ::testing::Test {BlobFormatImportersTest() : config(std::make_shared<OptionsDesc>()) {}std::unique_ptr<IBlobFormatImporter> importer;- FilteredConfig config;+ Config config;};/**diff --git a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_impl_test.cpp b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_impl_test.cppindex fb79f5421bd..72178781c0f 100644--- a/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_impl_test.cpp+++ b/src/plugins/intel_npu/tests/unit/npu/compiler_adapter/compiler_impl_test.cpp@@ -15,8 +15,8 @@#include <vector>#include "fake_vcl.hpp"-#include "intel_npu/common/filtered_config.hpp"#include "intel_npu/common/option_support_cache.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/utils/utils.hpp"#include "model_serializer.hpp"@@ -27,7 +27,7 @@#include "ze_graph_ext_wrappers.hpp"using ::fake_vcl::FakeVcl;-using ::intel_npu::FilteredConfig;+using ::intel_npu::Config;using ::intel_npu::IDevice;using ::intel_npu::OptionsDesc;using ::intel_npu::OptionSupportCache;@@ -48,10 +48,10 @@ std::shared_ptr<OptionsDesc> makeOptionsDesc() {return desc;}-FilteredConfig makeConfig() {+Config makeConfig() {// Registration is all that is needed: compileWsIterative writes WS_COMPILE_CALL_NUMBER via// update(), and MODEL_SERIALIZER_VERSION is read through config.get<>.- return FilteredConfig(makeOptionsDesc());+ return Config(makeOptionsDesc());}/// A minimal model with one weight, enough for the serializer to produce a real IR.diff --git a/src/plugins/intel_npu/tests/unit/npu/config.cpp b/src/plugins/intel_npu/tests/unit/npu/config.cppindex db0683dacf0..930d34033e3 100644--- a/src/plugins/intel_npu/tests/unit/npu/config.cpp+++ b/src/plugins/intel_npu/tests/unit/npu/config.cpp@@ -6,7 +6,14 @@#include <gtest/gtest.h>+#include <algorithm>+#include <chrono>+#include <cstdlib>+#include <limits>+#include <sstream>+#include "common_test_utils/test_assertions.hpp"+#include "intel_npu/config/options.hpp"namespace ov {@@ -17,48 +24,51 @@ namespace intel_npu {enum class DummyTestOption {TESTVALUE_0 = 0,TESTVALUE_1 = 1,- TESTVALUE_2 = 2,- TESTVALUE_3 = 3 // not parsed+ TESTVALUE_2 = 2 // not parsed};-std::string_view stringifyEnum(DummyTestOption dummyTestOption);--std::string_view stringifyEnum(DummyTestOption dummyTestOption) {+static std::string_view stringifyEnum(DummyTestOption dummyTestOption) {switch (dummyTestOption) {case DummyTestOption::TESTVALUE_0:return "TESTVALUE_0";case DummyTestOption::TESTVALUE_1:return "TESTVALUE_1";- case DummyTestOption::TESTVALUE_2:- return "TESTVALUE_2";default:OPENVINO_THROW("Cannot stringify DummyTestOption!");}}-static constexpr ov::Property<DummyTestOption, PropertyMutability::RO> dummy_test_option{"DUMMY_TEST_OPTION"};+// Unscoped enums promote to their underlying type, so they are streamable even with no `operator<<` of their own+enum DummyUnscopedTestOption : uint32_t { UNSCOPED_TESTVALUE_0 = 0, UNSCOPED_TESTVALUE_1 = 1 };-struct DUMMY_TEST_OPTION final : ::intel_npu::OptionBase<DUMMY_TEST_OPTION, DummyTestOption> {- static std::string_view key() {- return dummy_test_option.name();+static std::string_view stringifyEnum(DummyUnscopedTestOption dummyTestOption) {+ switch (dummyTestOption) {+ case UNSCOPED_TESTVALUE_0:+ return "UNSCOPED_TESTVALUE_0";+ case UNSCOPED_TESTVALUE_1:+ return "UNSCOPED_TESTVALUE_1";+ default:+ OPENVINO_THROW("Cannot stringify DummyUnscopedTestOption!");}+}- static constexpr std::string_view getTypeName() {- return "ov::unit_test_intel_npu::DummyTestOption";- }+// An enum may end up with both a `stringifyEnum` overload and an `operator<<`, each of them printing the value+// differently. The two spellings below only differ so that the printer's choice between them can be observed.+enum class DummyStreamableTestOption { TESTVALUE_0 };- static DummyTestOption defaultValue() {- return DummyTestOption::TESTVALUE_0;- }-};+static std::string_view stringifyEnum(DummyStreamableTestOption) {+ return "FROM_STRINGIFY_ENUM";+}++inline std::ostream& operator<<(std::ostream& os, const DummyStreamableTestOption&) {+ return os << "FROM_STREAM_OPERATOR";+}-static constexpr ov::Property<DummyTestOption, PropertyMutability::RO> dummy_test_option_custom_class_checker{- "DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER"};+static constexpr ov::Property<DummyTestOption, PropertyMutability::RO> dummy_test_option{"DUMMY_TEST_OPTION"};-struct DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER final- : ::intel_npu::OptionBase<DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER, DummyTestOption> {+struct DUMMY_TEST_OPTION final : ::intel_npu::OptionBase<DUMMY_TEST_OPTION, DummyTestOption> {static std::string_view key() {- return dummy_test_option_custom_class_checker.name();+ return dummy_test_option.name();}static constexpr std::string_view getTypeName() {@@ -68,10 +78,6 @@ struct DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER finalstatic DummyTestOption defaultValue() {return DummyTestOption::TESTVALUE_0;}-- static bool isValueSupported(std::string_view /* unusedVal */) { // custom class checker is here!- return true;- }};} // namespace intel_npu@@ -91,75 +97,1201 @@ ov::unit_test::intel_npu::DummyTestOption intel_npu::OptionParser<ov::unit_test:return ov::unit_test::intel_npu::DummyTestOption::TESTVALUE_0;} else if (val == "TESTVALUE_1") {return ov::unit_test::intel_npu::DummyTestOption::TESTVALUE_1;- } else if (val == "TESTVALUE_2") {- return ov::unit_test::intel_npu::DummyTestOption::TESTVALUE_2;}OPENVINO_THROW("Cannot parse DummyTestOption: ", val);}namespace {-using ConfigUnitTests = ::testing::Test;-using namespace ov::unit_test::intel_npu;-static constexpr std::string_view hardcodedTestValue3 = "TESTVALUE_3";-static constexpr std::string_view expectedParseErrorMessage = "Cannot parse DummyTestOption: TESTVALUE_3";+using intel_npu::Config;+using intel_npu::OptionMode;+using intel_npu::OptionParser;+using intel_npu::OptionPrinter;+using intel_npu::OptionsDesc;++// Aliases for types whose commas would otherwise break the gtest macros+using Milliseconds = std::chrono::duration<int64_t, std::milli>;+using StringToInt64Map = std::map<std::string, int64_t>;++static constexpr std::string_view hardcodedTestValue1 = "TESTVALUE_1";+static constexpr std::string_view hardcodedTestValue2 = "TESTVALUE_2";+static constexpr std::string_view expectedParseErrorMessage = "Cannot parse DummyTestOption: TESTVALUE_2";++//+// Dummy options used to exercise the `OptionsDesc` / `Config` plumbing+//++struct DUMMY_BOTH_OPTION final : intel_npu::OptionBase<DUMMY_BOTH_OPTION, std::string> {+ static std::string_view key() {+ return "DUMMY_BOTH_OPTION";+ }++ static std::string defaultValue() {+ return "both_default";+ }++ static OptionMode mode() {+ return OptionMode::Both;+ }+};++struct DUMMY_COMPILE_TIME_OPTION final : intel_npu::OptionBase<DUMMY_COMPILE_TIME_OPTION, std::string> {+ static std::string_view key() {+ return "DUMMY_COMPILE_TIME_OPTION";+ }++ static std::string defaultValue() {+ return "compile_time_default";+ }++ static OptionMode mode() {+ return OptionMode::CompileTime;+ }+};++struct DUMMY_RUN_TIME_OPTION final : intel_npu::OptionBase<DUMMY_RUN_TIME_OPTION, int64_t> {+ static std::string_view key() {+ return "DUMMY_RUN_TIME_OPTION";+ }++ static int64_t defaultValue() {+ return 42;+ }++ static OptionMode mode() {+ return OptionMode::RunTime;+ }+};++// Intentionally left without a `defaultValue()` override, so `OptionBase` returns `std::nullopt`+struct DUMMY_NO_DEFAULT_OPTION final : intel_npu::OptionBase<DUMMY_NO_DEFAULT_OPTION, std::string> {+ static std::string_view key() {+ return "DUMMY_NO_DEFAULT_OPTION";+ }+};++struct DUMMY_VALIDATED_OPTION final : intel_npu::OptionBase<DUMMY_VALIDATED_OPTION, int64_t> {+ static std::string_view key() {+ return "DUMMY_VALIDATED_OPTION";+ }++ static int64_t defaultValue() {+ return 0;+ }++ static void validateValue(const int64_t& val) {+ OPENVINO_ASSERT(val >= 0, "DUMMY_VALIDATED_OPTION expects non-negative values, got ", val);+ }+};++struct DUMMY_UINT32_OPTION final : intel_npu::OptionBase<DUMMY_UINT32_OPTION, uint32_t> {+ static std::string_view key() {+ return "DUMMY_UINT32_OPTION";+ }++ static uint32_t defaultValue() {+ return 1u;+ }+};++struct DUMMY_ENV_OPTION final : intel_npu::OptionBase<DUMMY_ENV_OPTION, int64_t> {+ static std::string_view key() {+ return "DUMMY_ENV_OPTION";+ }++ static std::string_view envVar() {+ return "OV_NPU_DUMMY_ENV_OPTION";+ }++ static int64_t defaultValue() {+ return 0;+ }+};++struct DUMMY_BOOL_OPTION final : intel_npu::OptionBase<DUMMY_BOOL_OPTION, bool> {+ static std::string_view key() {+ return "DUMMY_BOOL_OPTION";+ }++ static bool defaultValue() {+ return false;+ }+};++// `AUTO` is meaningless to `operator>>`, so this option can only be parsed through its own `parse()`+struct DUMMY_CUSTOM_PARSE_OPTION final : intel_npu::OptionBase<DUMMY_CUSTOM_PARSE_OPTION, int64_t> {+ static std::string_view key() {+ return "DUMMY_CUSTOM_PARSE_OPTION";+ }++ static int64_t defaultValue() {+ return 0;+ }++ static int64_t parse(std::string_view val) {+ if (val == "AUTO") {+ return -1;+ }+ return OptionParser<int64_t>::parse(val);+ }+};++struct DUMMY_DEPRECATED_KEYS_OPTION final : intel_npu::OptionBase<DUMMY_DEPRECATED_KEYS_OPTION, std::string> {+ static std::string_view key() {+ return "DUMMY_DEPRECATED_KEYS_OPTION";+ }++ static std::vector<std::string_view> deprecatedKeys() {+ return {"DUMMY_OLD_KEY"};+ }++ static std::string defaultValue() {+ return "";+ }+};++// Declares more than one deprecated spelling, and is neither a string nor free of validation, so it also+// covers parsing and validation being reached through an alias+struct DUMMY_MULTI_DEPRECATED_KEYS_OPTION final+ : intel_npu::OptionBase<DUMMY_MULTI_DEPRECATED_KEYS_OPTION, int64_t> {+ static std::string_view key() {+ return "DUMMY_MULTI_DEPRECATED_KEYS_OPTION";+ }++ static std::vector<std::string_view> deprecatedKeys() {+ return {"DUMMY_FIRST_OLD_KEY", "DUMMY_SECOND_OLD_KEY"};+ }++ static int64_t defaultValue() {+ return 0;+ }++ static void validateValue(const int64_t& val) {+ OPENVINO_ASSERT(val >= 0, "DUMMY_MULTI_DEPRECATED_KEYS_OPTION expects non-negative values, got ", val);+ }+};++// Claims a deprecated key which `DUMMY_DEPRECATED_KEYS_OPTION` already owns, used only to check that the+// clash is rejected at registration time. Never added to the shared descriptor.+struct DUMMY_CLASHING_DEPRECATED_KEY_OPTION final+ : intel_npu::OptionBase<DUMMY_CLASHING_DEPRECATED_KEY_OPTION, std::string> {+ static std::string_view key() {+ return "DUMMY_CLASHING_DEPRECATED_KEY_OPTION";+ }++ static std::vector<std::string_view> deprecatedKeys() {+ return {"DUMMY_OLD_KEY"};+ }+};++// There is neither an `operator<<` nor an `ov::util::Write` specialization for this type, so `ov::Any::print()`+// is a no-op for it and `ov::Any::as<std::string>()` hands back an empty string instead of failing+struct UnprintablePayload final {+ int value = 0;+};++//+// Helpers+//++// NB: the previous value of the variable is not saved and restored, the variable is simply cleared again on+// destruction. That is enough for the `OV_NPU_*` variables of the dummy options used here, which nothing else+// sets, but this helper must not be reused as is for a variable which may already be set in the environment.+class ScopedEnvVar final {+public:+ ScopedEnvVar(std::string name, const std::string& value) : _name(std::move(name)) {+#ifdef _WIN32+ _putenv_s(_name.c_str(), value.c_str());+#else+ setenv(_name.c_str(), value.c_str(), 1);+#endif+ }++ ScopedEnvVar(const ScopedEnvVar&) = delete;+ ScopedEnvVar& operator=(const ScopedEnvVar&) = delete;++ ~ScopedEnvVar() {+#ifdef _WIN32+ _putenv_s(_name.c_str(), "");+#else+ unsetenv(_name.c_str());+#endif+ }++private:+ std::string _name;+};++bool containsEntry(const std::string& serialized, std::string_view key, std::string_view value) {+ return serialized.find(std::string(key) + "=\"" + std::string(value) + "\"") != std::string::npos;+}++std::shared_ptr<OptionsDesc> makeDummyOptionsDesc() {+ auto desc = std::make_shared<OptionsDesc>();+ desc->add<DUMMY_BOTH_OPTION>();+ desc->add<DUMMY_COMPILE_TIME_OPTION>();+ desc->add<DUMMY_RUN_TIME_OPTION>();+ desc->add<DUMMY_NO_DEFAULT_OPTION>();+ desc->add<DUMMY_VALIDATED_OPTION>();+ desc->add<DUMMY_UINT32_OPTION>();+ desc->add<DUMMY_ENV_OPTION>();+ desc->add<DUMMY_BOOL_OPTION>();+ desc->add<DUMMY_CUSTOM_PARSE_OPTION>();+ desc->add<DUMMY_DEPRECATED_KEYS_OPTION>();+ desc->add<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>();+ return desc;+}++//+// OptionParser+//++using OptionParserUnitTests = ::testing::Test;++TEST_F(OptionParserUnitTests, BoolParserAcceptsAllSupportedSpellings) {+ for (const auto& val : {"YES", "yes", "TRUE", "True", "ON", "on", "1"}) {+ EXPECT_TRUE(OptionParser<bool>::parse(val)) << "value: " << val;+ }+ for (const auto& val : {"NO", "no", "FALSE", "False", "OFF", "off", "0"}) {+ EXPECT_FALSE(OptionParser<bool>::parse(val)) << "value: " << val;+ }+}++TEST_F(OptionParserUnitTests, BoolParserRejectsUnknownValue) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<bool>::parse("MAYBE"), ov::Exception, "is not a valid BOOL option");+}++TEST_F(OptionParserUnitTests, Int32ParserAcceptsWholeRange) {+ EXPECT_EQ(std::numeric_limits<int32_t>::min(), OptionParser<int32_t>::parse("-2147483648"));+ EXPECT_EQ(std::numeric_limits<int32_t>::max(), OptionParser<int32_t>::parse("2147483647"));+}++TEST_F(OptionParserUnitTests, Int32ParserRejectsOutOfRangeAndGarbage) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("2147483648"),+ ov::Exception,+ "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("-2147483649"),+ ov::Exception,+ "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("abc"), ov::Exception, "is not a valid INT32 option");+}++TEST_F(OptionParserUnitTests, UInt32ParserAcceptsWholeRange) {+ EXPECT_EQ(0u, OptionParser<uint32_t>::parse("0"));+ EXPECT_EQ(std::numeric_limits<uint32_t>::max(), OptionParser<uint32_t>::parse("4294967295"));+}-TEST_F(ConfigUnitTests, DefaultOptionValueCheckerWorks) {- intel_npu::OptionsDesc options;- options.add<DUMMY_TEST_OPTION>();- options.add<DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER>();+// The parser must not silently wrap negative values around, which is what `std::stoul` would do+TEST_F(OptionParserUnitTests, UInt32ParserRejectsNegativeAndOutOfRange) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse("-1"), ov::Exception, "is not a valid UINT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse("4294967296"),+ ov::Exception,+ "is not a valid UINT32 option");+}++TEST_F(OptionParserUnitTests, Int64ParserAcceptsWholeRange) {+ EXPECT_EQ(std::numeric_limits<int64_t>::min(), OptionParser<int64_t>::parse("-9223372036854775808"));+ EXPECT_EQ(std::numeric_limits<int64_t>::max(), OptionParser<int64_t>::parse("9223372036854775807"));+}- ASSERT_EQ(true,- options.get(dummy_test_option.name())- .isValueSupported(DUMMY_TEST_OPTION::toString(- DummyTestOption::TESTVALUE_1))); // parsable values will be returned as supported+TEST_F(OptionParserUnitTests, Int64ParserRejectsGarbage) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int64_t>::parse("abc"), ov::Exception, "is not a valid INT64 option");}-TEST_F(ConfigUnitTests, OptionImplementationValueCheckerWorks) {- intel_npu::OptionsDesc options;- options.add<DUMMY_TEST_OPTION>();- options.add<DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER>();+// The parser must not silently wrap negative values around, which is what `std::stoull` would do+TEST_F(OptionParserUnitTests, UInt64ParserRejectsNegative) {+ EXPECT_EQ(std::numeric_limits<uint64_t>::max(), OptionParser<uint64_t>::parse("18446744073709551615"));+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint64_t>::parse("-1"), ov::Exception, "is not a valid UINT64 option");+}++TEST_F(OptionParserUnitTests, DoubleParserWorks) {+ EXPECT_DOUBLE_EQ(1.5, OptionParser<double>::parse("1.5"));+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse("abc"), ov::Exception, "is not a valid FP64 option");+}- // make sure TESTVALUE_3 cannot be parsed by DUMMY_TEST_OPTION- OV_EXPECT_THROW_HAS_SUBSTRING(DUMMY_TEST_OPTION::parse(hardcodedTestValue3),+// `std::sto*` stops at the first character which is not part of the number, so a valid prefix alone must+// not be enough to accept the value+TEST_F(OptionParserUnitTests, NumericParsersRejectTrailingGarbage) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("12oops"), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("12 oops"),+ ov::Exception,+ "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse("12oops"),ov::Exception,- expectedParseErrorMessage.data());+ "is not a valid UINT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int64_t>::parse("12oops"), ov::Exception, "is not a valid INT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint64_t>::parse("12oops"),+ ov::Exception,+ "is not a valid UINT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse("1.5oops"), ov::Exception, "is not a valid FP64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse("1.5 oops"), ov::Exception, "is not a valid FP64 option");+}++// An explicit plus sign was accepted by the `std::sto*` functions used before, so it still is+TEST_F(OptionParserUnitTests, NumericParsersAcceptAnExplicitPlusSign) {+ EXPECT_EQ(12, OptionParser<int32_t>::parse("+12"));+ EXPECT_EQ(12u, OptionParser<uint32_t>::parse("+12"));+ EXPECT_EQ(12, OptionParser<int64_t>::parse("+12"));+ EXPECT_EQ(12u, OptionParser<uint64_t>::parse("+12"));+ EXPECT_DOUBLE_EQ(1.5, OptionParser<double>::parse(" +1.5 "));+}- ASSERT_EQ(false,- options.get(dummy_test_option.name())- .isValueSupported(hardcodedTestValue3)); // unparsable values will not be returned as supported+// Dropping the plus sign must not turn a malformed value into a well formed one+TEST_F(OptionParserUnitTests, NumericParsersRejectAMalformedSign) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("+-1"), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int64_t>::parse("+-1"), ov::Exception, "is not a valid INT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse("+-1"), ov::Exception, "is not a valid UINT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("++1"), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("+"), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse("+ 1"), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse("+-1.5"), ov::Exception, "is not a valid FP64 option");+}++// Surrounding whitespace is still tolerated, only actual content may not be left over+TEST_F(OptionParserUnitTests, NumericParsersIgnoreSurroundingWhitespace) {+ EXPECT_EQ(12, OptionParser<int32_t>::parse(" 12 "));+ EXPECT_EQ(12u, OptionParser<uint32_t>::parse(" 12 "));+ EXPECT_EQ(12, OptionParser<int64_t>::parse(" 12 "));+ EXPECT_EQ(12u, OptionParser<uint64_t>::parse(" 12 "));+ EXPECT_DOUBLE_EQ(1.5, OptionParser<double>::parse(" 1.5 "));+}- // logic changes for a class that implements its own `isValueSupported` method- ASSERT_EQ(true, options.get(dummy_test_option_custom_class_checker.name()).isValueSupported(hardcodedTestValue3));+TEST_F(OptionParserUnitTests, StringParserKeepsTheWholeView) {+ const std::string_view view = "PREFIX_VALUE";+ EXPECT_EQ("PREFIX", OptionParser<std::string>::parse(view.substr(0, 6)));}-TEST_F(ConfigUnitTests, CustomValueCheckerWorks) {- intel_npu::OptionsDesc options;- options.add<DUMMY_TEST_OPTION>(- [](std::string_view /* unusedVal */) { // custom value checker is given on option registration- return true;- });- options.add<DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER>([](std::string_view /* unusedVal */) {+TEST_F(OptionParserUnitTests, VectorParserSplitsOnComma) {+ const auto parsed = OptionParser<std::vector<int64_t>>::parse("1,2,3");+ EXPECT_EQ(std::vector<int64_t>({1, 2, 3}), parsed);+}++TEST_F(OptionParserUnitTests, MapParserSplitsOnCommaAndColon) {+ const StringToInt64Map expected{{"a", 1}, {"b", 2}};+ EXPECT_EQ(expected, OptionParser<StringToInt64Map>::parse("a:1,b:2"));+}++TEST_F(OptionParserUnitTests, MapParserRejectsEntryWithoutValue) {+ EXPECT_ANY_THROW(OptionParser<StringToInt64Map>::parse("a"));+}++// An empty spelling means "nothing to parse" for the string and container parsers. `Config` relies on this+// when it decides which `ov::Any` payloads may be stringified, so the behaviour is pinned in both directions.+TEST_F(OptionParserUnitTests, StringAndContainerParsersAcceptAnEmptyValue) {+ EXPECT_EQ("", OptionParser<std::string>::parse(""));+ EXPECT_TRUE(OptionParser<std::vector<int64_t>>::parse("").empty());+ EXPECT_TRUE(OptionParser<StringToInt64Map>::parse("").empty());+}++TEST_F(OptionParserUnitTests, ScalarParsersRejectAnEmptyValue) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<bool>::parse(""), ov::Exception, "is not a valid BOOL option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse(""), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse(""), ov::Exception, "is not a valid UINT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int64_t>::parse(""), ov::Exception, "is not a valid INT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint64_t>::parse(""), ov::Exception, "is not a valid UINT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse(""), ov::Exception, "is not a valid FP64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<Milliseconds>::parse(""), ov::Exception, "as time duration");+ EXPECT_ANY_THROW(OptionParser<ov::log::Level>::parse(""));+}++// A blank value is trimmed down to an empty one, which the numeric parsers must report instead of reading+// through the null pointer `ov::util::trim` hands back for it+TEST_F(OptionParserUnitTests, NumericParsersRejectABlankValue) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int32_t>::parse(" "), ov::Exception, "is not a valid INT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint32_t>::parse(" "), ov::Exception, "is not a valid UINT32 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<int64_t>::parse(" "), ov::Exception, "is not a valid INT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<uint64_t>::parse(" "), ov::Exception, "is not a valid UINT64 option");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<double>::parse(" "), ov::Exception, "is not a valid FP64 option");+}++TEST_F(OptionParserUnitTests, DurationParserRejectsNegativeAndGarbage) {+ EXPECT_EQ(Milliseconds(10), OptionParser<Milliseconds>::parse("10"));+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<Milliseconds>::parse("-1"),+ ov::Exception,+ "is not a valid time duration");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<Milliseconds>::parse("abc"), ov::Exception, "as time duration");+}++TEST_F(OptionParserUnitTests, DurationParserRejectsTrailingGarbage) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<Milliseconds>::parse("10ms"), ov::Exception, "as time duration");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<Milliseconds>::parse("10 oops"), ov::Exception, "as time duration");+}++// Types providing an `operator>>` (all the `ov::` property enums do) need no parser of their own+TEST_F(OptionParserUnitTests, DefaultParserReliesOnStreamOperator) {+ EXPECT_EQ(ov::log::Level::DEBUG, OptionParser<ov::log::Level>::parse("LOG_DEBUG"));+ EXPECT_EQ(ov::hint::ExecutionMode::ACCURACY, OptionParser<ov::hint::ExecutionMode>::parse("ACCURACY"));+}++TEST_F(OptionParserUnitTests, DefaultParserPropagatesStreamOperatorErrors) {+ EXPECT_ANY_THROW(OptionParser<ov::log::Level>::parse("LOG_SOMETHING"));+ EXPECT_ANY_THROW(OptionParser<ov::hint::ExecutionMode>::parse("SOMETHING"));+}++// `operator>>` stops at the first character it can't consume, so a valid prefix alone must not be enough+TEST_F(OptionParserUnitTests, DefaultParserRejectsTrailingGarbage) {+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<ov::log::Level>::parse("LOG_DEBUG garbage"),+ ov::Exception,+ "is not a valid option value");+ OV_EXPECT_THROW_HAS_SUBSTRING(OptionParser<ov::hint::ExecutionMode>::parse("ACCURACY PERFORMANCE"),+ ov::Exception,+ "is not a valid option value");+}++// Surrounding whitespace is still tolerated, only actual content may not be left over+TEST_F(OptionParserUnitTests, DefaultParserIgnoresSurroundingWhitespace) {+ EXPECT_EQ(ov::log::Level::DEBUG, OptionParser<ov::log::Level>::parse(" LOG_DEBUG "));+}++//+// OptionPrinter+//++using OptionPrinterUnitTests = ::testing::Test;++TEST_F(OptionPrinterUnitTests, BooleanIsPrintedAsYesNo) {+ EXPECT_EQ("YES", OptionPrinter<bool>::toString(true));+ EXPECT_EQ("NO", OptionPrinter<bool>::toString(false));+}++TEST_F(OptionPrinterUnitTests, FloatingPointIsPrintedWithTwoDecimals) {+ EXPECT_EQ("1.50", OptionPrinter<double>::toString(1.5));+ EXPECT_EQ("1.00", OptionPrinter<double>::toString(1.0));+}++// Enums providing an `operator<<` are printed through it+TEST_F(OptionPrinterUnitTests, EnumWithStreamOperatorUsesIt) {+ EXPECT_EQ("LOG_DEBUG", OptionPrinter<ov::log::Level>::toString(ov::log::Level::DEBUG));+ EXPECT_EQ("ACCURACY", OptionPrinter<ov::hint::ExecutionMode>::toString(ov::hint::ExecutionMode::ACCURACY));+}++// Enums with no `operator<<` fall back onto the `stringifyEnum` overload+TEST_F(OptionPrinterUnitTests, EnumWithoutStreamOperatorUsesStringifyEnum) {+ EXPECT_EQ(std::string(hardcodedTestValue1), OptionPrinter<DummyTestOption>::toString(DummyTestOption::TESTVALUE_1));+ EXPECT_ANY_THROW(OptionPrinter<DummyTestOption>::toString(DummyTestOption::TESTVALUE_2));+}++// Unscoped enums are implicitly streamable through integral promotion, the `stringifyEnum` overload still wins+TEST_F(OptionPrinterUnitTests, UnscopedEnumUsesStringifyEnum) {+ EXPECT_EQ("UNSCOPED_TESTVALUE_1", OptionPrinter<DummyUnscopedTestOption>::toString(UNSCOPED_TESTVALUE_1));+}++// When an enum provides both, the `stringifyEnum` overload is the one which takes precedence+TEST_F(OptionPrinterUnitTests, StringifyEnumTakesPrecedenceOverStreamOperator) {+ EXPECT_EQ("FROM_STRINGIFY_ENUM",+ OptionPrinter<DummyStreamableTestOption>::toString(DummyStreamableTestOption::TESTVALUE_0));++ // Makes sure the expectation above is not met just because the `operator<<` is unusable to begin with+ std::stringstream stream;+ stream << DummyStreamableTestOption::TESTVALUE_0;+ EXPECT_EQ("FROM_STREAM_OPERATOR", stream.str());+}++TEST_F(OptionPrinterUnitTests, MapIsPrintedAsCommaSeparatedPairs) {+ const StringToInt64Map val{{"a", 1}, {"b", 2}};+ EXPECT_EQ("a:1,b:2", OptionPrinter<StringToInt64Map>::toString(val));+}++TEST_F(OptionPrinterUnitTests, DurationIsPrintedAsCount) {+ EXPECT_EQ("10", OptionPrinter<Milliseconds>::toString(Milliseconds(10)));+}++TEST_F(OptionPrinterUnitTests, OptionModeIsStringified) {+ EXPECT_EQ("Both", intel_npu::stringifyEnum(OptionMode::Both));+ EXPECT_EQ("CompileTime", intel_npu::stringifyEnum(OptionMode::CompileTime));+ EXPECT_EQ("RunTime", intel_npu::stringifyEnum(OptionMode::RunTime));+}++//+// OptionBase+//++using OptionBaseUnitTests = ::testing::Test;++TEST_F(OptionBaseUnitTests, DefaultValueIsOptionalUnlessOverridden) {+ EXPECT_FALSE(DUMMY_NO_DEFAULT_OPTION::defaultValue().has_value());+ EXPECT_EQ("both_default", DUMMY_BOTH_OPTION::defaultValue());+}++TEST_F(OptionBaseUnitTests, TypeNameComesFromTypePrinterForStandardTypes) {+ EXPECT_EQ("std::string", DUMMY_BOTH_OPTION::getTypeName());+ EXPECT_EQ("int64_t", DUMMY_RUN_TIME_OPTION::getTypeName());+ EXPECT_EQ("ov::unit_test_intel_npu::DummyTestOption", DUMMY_TEST_OPTION::getTypeName());+}++TEST_F(OptionBaseUnitTests, DefaultsAreBothModeAndNoEnvVar) {+ EXPECT_EQ(OptionMode::Both, DUMMY_NO_DEFAULT_OPTION::mode());+ EXPECT_TRUE(DUMMY_NO_DEFAULT_OPTION::envVar().empty());+ EXPECT_TRUE(DUMMY_NO_DEFAULT_OPTION::deprecatedKeys().empty());+}++TEST_F(OptionBaseUnitTests, DeprecatedKeysAreReportedInDeclarationOrder) {+ EXPECT_EQ(std::vector<std::string_view>({"DUMMY_OLD_KEY"}), DUMMY_DEPRECATED_KEYS_OPTION::deprecatedKeys());+ EXPECT_EQ(std::vector<std::string_view>({"DUMMY_FIRST_OLD_KEY", "DUMMY_SECOND_OLD_KEY"}),+ DUMMY_MULTI_DEPRECATED_KEYS_OPTION::deprecatedKeys());+}++//+// OptionsDesc+//++using OptionsDescUnitTests = ::testing::Test;++TEST_F(OptionsDescUnitTests, RegisteredOptionCanBeFound) {+ const auto desc = makeDummyOptionsDesc();++ EXPECT_TRUE(desc->has(DUMMY_BOTH_OPTION::key()));+ EXPECT_EQ(DUMMY_BOTH_OPTION::key(), desc->get(DUMMY_BOTH_OPTION::key()).key());+ EXPECT_EQ(OptionMode::CompileTime, desc->get(DUMMY_COMPILE_TIME_OPTION::key()).mode());+}++TEST_F(OptionsDescUnitTests, UnknownOptionIsReported) {+ const auto desc = makeDummyOptionsDesc();++ EXPECT_FALSE(desc->has("SOME_UNKNOWN_OPTION"));+ OV_EXPECT_THROW_HAS_SUBSTRING(desc->get("SOME_UNKNOWN_OPTION"), ov::Exception, "[ NOT_FOUND ]");+}++TEST_F(OptionsDescUnitTests, RegisteringTheSameOptionTwiceThrows) {+ OptionsDesc desc;+ desc.add<DUMMY_BOTH_OPTION>();++ OV_EXPECT_THROW_HAS_SUBSTRING(desc.add<DUMMY_BOTH_OPTION>(), ov::Exception, "was already registered");+}++TEST_F(OptionsDescUnitTests, DeprecatedKeyResolvesToTheActualOption) {+ const auto desc = makeDummyOptionsDesc();++ EXPECT_TRUE(desc->has("DUMMY_OLD_KEY"));+ EXPECT_EQ(DUMMY_DEPRECATED_KEYS_OPTION::key(), desc->get("DUMMY_OLD_KEY").key());+}++TEST_F(OptionsDescUnitTests, EveryDeprecatedKeyOfAnOptionResolvesToIt) {+ const auto desc = makeDummyOptionsDesc();++ for (const auto& deprecatedKey : DUMMY_MULTI_DEPRECATED_KEYS_OPTION::deprecatedKeys()) {+ EXPECT_TRUE(desc->has(deprecatedKey)) << "key: " << deprecatedKey;+ // the whole descriptor, not just the key, is the one of the actual option+ const auto opt = desc->get(deprecatedKey);+ EXPECT_EQ(DUMMY_MULTI_DEPRECATED_KEYS_OPTION::key(), opt.key()) << "key: " << deprecatedKey;+ EXPECT_EQ(DUMMY_MULTI_DEPRECATED_KEYS_OPTION::mode(), opt.mode()) << "key: " << deprecatedKey;+ }+}++TEST_F(OptionsDescUnitTests, DeprecatedKeyIsNotAnOptionOfItsOwn) {+ OptionsDesc desc;+ desc.add<DUMMY_DEPRECATED_KEYS_OPTION>();++ std::vector<std::string> visited;+ desc.walk([&](const intel_npu::details::OptionConcept& opt) {+ visited.emplace_back(opt.key());+ });++ // deprecated keys are a lookup alias only, they are never advertised as options+ EXPECT_EQ(std::vector<std::string>({std::string(DUMMY_DEPRECATED_KEYS_OPTION::key())}), visited);+}++TEST_F(OptionsDescUnitTests, RegisteringTheSameDeprecatedKeyTwiceThrows) {+ OptionsDesc desc;+ desc.add<DUMMY_DEPRECATED_KEYS_OPTION>();++ OV_EXPECT_THROW_HAS_SUBSTRING(desc.add<DUMMY_CLASHING_DEPRECATED_KEY_OPTION>(),+ ov::Exception,+ "Option 'DUMMY_OLD_KEY' was already registered");+}++TEST_F(OptionsDescUnitTests, ResetRemovesDeprecatedKeys) {+ OptionsDesc desc;+ desc.add<DUMMY_DEPRECATED_KEYS_OPTION>();+ ASSERT_TRUE(desc.has("DUMMY_OLD_KEY"));++ desc.reset();++ EXPECT_FALSE(desc.has("DUMMY_OLD_KEY"));+ OV_EXPECT_THROW_HAS_SUBSTRING(desc.get("DUMMY_OLD_KEY"), ov::Exception, "[ NOT_FOUND ]");+ // the alias table is cleared too, so the same option can be registered again afterwards+ EXPECT_NO_THROW(desc.add<DUMMY_DEPRECATED_KEYS_OPTION>());+}++TEST_F(OptionsDescUnitTests, ResetRemovesRegisteredOptions) {+ OptionsDesc desc;+ desc.add<DUMMY_BOTH_OPTION>();+ ASSERT_TRUE(desc.has(DUMMY_BOTH_OPTION::key()));++ desc.reset();++ EXPECT_FALSE(desc.has(DUMMY_BOTH_OPTION::key()));+}++TEST_F(OptionsDescUnitTests, WalkVisitsEveryRegisteredOption) {+ OptionsDesc desc;+ desc.add<DUMMY_BOTH_OPTION>();+ desc.add<DUMMY_RUN_TIME_OPTION>();++ std::vector<std::string> visited;+ desc.walk([&](const intel_npu::details::OptionConcept& opt) {+ visited.emplace_back(opt.key());+ });++ std::sort(visited.begin(), visited.end());+ EXPECT_EQ(+ std::vector<std::string>({std::string(DUMMY_BOTH_OPTION::key()), std::string(DUMMY_RUN_TIME_OPTION::key())}),+ visited);+}++//+// Config+//++class ConfigUnitTests : public ::testing::Test {+protected:+ void SetUp() override {+ _desc = makeDummyOptionsDesc();+ }++ Config makeConfig() const {+ return Config(_desc);+ }++ std::shared_ptr<OptionsDesc> _desc;+};++TEST_F(ConfigUnitTests, NullOptionsDescIsRejected) {+ const std::shared_ptr<const OptionsDesc> nullDesc;++ OV_EXPECT_THROW_HAS_SUBSTRING((void)Config(nullDesc), ov::Exception, "Got NULL OptionsDesc");+}++TEST_F(ConfigUnitTests, UnsetOptionFallsBackOntoItsDefaultValue) {+ const auto config = makeConfig();++ EXPECT_FALSE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_EQ("both_default", config.get<DUMMY_BOTH_OPTION>());+ EXPECT_EQ(42, config.get<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, UnsetOptionWithoutDefaultValueThrowsOnAccess) {+ const auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.get<DUMMY_NO_DEFAULT_OPTION>(),+ ov::Exception,+ "no default value is available");+}++TEST_F(ConfigUnitTests, UpdateFromMapSetsSeveralOptionsAtOnce) {+ auto config = makeConfig();+ config.update(+ {{std::string(DUMMY_BOTH_OPTION::key()), "custom"}, {std::string(DUMMY_RUN_TIME_OPTION::key()), "7"}});++ EXPECT_TRUE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_EQ("custom", config.get<DUMMY_BOTH_OPTION>());+ EXPECT_EQ(7, config.get<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, UpdateFromSingleKeyValueWorks) {+ auto config = makeConfig();+ config.update(DUMMY_RUN_TIME_OPTION::key(), "7");++ EXPECT_EQ(7, config.get<DUMMY_RUN_TIME_OPTION>());+ EXPECT_EQ("7", config.getString<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, UpdateThroughDeprecatedKeySetsTheActualOption) {+ auto config = makeConfig();+ config.update("DUMMY_OLD_KEY", "some_value");++ EXPECT_TRUE(config.has<DUMMY_DEPRECATED_KEYS_OPTION>());+ EXPECT_EQ("some_value", config.get<DUMMY_DEPRECATED_KEYS_OPTION>());+ // the value is stored under the actual key, not the deprecated one+ EXPECT_FALSE(config.has("DUMMY_OLD_KEY"));+}++TEST_F(ConfigUnitTests, UpdateThroughEachDeprecatedKeySetsTheActualOption) {+ for (const auto& deprecatedKey : DUMMY_MULTI_DEPRECATED_KEYS_OPTION::deprecatedKeys()) {+ auto config = makeConfig();+ config.update({{std::string(deprecatedKey), "7"}});++ EXPECT_TRUE(config.has<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>()) << "key: " << deprecatedKey;+ EXPECT_EQ(7, config.get<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>()) << "key: " << deprecatedKey;+ }+}++TEST_F(ConfigUnitTests, UpdateThroughDeprecatedKeyAcceptsAnAnyPayload) {+ auto config = makeConfig();+ config.update("DUMMY_FIRST_OLD_KEY", ov::Any(int64_t{7}));++ EXPECT_EQ(7, config.get<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>());+}++// The alias is resolved before anything is parsed, so the option's own `parse()` and `validateValue()` are the+// ones which run, and errors are reported against the actual key+TEST_F(ConfigUnitTests, UpdateThroughDeprecatedKeyRunsParsingAndValidation) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update("DUMMY_FIRST_OLD_KEY", "abc"),+ ov::Exception,+ "Failed to parse 'DUMMY_MULTI_DEPRECATED_KEYS_OPTION' option");+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update("DUMMY_FIRST_OLD_KEY", "-1"),+ ov::Exception,+ "expects non-negative values");+ EXPECT_FALSE(config.has<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>());+}++TEST_F(ConfigUnitTests, DeprecatedAndActualKeysWriteToTheSameSlot) {+ auto config = makeConfig();+ config.update("DUMMY_FIRST_OLD_KEY", "1");+ config.update("DUMMY_SECOND_OLD_KEY", "2");+ config.update(DUMMY_MULTI_DEPRECATED_KEYS_OPTION::key(), "3");++ EXPECT_EQ(3, config.get<DUMMY_MULTI_DEPRECATED_KEYS_OPTION>());+ // a single entry, serialized under the actual key+ EXPECT_EQ("DUMMY_MULTI_DEPRECATED_KEYS_OPTION=\"3\"", config.toString());+}++TEST_F(ConfigUnitTests, OptionDescriptorLookupResolvesDeprecatedKeys) {+ const auto config = makeConfig();++ EXPECT_TRUE(config.hasOpt("DUMMY_OLD_KEY"));+ EXPECT_EQ(DUMMY_DEPRECATED_KEYS_OPTION::key(), config.getOpt("DUMMY_OLD_KEY").key());+}++TEST_F(ConfigUnitTests, UpdateWithUnknownKeyThrows) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update("SOME_UNKNOWN_OPTION", "value"), ov::Exception, "[ NOT_FOUND ]");+}++TEST_F(ConfigUnitTests, UpdateWithUnparsableValueThrows) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_RUN_TIME_OPTION::key(), "abc"),+ ov::Exception,+ "Failed to parse 'DUMMY_RUN_TIME_OPTION' option");+}++TEST_F(ConfigUnitTests, UpdateRunsTheOptionValidation) {+ auto config = makeConfig();+ config.update(DUMMY_VALIDATED_OPTION::key(), "1");+ EXPECT_EQ(1, config.get<DUMMY_VALIDATED_OPTION>());++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_VALIDATED_OPTION::key(), "-1"),+ ov::Exception,+ "expects non-negative values");++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_VALIDATED_OPTION::key(), ov::Any(int64_t{-1})),+ ov::Exception,+ "expects non-negative values");+}++TEST_F(ConfigUnitTests, UpdateTakesTheValueAsIs) {+ auto config = makeConfig();+ config.update(DUMMY_RUN_TIME_OPTION::key(), ov::Any(int64_t{7}));+ config.update(DUMMY_BOTH_OPTION::key(), ov::Any(std::string("custom")));++ EXPECT_EQ(7, config.get<DUMMY_RUN_TIME_OPTION>());+ EXPECT_EQ("custom", config.get<DUMMY_BOTH_OPTION>());+}++// A string payload must reach the option's own parser instead of being re-parsed by `ov::Any::as()`+TEST_F(ConfigUnitTests, UpdateWithStringPayloadUsesTheOptionParser) {+ auto config = makeConfig();+ config.update(DUMMY_CUSTOM_PARSE_OPTION::key(), ov::Any(std::string("AUTO")));++ EXPECT_EQ(-1, config.get<DUMMY_CUSTOM_PARSE_OPTION>());+}++TEST_F(ConfigUnitTests, StringAndAnyPayloadsAcceptTheSameBooleanSpellings) {+ for (const auto& val : {"YES", "yes", "TRUE", "ON", "1"}) {+ auto fromString = makeConfig();+ fromString.update(DUMMY_BOOL_OPTION::key(), val);++ auto fromAny = makeConfig();+ fromAny.update(DUMMY_BOOL_OPTION::key(), ov::Any(std::string(val)));++ EXPECT_TRUE(fromString.get<DUMMY_BOOL_OPTION>()) << "value: " << val;+ EXPECT_TRUE(fromAny.get<DUMMY_BOOL_OPTION>()) << "value: " << val;+ }+}++TEST_F(ConfigUnitTests, UpdateKeepsStringOptionsIntact) {+ auto config = makeConfig();+ config.update(DUMMY_BOTH_OPTION::key(), ov::Any(std::string("some value with spaces")));++ EXPECT_EQ("some value with spaces", config.get<DUMMY_BOTH_OPTION>());+}++TEST_F(ConfigUnitTests, UpdateWithUnparsableStringPayloadReportsTheOption) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_RUN_TIME_OPTION::key(), ov::Any(std::string("abc"))),+ ov::Exception,+ "Failed to parse 'DUMMY_RUN_TIME_OPTION' option");+}++TEST_F(ConfigUnitTests, UpdateWithStringPayloadRunsTheOptionValidation) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_VALIDATED_OPTION::key(), ov::Any(std::string("-1"))),+ ov::Exception,+ "expects non-negative values");+}++// Payloads which already have the option's exact type must keep bypassing the parser, as some options+// cannot be built from a string at all+TEST_F(ConfigUnitTests, UpdateWithExactlyTypedPayloadSkipsTheOptionParser) {+ auto config = makeConfig();+ config.update(DUMMY_CUSTOM_PARSE_OPTION::key(), ov::Any(int64_t{-1}));+ config.update(DUMMY_BOOL_OPTION::key(), ov::Any(true));++ EXPECT_EQ(-1, config.get<DUMMY_CUSTOM_PARSE_OPTION>());+ EXPECT_TRUE(config.get<DUMMY_BOOL_OPTION>());+}++// `ov::Any::as<uint32_t>()` would convert -2.0f through an unchecked arithmetic cast, wrapping it around+// into a huge positive value which then passes any range validation+TEST_F(ConfigUnitTests, UpdateWithMismatchedArithmeticPayloadIsRejected) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_UINT32_OPTION::key(), ov::Any(-2.0f)),+ ov::Exception,+ "Failed to parse 'DUMMY_UINT32_OPTION' option");+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_UINT32_OPTION::key(), ov::Any(int64_t{-2})),+ ov::Exception,+ "Failed to parse 'DUMMY_UINT32_OPTION' option");++ EXPECT_FALSE(config.has<DUMMY_UINT32_OPTION>());+ EXPECT_EQ(1u, config.get<DUMMY_UINT32_OPTION>());+}++// A payload of a different type is still usable as long as its value fits the option+TEST_F(ConfigUnitTests, UpdateWithMismatchedArithmeticPayloadGoesThroughTheParser) {+ auto config = makeConfig();+ config.update(DUMMY_UINT32_OPTION::key(), ov::Any(int64_t{7}));++ EXPECT_EQ(7u, config.get<DUMMY_UINT32_OPTION>());+}++// An unprintable payload is stringified into an empty spelling, which the `std::string` parser would otherwise+// accept, silently setting the option to an empty value instead of reporting the unusable payload+TEST_F(ConfigUnitTests, UpdateWithUnprintablePayloadIsRejected) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_BOTH_OPTION::key(), ov::Any(UnprintablePayload{})),+ ov::Exception,+ "can't be converted to a string");++ EXPECT_FALSE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_EQ("both_default", config.get<DUMMY_BOTH_OPTION>());+}++// An empty `ov::Any` is stringified into an empty spelling as well+TEST_F(ConfigUnitTests, UpdateWithEmptyPayloadIsRejected) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_BOTH_OPTION::key(), ov::Any()),+ ov::Exception,+ "No value was provided");++ EXPECT_FALSE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_EQ("both_default", config.get<DUMMY_BOTH_OPTION>());+}++// An empty spelling is still accepted when it really was given as a string, for an option whose parser takes it+TEST_F(ConfigUnitTests, UpdateWithEmptyStringPayloadIsAccepted) {+ auto config = makeConfig();+ config.update(DUMMY_BOTH_OPTION::key(), ov::Any(std::string()));++ EXPECT_TRUE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_EQ("", config.get<DUMMY_BOTH_OPTION>());+}++// A string literal reaches the option's parser as an empty spelling as well, which is not the same thing as+// providing no value at all: here it is the option's own parser which rejects it+TEST_F(ConfigUnitTests, UpdateWithEmptyStringPayloadIsRejectedByTheOptionParser) {+ auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_BOOL_OPTION::key(), ""),+ ov::Exception,+ "is not a valid BOOL option");+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(DUMMY_RUN_TIME_OPTION::key(), ov::Any(std::string())),+ ov::Exception,+ "is not a valid INT64 option");++ EXPECT_FALSE(config.has<DUMMY_BOOL_OPTION>());+ EXPECT_FALSE(config.has<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, RemoveDropsThePreviouslySetValue) {+ auto config = makeConfig();+ config.update(DUMMY_RUN_TIME_OPTION::key(), "7");+ ASSERT_TRUE(config.has(std::string(DUMMY_RUN_TIME_OPTION::key())));++ config.remove(std::string(DUMMY_RUN_TIME_OPTION::key()));++ EXPECT_FALSE(config.has<DUMMY_RUN_TIME_OPTION>());+ // back to the default value+ EXPECT_EQ(42, config.get<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, ToStringSerializesOnlyTheSetOptions) {+ auto config = makeConfig();+ config.update(DUMMY_BOTH_OPTION::key(), "custom");++ EXPECT_EQ("DUMMY_BOTH_OPTION=\"custom\"", config.toString());+}++TEST_F(ConfigUnitTests, ToStringFromStringRoundTrip) {+ auto config = makeConfig();+ config.update(+ {{std::string(DUMMY_BOTH_OPTION::key()), "custom"}, {std::string(DUMMY_RUN_TIME_OPTION::key()), "7"}});++ auto restored = makeConfig();+ restored.fromString(config.toString());++ EXPECT_EQ("custom", restored.get<DUMMY_BOTH_OPTION>());+ EXPECT_EQ(7, restored.get<DUMMY_RUN_TIME_OPTION>());+}++TEST_F(ConfigUnitTests, OptionDescriptorLookupIsForwardedToTheDesc) {+ const auto config = makeConfig();++ EXPECT_TRUE(config.hasOpt(DUMMY_BOTH_OPTION::key()));+ EXPECT_FALSE(config.hasOpt("SOME_UNKNOWN_OPTION"));+ EXPECT_EQ(OptionMode::RunTime, config.getOpt(DUMMY_RUN_TIME_OPTION::key()).mode());+ OV_EXPECT_THROW_HAS_SUBSTRING(config.getOpt("SOME_UNKNOWN_OPTION"), ov::Exception, "[ NOT_FOUND ]");+}++//+// Config - internal compiler options+//++TEST_F(ConfigUnitTests, InternalOptionCanBeAddedAndRead) {+ auto config = makeConfig();+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");++ EXPECT_TRUE(config.hasInternal("INTERNAL_OPTION"));+ EXPECT_EQ("1", config.getInternal("INTERNAL_OPTION"));+}++TEST_F(ConfigUnitTests, InternalOptionIsOverwrittenOnSecondAdd) {+ auto config = makeConfig();+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");+ config.addOrUpdateInternal("INTERNAL_OPTION", "2");++ EXPECT_EQ("2", config.getInternal("INTERNAL_OPTION"));+}++TEST_F(ConfigUnitTests, ReadingMissingInternalOptionThrows) {+ const auto config = makeConfig();++ EXPECT_FALSE(config.hasInternal("INTERNAL_OPTION"));+ OV_EXPECT_THROW_HAS_SUBSTRING(config.getInternal("INTERNAL_OPTION"), ov::Exception, "does not exist");+}++TEST_F(ConfigUnitTests, RemoveCompileTimeConfigsKeepsRunTimeAndBothOptions) {+ auto config = makeConfig();+ config.update({{std::string(DUMMY_BOTH_OPTION::key()), "custom"},+ {std::string(DUMMY_COMPILE_TIME_OPTION::key()), "custom"},+ {std::string(DUMMY_RUN_TIME_OPTION::key()), "7"}});+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");++ config.removeCompileTimeConfigs();++ EXPECT_FALSE(config.has<DUMMY_COMPILE_TIME_OPTION>());+ EXPECT_TRUE(config.has<DUMMY_BOTH_OPTION>());+ EXPECT_TRUE(config.has<DUMMY_RUN_TIME_OPTION>());+ EXPECT_FALSE(config.hasInternal("INTERNAL_OPTION"));+}++//+// Config - compiler serialization+//++TEST_F(ConfigUnitTests, ToStringForCompilerRequiresAPredicate) {+ const auto config = makeConfig();++ OV_EXPECT_THROW_HAS_SUBSTRING(config.toStringForCompiler(nullptr),+ ov::Exception,+ "requires a valid support predicate");+}++TEST_F(ConfigUnitTests, ToStringForCompilerSerializesSupportedCompileTimeAndBothOptions) {+ auto config = makeConfig();+ config.update({{std::string(DUMMY_BOTH_OPTION::key()), "both_value"},+ {std::string(DUMMY_COMPILE_TIME_OPTION::key()), "compile_value"}});++ const auto serialized = config.toStringForCompiler([](const std::string&) {+ return true;+ });++ EXPECT_TRUE(containsEntry(serialized, DUMMY_BOTH_OPTION::key(), "both_value")) << serialized;+ EXPECT_TRUE(containsEntry(serialized, DUMMY_COMPILE_TIME_OPTION::key(), "compile_value")) << serialized;+}++TEST_F(ConfigUnitTests, ToStringForCompilerSkipsRunTimeOptions) {+ auto config = makeConfig();+ config.update(DUMMY_RUN_TIME_OPTION::key(), "7");++ const auto serialized = config.toStringForCompiler([](const std::string&) {+ return true;+ });++ EXPECT_EQ("", serialized);+}++// A "Both" option the compiler doesn't know about is still usable by the plugin, so it is silently dropped+TEST_F(ConfigUnitTests, ToStringForCompilerSkipsUnsupportedBothOptions) {+ auto config = makeConfig();+ config.update(DUMMY_BOTH_OPTION::key(), "both_value");++ const auto serialized = config.toStringForCompiler([](const std::string&) {return false;});- // make sure TESTVALUE_3 cannot be parsed by DUMMY_TEST_OPTION- OV_EXPECT_THROW_HAS_SUBSTRING(DUMMY_TEST_OPTION::parse(hardcodedTestValue3),+ EXPECT_EQ("", serialized);+}++// A compile-time-only option the compiler doesn't know about cannot be honored, hence the hard error+TEST_F(ConfigUnitTests, ToStringForCompilerThrowsOnUnsupportedCompileTimeOption) {+ auto config = makeConfig();+ config.update(DUMMY_COMPILE_TIME_OPTION::key(), "compile_value");++ OV_EXPECT_THROW_HAS_SUBSTRING(config.toStringForCompiler([](const std::string&) {+ return false;+ }),ov::Exception,- expectedParseErrorMessage.data());+ "[ NOT_FOUND ]");+}++TEST_F(ConfigUnitTests, ToStringForCompilerSerializesInternalOptions) {+ auto config = makeConfig();+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");++ const auto serialized = config.toStringForCompiler([](const std::string&) {+ return true;+ });++ EXPECT_TRUE(containsEntry(serialized, "INTERNAL_OPTION", "1")) << serialized;+}++TEST_F(ConfigUnitTests, ToStringForCompilerThrowsOnUnsupportedInternalOption) {+ auto config = makeConfig();+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");++ OV_EXPECT_THROW_HAS_SUBSTRING(config.toStringForCompiler([](const std::string&) {+ return false;+ }),+ ov::Exception,+ "[ NOT_FOUND ]");+}++TEST_F(ConfigUnitTests, SerializedEntriesAreSpaceSeparated) {+ auto config = makeConfig();+ config.update(DUMMY_COMPILE_TIME_OPTION::key(), "compile_value");+ config.addOrUpdateInternal("INTERNAL_OPTION", "1");++ const auto serialized = config.toStringForCompiler([](const std::string&) {+ return true;+ });++ EXPECT_EQ(1u, std::count(serialized.begin(), serialized.end(), ' ')) << serialized;+}++//+// Config - environment variables+//++TEST_F(ConfigUnitTests, EnvVarIsAppliedToTheMatchingOption) {+ const ScopedEnvVar envVar("OV_NPU_DUMMY_ENV_OPTION", "7");++ auto config = makeConfig();+ config.parseEnvVars();++ EXPECT_TRUE(config.has<DUMMY_ENV_OPTION>());+ EXPECT_EQ(7, config.get<DUMMY_ENV_OPTION>());+}++TEST_F(ConfigUnitTests, InvalidEnvVarValueIsIgnored) {+ const ScopedEnvVar envVar("OV_NPU_DUMMY_ENV_OPTION", "abc");++ auto config = makeConfig();+ EXPECT_NO_THROW(config.parseEnvVars());++ EXPECT_FALSE(config.has<DUMMY_ENV_OPTION>());+ EXPECT_EQ(0, config.get<DUMMY_ENV_OPTION>());+}++TEST_F(ConfigUnitTests, OptionsWithoutEnvVarAreLeftUntouched) {+ auto config = makeConfig();+ config.parseEnvVars();++ EXPECT_FALSE(config.has<DUMMY_BOTH_OPTION>());+}++//+// Real options+//++using RealOptionsUnitTests = ::testing::Test;++// `ov::log::Level` has no dedicated `OptionParser` / `OptionPrinter` specialization, it goes through the+// stream-operator-based defaults+TEST_F(RealOptionsUnitTests, LogLevelIsParsedAndPrintedThroughTheDefaults) {+ auto desc = std::make_shared<OptionsDesc>();+ desc->add<intel_npu::LOG_LEVEL>();+ Config config(desc);++ config.update(intel_npu::LOG_LEVEL::key(), "LOG_DEBUG");++ EXPECT_EQ(ov::log::Level::DEBUG, config.get<intel_npu::LOG_LEVEL>());+ EXPECT_EQ("LOG_DEBUG", config.getString<intel_npu::LOG_LEVEL>());+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(intel_npu::LOG_LEVEL::key(), "LOG_SOMETHING"),+ ov::Exception,+ "Failed to parse 'LOG_LEVEL' option");+}++// A malformed public setting must be rejected instead of being silently applied from its valid prefix+TEST_F(RealOptionsUnitTests, MalformedValuesAreRejectedForPublicOptions) {+ auto desc = std::make_shared<OptionsDesc>();+ desc->add<intel_npu::COMPILER_TYPE>();+ desc->add<intel_npu::PERFORMANCE_HINT_NUM_REQUESTS>();+ Config config(desc);++ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(intel_npu::COMPILER_TYPE::key(), "PLUGIN garbage"),+ ov::Exception,+ "Failed to parse 'NPU_COMPILER_TYPE' option");+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(intel_npu::PERFORMANCE_HINT_NUM_REQUESTS::key(), "12oops"),+ ov::Exception,+ "Failed to parse 'PERFORMANCE_HINT_NUM_REQUESTS' option");+ // the value `OVPropertiesIncorrectTests` passes for this property+ OV_EXPECT_THROW_HAS_SUBSTRING(config.update(intel_npu::PERFORMANCE_HINT_NUM_REQUESTS::key(), ov::Any(-2.0f)),+ ov::Exception,+ "Failed to parse 'PERFORMANCE_HINT_NUM_REQUESTS' option");++ EXPECT_EQ(ov::intel_npu::CompilerType::PREFER_PLUGIN, config.get<intel_npu::COMPILER_TYPE>());+ EXPECT_FALSE(config.has<intel_npu::PERFORMANCE_HINT_NUM_REQUESTS>());++ // the well formed spellings still go through+ config.update(intel_npu::COMPILER_TYPE::key(), "PLUGIN");+ config.update(intel_npu::PERFORMANCE_HINT_NUM_REQUESTS::key(), "12");++ EXPECT_EQ(ov::intel_npu::CompilerType::PLUGIN, config.get<intel_npu::COMPILER_TYPE>());+ EXPECT_EQ(12u, config.get<intel_npu::PERFORMANCE_HINT_NUM_REQUESTS>());+}++TEST_F(RealOptionsUnitTests, ExecutionModeHintIsParsedAndPrintedThroughTheDefaults) {+ auto desc = std::make_shared<OptionsDesc>();+ desc->add<intel_npu::EXECUTION_MODE_HINT>();+ Config config(desc);++ EXPECT_EQ(ov::hint::ExecutionMode::PERFORMANCE, config.get<intel_npu::EXECUTION_MODE_HINT>());- ASSERT_EQ(true,- options.get(dummy_test_option.name())- .isValueSupported(hardcodedTestValue3)); // even if TESTVALUE_3 cannot be parsed,- // custom checker should be prioritized+ config.update(intel_npu::EXECUTION_MODE_HINT::key(), "ACCURACY");- // same prioritization expectation for custom value checker even if class implements self `isValueSupported` method- // which returns `true`- ASSERT_EQ(false,- options.get(dummy_test_option_custom_class_checker.name())- .isValueSupported(DUMMY_TEST_OPTION_CUSTOM_CLASS_CHECKER::toString(DummyTestOption::TESTVALUE_2)));+ EXPECT_EQ(ov::hint::ExecutionMode::ACCURACY, config.get<intel_npu::EXECUTION_MODE_HINT>());+ EXPECT_EQ("ACCURACY", config.getString<intel_npu::EXECUTION_MODE_HINT>());}} // namespace