Skip to content

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

[NPU] Resolve compiler type, platform and device id for each property if needed (#38558)

Bogdan Pereanu8f311956948b
diff --git a/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp b/src/plugins/intel_npu/src/plugin/include/plugin_property_manager.hpp
index f980b2441ee..c9f5cd439e1 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
@@ -46,9 +46,14 @@ public:
private:
void registerProperties();
- std::optional<ov::intel_npu::CompilerType> resolveCompilerType(ov::intel_npu::CompilerType compilerType,
- const std::string& deviceId,
- const std::string& platform) const;
+
+ // The helpers below read the value from the arguments and fall back to the stored config when missing.
+ // They don't lock _mutex, callers must hold it.
+ std::string getDeviceIdOrDefault(const ov::AnyMap& arguments) const;
+ std::string getPlatformOrDefault(const ov::AnyMap& arguments) const;
+ std::optional<ov::intel_npu::CompilerType> getCompilerTypeOrDefault(const ov::AnyMap& arguments) const;
+ std::optional<ov::intel_npu::CompilerType> resolveCompilerType(const ov::AnyMap& arguments) const;
+
void warnCompilerOnlyOptionSkipped(const std::string& key) const;
Config _config;
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp
index 3ccb57ebed5..ad7dd207fe5 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
@@ -25,30 +25,6 @@ void logCpuPinningDeprecationWarning(intel_npu::Logger& logger) {
OPENVINO_SUPPRESS_DEPRECATED_END
}
-struct ResolvedRequestContext {
- ov::intel_npu::CompilerType compilerType;
- std::string deviceId;
- std::string platform;
-};
-
-ResolvedRequestContext resolveRequestContext(const ov::AnyMap& arguments,
- ov::intel_npu::CompilerType defaultCompilerType,
- std::string defaultDeviceId,
- std::string defaultPlatform) {
- const auto compilerTypeIt = arguments.find(ov::intel_npu::compiler_type.name());
- const auto compilerType = compilerTypeIt == arguments.end()
- ? defaultCompilerType
- : ::intel_npu::COMPILER_TYPE::parse(compilerTypeIt->second.as<std::string>());
-
- const auto deviceIdIt = arguments.find(std::string(ov::device::id.name()));
- auto deviceId = deviceIdIt == arguments.end() ? std::move(defaultDeviceId) : deviceIdIt->second.as<std::string>();
-
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- auto platform = platformIt == arguments.end() ? std::move(defaultPlatform) : platformIt->second.as<std::string>();
-
- return {compilerType, std::move(deviceId), std::move(platform)};
-}
-
bool isCompatibilityCheckSupported(const ov::SoPtr<intel_npu::IEngineBackend>& backend,
intel_npu::CompilerOptionSupportHelper& optionSupportHelper) {
using namespace intel_npu;
@@ -149,22 +125,11 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {
logCpuPinningDeprecationWarning(_logger);
}
- auto normalizedArguments = resolveRequestContext(properties,
- _config.get<COMPILER_TYPE>(),
- _config.get<DEVICE_ID>(),
- _config.get<PLATFORM>());
- ov::AnyMap supportCheckArguments = properties;
- supportCheckArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;
- supportCheckArguments[ov::device::id.name()] = normalizedArguments.deviceId;
- supportCheckArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;
-
for (auto&& value : properties) {
const auto propertyDescriptorIt = _properties.find(value.first);
if (propertyDescriptorIt == _properties.end()) {
// property doesn't exist - checking as internal now
- const auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,
- normalizedArguments.deviceId,
- normalizedArguments.platform);
+ const auto resolvedCompilerType = resolveCompilerType(properties);
OPENVINO_ASSERT(resolvedCompilerType.has_value(), "Unsupported configuration key: ", value.first);
bool isSupported = false;
try {
@@ -180,9 +145,7 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {
OPENVINO_ASSERT(descriptor.mutability != ov::PropertyMutability::RO,
"READ-ONLY configuration key: ",
value.first);
- OPENVINO_ASSERT(descriptor.isSupported(supportCheckArguments),
- "Unsupported configuration key: ",
- value.first);
+ OPENVINO_ASSERT(descriptor.isSupported(properties), "Unsupported configuration key: ", value.first);
}
}
@@ -198,37 +161,24 @@ void PluginPropertyManager::setProperty(const ov::AnyMap& properties) {
}
ov::Any PluginPropertyManager::getProperty(const std::string& name, const ov::AnyMap& arguments) const {
- auto propertyArguments = arguments;
std::lock_guard<std::mutex> lock(_mutex);
if (name == ov::hint::enable_cpu_pinning.name()) {
logCpuPinningDeprecationWarning(_logger);
}
- auto normalizedArguments = resolveRequestContext(arguments,
- _config.get<COMPILER_TYPE>(),
- _config.get<DEVICE_ID>(),
- _config.get<PLATFORM>());
- propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;
- propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;
- propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;
-
const auto propertyDescriptorIt = _properties.find(name);
if (propertyDescriptorIt != _properties.cend()) {
- OPENVINO_ASSERT(propertyDescriptorIt->second.isSupported(propertyArguments),
- "Unsupported configuration key: ",
- name);
+ OPENVINO_ASSERT(propertyDescriptorIt->second.isSupported(arguments), "Unsupported configuration key: ", name);
if (propertyDescriptorIt->second.mutability == ov::PropertyMutability::WO) {
_logger.warning("Trying to get WRITE-ONLY property: %s. Returning empty `ov::Any` object", name.c_str());
return ov::Any();
}
- return propertyDescriptorIt->second.get(propertyArguments);
+ return propertyDescriptorIt->second.get(arguments);
}
if (_config.hasInternal(name)) {
- auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,
- normalizedArguments.deviceId,
- normalizedArguments.platform);
+ auto resolvedCompilerType = resolveCompilerType(arguments);
OPENVINO_ASSERT(resolvedCompilerType.has_value(), "Unsupported configuration key: ", name);
try {
if (_compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType.value(), name)) {
@@ -241,7 +191,6 @@ ov::Any PluginPropertyManager::getProperty(const std::string& name, const ov::An
}
bool PluginPropertyManager::isPropertySupported(const std::string& name, const ov::AnyMap& arguments) const {
- auto propertyArguments = arguments;
std::lock_guard<std::mutex> lock(_mutex);
if (name == ov::hint::enable_cpu_pinning.name()) {
@@ -254,15 +203,7 @@ bool PluginPropertyManager::isPropertySupported(const std::string& name, const o
return false;
}
- auto normalizedArguments = resolveRequestContext(arguments,
- _config.get<COMPILER_TYPE>(),
- _config.get<DEVICE_ID>(),
- _config.get<PLATFORM>());
- propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;
- propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;
- propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;
-
- return propertyDescriptorIt->second.isPublic && propertyDescriptorIt->second.isSupported(propertyArguments);
+ return propertyDescriptorIt->second.isPublic && propertyDescriptorIt->second.isSupported(arguments);
}
std::pair<Config, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownProperties(const ov::AnyMap& properties,
@@ -283,24 +224,17 @@ std::pair<Config, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownPr
}
ov::AnyMap propertyArguments = properties;
- auto normalizedArguments = resolveRequestContext(properties,
- _config.get<COMPILER_TYPE>(),
- _config.get<DEVICE_ID>(),
- _config.get<PLATFORM>());
if (mergeMode == ConfigMergeMode::Import) {
- // Make sure the compiler type is removed from the property arguments when importing a model with both
- // compile-time and runtime options to check only runtime availability.
+ // Mark the compiler type as unavailable in the property arguments when importing a model with both
+ // compile-time and runtime options to check only runtime availability. An empty value is used instead of
+ // erasing the key, otherwise the support predicates would fall back to the configured compiler type.
if (propertyArguments.find(ov::intel_npu::compiler_type.name()) != propertyArguments.end()) {
_logger.warning("Property '%s' is used to specify the compiler type, will not be used for current "
"configuration.",
ov::intel_npu::compiler_type.name());
- propertyArguments.erase(ov::intel_npu::compiler_type.name());
}
- } else {
- propertyArguments[ov::intel_npu::compiler_type.name()] = normalizedArguments.compilerType;
+ propertyArguments[ov::intel_npu::compiler_type.name()] = ov::Any();
}
- propertyArguments[std::string(ov::device::id.name())] = normalizedArguments.deviceId;
- propertyArguments[ov::intel_npu::platform.name()] = normalizedArguments.platform;
ov::AnyMap unknownProperties;
auto updatedConfig = _config;
@@ -315,9 +249,7 @@ std::pair<Config, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownPr
// model and the model was not loaded from cache, as compile-time-only options are not relevant in that
// case.
bool isSupportedByCompiler = false;
- const auto resolvedCompilerType = resolveCompilerType(normalizedArguments.compilerType,
- normalizedArguments.deviceId,
- normalizedArguments.platform);
+ const auto resolvedCompilerType = resolveCompilerType(properties);
if (resolvedCompilerType.has_value()) {
try {
isSupportedByCompiler =
@@ -403,21 +335,13 @@ std::pair<Config, ov::AnyMap> PluginPropertyManager::getMergedConfigAndUnknownPr
}
std::string PluginPropertyManager::determinePlatform(const ov::AnyMap& properties) const {
- auto platform = properties.find(ov::intel_npu::platform.name());
- if (platform != properties.end()) {
- return platform->second.as<std::string>();
- }
std::lock_guard<std::mutex> lock(_mutex);
- return _config.get<PLATFORM>();
+ return getPlatformOrDefault(properties);
}
std::string PluginPropertyManager::determineDeviceId(const ov::AnyMap& properties) const {
- auto device_id = properties.find(std::string(ov::device::id.name()));
- if (device_id != properties.end()) {
- return device_id->second.as<std::string>();
- }
std::lock_guard<std::mutex> lock(_mutex);
- return _config.get<DEVICE_ID>();
+ return getDeviceIdOrDefault(properties);
}
ov::intel_npu::CompilerType PluginPropertyManager::determineCompilerType(const ov::AnyMap& properties) const {
@@ -429,21 +353,50 @@ ov::intel_npu::CompilerType PluginPropertyManager::determineCompilerType(const o
return _config.get<COMPILER_TYPE>();
}
+std::string PluginPropertyManager::getDeviceIdOrDefault(const ov::AnyMap& arguments) const {
+ const auto deviceIdIt = arguments.find(std::string(ov::device::id.name()));
+ return deviceIdIt != arguments.end() ? deviceIdIt->second.as<std::string>() : _config.get<DEVICE_ID>();
+}
+
+std::string PluginPropertyManager::getPlatformOrDefault(const ov::AnyMap& arguments) const {
+ const auto platformIt = arguments.find(ov::intel_npu::platform.name());
+ return platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
+}
+
+std::optional<ov::intel_npu::CompilerType> PluginPropertyManager::getCompilerTypeOrDefault(
+ const ov::AnyMap& arguments) const {
+ const auto compilerTypeIt = arguments.find(ov::intel_npu::compiler_type.name());
+ if (compilerTypeIt == arguments.end()) {
+ return _config.get<COMPILER_TYPE>();
+ }
+
+ // An empty value explicitly marks the compiler type as unavailable.
+ if (compilerTypeIt->second.empty()) {
+ return std::nullopt;
+ }
+
+ if (compilerTypeIt->second.is<std::string>()) {
+ return COMPILER_TYPE::parse(compilerTypeIt->second.as<std::string>());
+ }
+ return compilerTypeIt->second.as<ov::intel_npu::CompilerType>();
+}
+
std::optional<ov::intel_npu::CompilerType> PluginPropertyManager::resolveCompilerType(
- ov::intel_npu::CompilerType compilerType,
- const std::string& deviceId,
- const std::string& platform) const {
- if (compilerType != ov::intel_npu::CompilerType::PREFER_PLUGIN) {
+ const ov::AnyMap& arguments) const {
+ auto compilerType = getCompilerTypeOrDefault(arguments);
+ if (!compilerType.has_value() || compilerType.value() != ov::intel_npu::CompilerType::PREFER_PLUGIN) {
return compilerType;
}
try {
+ const auto deviceId = getDeviceIdOrDefault(arguments);
auto device = utils::getDeviceById(_backend, deviceId);
- auto compilationPlatform =
- utils::getCompilationPlatform(_backend, platform, device == nullptr ? deviceId : device->getName());
+ auto compilationPlatform = utils::getCompilationPlatform(_backend,
+ getPlatformOrDefault(arguments),
+ device == nullptr ? deviceId : device->getName());
CompilerAdapterFactory factory;
- factory.decideCompilerType(compilerType, device, compilationPlatform);
+ factory.decideCompilerType(compilerType.value(), device, compilationPlatform);
return compilerType;
} catch (const std::exception& ex) {
_logger.warning("Failed to resolve compiler type: %s. Compiler-dependent properties will be unsupported.",
@@ -468,22 +421,14 @@ void PluginPropertyManager::registerProperties() {
// Guarded by PluginPropertyManager::_mutex, held by all call sites that invoke this predicate.
auto hasBackendAndValidDeviceCache = std::make_shared<std::optional<std::pair<std::string, bool>>>();
- const auto getDeviceId = [](const ov::AnyMap& arguments) -> std::string {
- const auto deviceIdIt = arguments.find(ov::device::id.name());
- if (deviceIdIt != arguments.end()) {
- return deviceIdIt->second.as<std::string>();
- }
- return std::string();
- };
-
const auto hasBackendAndValidDevice =
- [this, hasBackend, hasBackendAndValidDeviceCache, getDeviceId](const ov::AnyMap& arguments) {
+ [this, hasBackend, hasBackendAndValidDeviceCache](const ov::AnyMap& arguments) {
if (!hasBackend) {
return false;
}
try {
- const auto specifiedDeviceName = getDeviceId(arguments);
+ const auto specifiedDeviceName = getDeviceIdOrDefault(arguments);
if (hasBackendAndValidDeviceCache->has_value() &&
hasBackendAndValidDeviceCache->value().first == specifiedDeviceName) {
@@ -501,47 +446,19 @@ void PluginPropertyManager::registerProperties() {
return false;
};
- auto getCompilerTypeOrDefault = [](const ov::AnyMap& arguments) -> std::optional<ov::intel_npu::CompilerType> {
- auto compilerTypeIt = arguments.find(ov::intel_npu::compiler_type.name());
- if (compilerTypeIt == arguments.end()) {
- return std::nullopt;
- }
-
+ const auto isCompilerOptionSupported = [this](const std::string& propertyName, const ov::AnyMap& arguments) {
try {
- return compilerTypeIt->second.as<ov::intel_npu::CompilerType>();
- } catch (...) {
- return std::nullopt;
- }
- };
-
- const auto isCompilerOptionSupported =
- [this, getCompilerTypeOrDefault, getDeviceId](const std::string& propertyName, const ov::AnyMap& arguments) {
- const auto compilerType = getCompilerTypeOrDefault(arguments);
- if (!compilerType.has_value()) {
+ const auto resolvedCompilerType = resolveCompilerType(arguments);
+ if (!resolvedCompilerType.has_value()) {
return false;
}
- ov::intel_npu::CompilerType resolvedCompilerType;
- if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- const auto platform =
- platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
- const auto resolvedCompilerTypeOpt =
- resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);
- if (!resolvedCompilerTypeOpt.has_value()) {
- return false;
- }
- resolvedCompilerType = resolvedCompilerTypeOpt.value();
- } else {
- resolvedCompilerType = compilerType.value();
- }
-
- try {
- return _compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType, propertyName);
- } catch (...) {
- return false;
- }
- };
+ return _compilerOptionSupportHelper->isOptionSupported(resolvedCompilerType.value(), propertyName);
+ } catch (...) {
+ // an invalid compiler type argument or a compiler failure makes the property unsupported
+ return false;
+ }
+ };
const auto registerConfigProperty = [this](const auto optionTag, bool isPublic) {
using OptionType = std::decay_t<decltype(optionTag)>;
@@ -659,8 +576,8 @@ void PluginPropertyManager::registerProperties() {
[this](const ov::AnyMap&) {
return _config.hasOpt(ov::device::id.name());
},
- [this, getDeviceId](const ov::AnyMap& arguments) -> ov::Any {
- const auto deviceId = getDeviceId(arguments);
+ [this](const ov::AnyMap& arguments) -> ov::Any {
+ const auto deviceId = getDeviceIdOrDefault(arguments);
return deviceId.empty() ? ov::Any(_config.get<DEVICE_ID>()) : ov::Any(deviceId);
},
[this](const ov::Any& value) {
@@ -671,7 +588,7 @@ void PluginPropertyManager::registerProperties() {
[this](const ov::AnyMap&) {
return _config.hasOpt(ov::intel_npu::compiler_type.name());
},
- [this, getCompilerTypeOrDefault](const ov::AnyMap& arguments) -> ov::Any {
+ [this](const ov::AnyMap& arguments) -> ov::Any {
const auto compilerType = getCompilerTypeOrDefault(arguments);
return compilerType.has_value() ? ov::Any(compilerType.value()) : ov::Any(_config.get<COMPILER_TYPE>());
},
@@ -681,10 +598,10 @@ void PluginPropertyManager::registerProperties() {
);
register_property(ov::intel_npu::max_tiles.name(), true, ov::PropertyMutability::RO,
hasBackendAndValidDevice,
- [this, getDeviceId](const ov::AnyMap& arguments) {
+ [this](const ov::AnyMap& arguments) {
if (!_config.has<MAX_TILES>()) {
try {
- return static_cast<int64_t>(utils::getMaxTiles(_backend, getDeviceId(arguments)));
+ return static_cast<int64_t>(utils::getMaxTiles(_backend, getDeviceIdOrDefault(arguments)));
} catch (...) {
_logger.warning("GetMaxTiles failed to get value from device.");
}
@@ -836,10 +753,10 @@ void PluginPropertyManager::registerProperties() {
[this](const ov::AnyMap&) {
return _config.hasOpt(ov::intel_npu::stepping.name());
},
- [this, getDeviceId](const ov::AnyMap& arguments) {
+ [this](const ov::AnyMap& arguments) {
if (!_config.has<STEPPING>()) {
try {
- return static_cast<int64_t>(utils::getSteppingNumber(_backend, getDeviceId(arguments)));
+ return static_cast<int64_t>(utils::getSteppingNumber(_backend, getDeviceIdOrDefault(arguments)));
} catch (...) {
_logger.warning("GetSteppingNumber failed to get value from device.");
}
@@ -904,18 +821,11 @@ void PluginPropertyManager::registerProperties() {
OPENVINO_THROW("Property '", ov::hint::model.name(),"' can only be provided when importing a compiled model, it cannot be set otherwise");
}
);
- register_property(ov::supported_properties.name(), true, ov::PropertyMutability::RO, alwaysSupported, [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) {
+ register_property(ov::supported_properties.name(), true, ov::PropertyMutability::RO, alwaysSupported, [this](const ov::AnyMap& arguments) {
+ // Resolve the compiler type once, so the support predicates don't resolve it again for every property.
auto resolvedArguments = arguments;
- if (const auto compilerType = getCompilerTypeOrDefault(arguments); compilerType.has_value() && compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
- const auto resolvedCompilerType = resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);
- if (resolvedCompilerType.has_value()) {
- resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.value();
- } else {
- resolvedArguments.erase(ov::intel_npu::compiler_type.name());
- }
- }
+ const auto resolvedCompilerType = resolveCompilerType(arguments);
+ resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.has_value() ? ov::Any(resolvedCompilerType.value()) : ov::Any();
std::vector<ov::PropertyName> supportedProperties;
for (auto& property : _properties) {
@@ -948,18 +858,11 @@ void PluginPropertyManager::registerProperties() {
register_property(ov::internal::cache_header_alignment.name(), false, ov::PropertyMutability::RO, alwaysSupported, [](const ov::AnyMap&) {
return utils::STANDARD_PAGE_SIZE;
}, readOnlySetter);
- register_property(ov::internal::caching_properties.name(), false, ov::PropertyMutability::RO, alwaysSupported, [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) {
+ register_property(ov::internal::caching_properties.name(), false, ov::PropertyMutability::RO, alwaysSupported, [this](const ov::AnyMap& arguments) {
+ // Resolve the compiler type once, so the support predicates don't resolve it again for every property.
auto resolvedArguments = arguments;
- if (const auto compilerType = getCompilerTypeOrDefault(arguments); compilerType.has_value() && compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
- const auto resolvedCompilerType = resolveCompilerType(compilerType.value(), getDeviceId(arguments), platform);
- if (resolvedCompilerType.has_value()) {
- resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.value();
- } else {
- resolvedArguments.erase(ov::intel_npu::compiler_type.name());
- }
- }
+ const auto resolvedCompilerType = resolveCompilerType(arguments);
+ resolvedArguments[ov::intel_npu::compiler_type.name()] = resolvedCompilerType.has_value() ? ov::Any(resolvedCompilerType.value()) : ov::Any();
std::vector<ov::PropertyName> caching_props{};
for (auto prop : _cachingProperties) {
@@ -975,34 +878,34 @@ void PluginPropertyManager::registerProperties() {
OPENVINO_ASSERT(_backend != nullptr, "No available backend");
return _backend->getDriverVersion();
}, readOnlySetter);
- register_property(ov::device::pci_info.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getPciInfo(_backend, getDeviceId(arguments));
+ register_property(ov::device::pci_info.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getPciInfo(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::device::gops.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getGops(_backend, getDeviceId(arguments));
+ register_property(ov::device::gops.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getGops(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::device::type.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getDeviceType(_backend, getDeviceId(arguments));
+ register_property(ov::device::type.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getDeviceType(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::intel_npu::device_alloc_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getDeviceAllocMemSize(_backend, getDeviceId(arguments));
+ register_property(ov::intel_npu::device_alloc_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getDeviceAllocMemSize(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::intel_npu::device_total_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getDeviceTotalMemSize(_backend, getDeviceId(arguments));
+ register_property(ov::intel_npu::device_total_mem_size.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getDeviceTotalMemSize(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::device::uuid.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- auto devUuid = utils::getDeviceUuid(_backend, getDeviceId(arguments));
+ register_property(ov::device::uuid.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ auto devUuid = utils::getDeviceUuid(_backend, getDeviceIdOrDefault(arguments));
return decltype(ov::device::uuid)::value_type{devUuid};
}, readOnlySetter);
- register_property(ov::device::architecture.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- const auto devName = utils::getDeviceName(_backend, getDeviceId(arguments));
+ register_property(ov::device::architecture.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ const auto devName = utils::getDeviceName(_backend, getDeviceIdOrDefault(arguments));
return utils::getPlatformByDeviceName(devName);
}, readOnlySetter);
- register_property(ov::device::full_name.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getFullDeviceName(_backend, getDeviceId(arguments));
+ register_property(ov::device::full_name.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getFullDeviceName(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
- register_property(ov::device::luid.name(), _backend != nullptr && _backend->isLUIDExtSupported(), ov::PropertyMutability::RO, hasBackendAndValidDevice, [this, getDeviceId](const ov::AnyMap& arguments) {
- return utils::getDeviceLUID(_backend, getDeviceId(arguments));
+ register_property(ov::device::luid.name(), _backend != nullptr && _backend->isLUIDExtSupported(), ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
+ return utils::getDeviceLUID(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
// Guarded by PluginPropertyManager::_mutex, held by all call sites that invoke this predicate.
@@ -1026,20 +929,23 @@ void PluginPropertyManager::registerProperties() {
}, readOnlySetter);
register_property(ov::intel_npu::compiler_version.name(), true, ov::PropertyMutability::RO,
- [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) { // support predicate
- auto compilerType = getCompilerTypeOrDefault(arguments);
+ [this](const ov::AnyMap& arguments) { // support predicate
+ std::optional<ov::intel_npu::CompilerType> compilerType;
+ try {
+ compilerType = getCompilerTypeOrDefault(arguments);
+ } catch (...) {
+ return false;
+ }
if (!compilerType.has_value()) {
return false;
}
std::string compilationPlatform;
if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
- auto deviceId = getDeviceId(arguments);
+ auto deviceId = getDeviceIdOrDefault(arguments);
auto device = utils::getDeviceById(_backend, deviceId);
compilationPlatform = utils::getCompilationPlatform(
_backend,
- platform,
+ getPlatformOrDefault(arguments),
device == nullptr ? deviceId : device->getName()
);
}
@@ -1051,18 +957,16 @@ void PluginPropertyManager::registerProperties() {
return false;
}
},
- [this, getCompilerTypeOrDefault, getDeviceId](const ov::AnyMap& arguments) { // value getter
+ [this](const ov::AnyMap& arguments) { // value getter
auto compilerType = getCompilerTypeOrDefault(arguments);
OPENVINO_ASSERT(compilerType.has_value(), "Compiler type is not specified in properties.");
std::string compilationPlatform;
if (compilerType.value() == ov::intel_npu::CompilerType::PREFER_PLUGIN) {
- const auto platformIt = arguments.find(ov::intel_npu::platform.name());
- const auto platform = platformIt != arguments.end() ? platformIt->second.as<std::string>() : _config.get<PLATFORM>();
- auto deviceId = getDeviceId(arguments);
+ auto deviceId = getDeviceIdOrDefault(arguments);
auto device = utils::getDeviceById(_backend, deviceId);
compilationPlatform = utils::getCompilationPlatform(
_backend,
- platform,
+ getPlatformOrDefault(arguments),
device == nullptr ? deviceId : device->getName());
}