diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hpp index eeefcb9f5b4e1a..b13be5000513ec 100644 --- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp +++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp @@ -61,12 +61,14 @@ class Plugin : public ov::IPlugin { std::unique_ptr _metrics; // properties map: {name -> [supported, mutable, eval function]} - std::map>> _properties; - std::vector _supportedProperties; + mutable std::map>> + _properties; + mutable std::vector _supportedProperties; static std::atomic _compiledModelLoadCounter; - bool min_compiler_requirement(uint32_t compiler_version_requirement); + void reset_compiler_dependent_properties() const; + void reset_supported_properties() const; }; } // namespace intel_npu diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp index 0755c0220d92d9..a81ed843bca3f4 100644 --- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp +++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp @@ -450,7 +450,7 @@ Plugin::Plugin() return config.get(); }}}, {ov::intel_npu::compiler_dynamic_quantization.name(), - {min_compiler_requirement(ICOMPILER_MAKE_VERSION(7, 1)), + {false, ov::PropertyMutability::RW, [](const Config& config) { return config.get(); @@ -571,7 +571,12 @@ Plugin::Plugin() {ov::intel_npu::batch_mode.name(), {false, ov::PropertyMutability::RW, [](const Config& config) { return config.getString(); }}}}; +} +void Plugin::reset_supported_properties() const { + /// reset first + _supportedProperties.clear(); /// Mutable member + /// populate for (auto& property : _properties) { if (std::get<0>(property.second)) { _supportedProperties.emplace_back(ov::PropertyName(property.first, std::get<1>(property.second))); @@ -579,9 +584,27 @@ Plugin::Plugin() } } +void Plugin::reset_compiler_dependent_properties() const { + // get active compiler version + CompilerAdapterFactory compilerAdapterFactory; + auto dummyCompiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), _globalConfig); + uint32_t active_compiler_version = dummyCompiler->get_version(); + + // NPU_COMPILER_DYNAMIC_QUANTIZATION + // unpublish if compiler version requirement is not met + if (_properties.find(ov::intel_npu::compiler_dynamic_quantization.name()) != _properties.end()) { + if (active_compiler_version >= ICOMPILER_MAKE_VERSION(7, 1)) { + std::get<0>(_properties[ov::intel_npu::compiler_dynamic_quantization.name()]) = true; /// mark supported + } else { + std::get<0>(_properties[ov::intel_npu::compiler_dynamic_quantization.name()]) = false; // mark unsupported + } + } +} + void Plugin::set_property(const ov::AnyMap& properties) { const std::map config = any_copy(properties); update_log_level(config); + bool compiler_type_change = false; for (const auto& configEntry : config) { if (_properties.find(configEntry.first) == _properties.end()) { OPENVINO_THROW("Unsupported configuration key: ", configEntry.first); @@ -589,6 +612,10 @@ void Plugin::set_property(const ov::AnyMap& properties) { if (std::get<1>(_properties[configEntry.first]) == ov::PropertyMutability::RO) { OPENVINO_THROW("READ-ONLY configuration key: ", configEntry.first); } + if (configEntry.first == ov::intel_npu::compiler_type.name()) { + // we just assume its a change, not compare against old value + compiler_type_change = true; + } } } @@ -600,12 +627,26 @@ void Plugin::set_property(const ov::AnyMap& properties) { for (const auto& entry : config) { _config[entry.first] = entry.second; } + + if (compiler_type_change) { + // if compiler type was changed > need to reset properties to match the new compiler + // since properties have changed > need to reset supported_properties as well + reset_compiler_dependent_properties(); + reset_supported_properties(); + } } ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& arguments) const { const std::map& amends = any_copy(arguments); const Config amendedConfig = merge_configs(_globalConfig, amends); + /// Special case for supportedProperties + /// populate it at first get + if (name == ov::supported_properties.name() && _supportedProperties.size() < 1) { + reset_compiler_dependent_properties(); + reset_supported_properties(); + } + auto&& configIterator = _properties.find(name); if (configIterator != _properties.cend()) { return std::get<2>(configIterator->second)(amendedConfig); @@ -854,15 +895,6 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr& return supportedOpsMap; } -bool Plugin::min_compiler_requirement(uint32_t compiler_version_requirement) { - /// Internal helper function to check if compiler_version_requirement param >= actual compiler version in use - /// create dummy compiler of from config - CompilerAdapterFactory compilerAdapterFactory; - auto dummyCompiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), _globalConfig); - uint32_t compiler_version_in_use = dummyCompiler->get_version(); - return (compiler_version_in_use >= compiler_version_requirement); -} - std::atomic Plugin::_compiledModelLoadCounter{1}; static const ov::Version version = {CI_BUILD_NUMBER, NPU_PLUGIN_LIB_NAME};