Skip to content

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

[intel-npu] Bugfix for total allocable memory property (#27270)

Attila Csoka7ccc5e0efcc
diff --git a/src/plugins/intel_npu/src/backend/src/zero_device.cpp b/src/plugins/intel_npu/src/backend/src/zero_device.cpp
index ac60e474194..439b5fbd59f 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_device.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_device.cpp
@@ -162,12 +162,22 @@ uint64_t ZeroDevice::getAllocMemSize() const {
}
uint64_t ZeroDevice::getTotalMemSize() const {
+#define LEGACY_MAX_MEM_ALLOC_SIZE_BYTES (2147483648) // 2GB in base-2
+
ze_graph_memory_query_t query{};
ze_result_t result =
_graph_ddi_table_ext.pfnQueryContextMemory(_initStructs->getContext(), ZE_GRAPH_QUERY_MEMORY_DDR, &query);
THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnQueryContextMemory", result, _graph_ddi_table_ext);
- return query.total;
+ // For drivers with graph_extension < 1.9 we report fixed 2GB max allocation size (old drivers don't support more)
+ // For drivers with graph_extension > 1.9 we report the value they return
+ if (_initStructs->isExtensionSupported(std::string(ZE_GRAPH_EXT_NAME), ZE_MAKE_VERSION(1, 9))) {
+ // we are safe here, can return the value directly from driver
+ return query.total;
+ }
+
+ // Default for older drivers: return 2GB
+ return LEGACY_MAX_MEM_ALLOC_SIZE_BYTES;
}
ov::device::PCIInfo ZeroDevice::getPciInfo() const {