Skip to content

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

[NPU] Update getCompilerVersion and getCompilerProperties methods (#35152)

Bogdan Pereanu191547a45681
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
index 40300a704cc..0b88f4487f0 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_init.hpp
@@ -86,6 +86,7 @@ public:
private:
void initNpuDriver();
+ void initCompilerPropertiesLocked();
void getExtensionFunctionAddress(const std::string& name, const uint32_t version, void** function_address);
void setContextProperties();
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
index 790c67eedb7..cf85eac2941 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
@@ -427,21 +427,27 @@ const std::shared_ptr<ZeroInitStructsHolder> ZeroInitStructsHolder::getInstance(
ze_device_graph_properties_t ZeroInitStructsHolder::getCompilerProperties() {
std::lock_guard<std::mutex> lock(_mutex);
- if (!_compiler_properties.has_value()) {
- // Obtain compiler-in-driver properties
- _compiler_properties.emplace(ze_device_graph_properties_t{});
- _compiler_properties->stype = ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES;
- auto result =
- _graph_dditable_ext_decorator->pfnDeviceGetGraphProperties(_device_handle, &_compiler_properties.value());
- THROW_ON_FAIL_FOR_LEVELZERO("pfnDeviceGetGraphProperties", result);
+ initCompilerPropertiesLocked();
+ return _compiler_properties.value();
+}
+
+void ZeroInitStructsHolder::initCompilerPropertiesLocked() {
+ if (_compiler_properties.has_value()) {
+ return;
}
- return _compiler_properties.value_or(ze_device_graph_properties_t{});
+
+ // Keep optional disengaged unless driver query succeeds.
+ ze_device_graph_properties_t compiler_properties = {};
+ compiler_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES;
+ auto result = _graph_dditable_ext_decorator->pfnDeviceGetGraphProperties(_device_handle, &compiler_properties);
+ THROW_ON_FAIL_FOR_LEVELZERO("pfnDeviceGetGraphProperties", result);
+
+ _compiler_properties = compiler_properties;
}
uint32_t ZeroInitStructsHolder::getCompilerVersion() {
- if (!_compiler_properties.has_value()) {
- (void)getCompilerProperties();
- }
+ std::lock_guard<std::mutex> lock(_mutex);
+ initCompilerPropertiesLocked();
return ZE_MAKE_VERSION(_compiler_properties->compilerVersion.major, _compiler_properties->compilerVersion.minor);
}