Skip to content

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

[NPU] Fix ov::device::architecture property (#38645)

Bogdan Pereanuf4753c407901
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp
index 8e70c4bda32..6010a96c67b 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/device_helpers.hpp
@@ -25,6 +25,8 @@ std::string getCompilationPlatform(const ov::SoPtr<IEngineBackend>& engineBacken
*/
std::shared_ptr<IDevice> getDeviceById(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& deviceId);
std::string getFullDeviceName(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);
+std::string getDeviceArchitecture(const ov::SoPtr<IEngineBackend>& engineBackend,
+ const std::string& specifiedDeviceName);
IDevice::Uuid getDeviceUuid(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);
ov::device::LUID getDeviceLUID(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);
uint32_t getSteppingNumber(const ov::SoPtr<IEngineBackend>& engineBackend, const std::string& specifiedDeviceName);
diff --git a/src/plugins/intel_npu/src/common/src/device_helpers.cpp b/src/plugins/intel_npu/src/common/src/device_helpers.cpp
index 4fd20e2e883..5110e704a55 100644
--- a/src/plugins/intel_npu/src/common/src/device_helpers.cpp
+++ b/src/plugins/intel_npu/src/common/src/device_helpers.cpp
@@ -87,6 +87,17 @@ std::string utils::getFullDeviceName(const ov::SoPtr<IEngineBackend>& engineBack
OPENVINO_THROW("No device with name '", specifiedDeviceName, "' is available");
}
+std::string utils::getDeviceArchitecture(const ov::SoPtr<IEngineBackend>& engineBackend,
+ const std::string& specifiedDeviceName) {
+ // Empty name falls back to the first available device inside the backend
+ auto device = getDeviceById(engineBackend, specifiedDeviceName);
+ if (device) {
+ return device->getName();
+ }
+
+ return std::string();
+}
+
IDevice::Uuid utils::getDeviceUuid(const ov::SoPtr<IEngineBackend>& engineBackend,
const std::string& specifiedDeviceName) {
const auto devName = getDeviceName(engineBackend, specifiedDeviceName);
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 ad7dd207fe5..b4f5c143334 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
@@ -898,8 +898,7 @@ void PluginPropertyManager::registerProperties() {
return decltype(ov::device::uuid)::value_type{devUuid};
}, readOnlySetter);
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);
+ return utils::getDeviceArchitecture(_backend, getDeviceIdOrDefault(arguments));
}, readOnlySetter);
register_property(ov::device::full_name.name(), true, ov::PropertyMutability::RO, hasBackendAndValidDevice, [this](const ov::AnyMap& arguments) {
return utils::getFullDeviceName(_backend, getDeviceIdOrDefault(arguments));
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.cpp
index 3eec0617556..8c54b8d312f 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
@@ -996,6 +996,65 @@ TEST_P(DisableIdleMemoryPruningPropertyTests, MergedConfigurationDoesNotChangeTh
ASSERT_FALSE(propertiesManager->getProperty(ov::intel_npu::disable_idle_memory_prunning.name()).as<bool>());
}
+// DEVICE_ARCHITECTURE must always report the name of the resolved device, no matter how DEVICE_ID identifies it.
+class DeviceArchitecturePropertyTests : public PropertiesManagerTests {
+protected:
+ std::string expectedArchitecture;
+
+ void SetUp() override {
+ PropertiesManagerTests::SetUp();
+
+ const auto device = backend ? backend->getDevice() : nullptr;
+ if (device == nullptr) {
+ GTEST_SKIP() << "No NPU device available.";
+ }
+ expectedArchitecture = device->getName();
+ }
+
+ std::string getArchitecture(const ov::AnyMap& arguments = {}) const {
+ return propertiesManager->getProperty(ov::device::architecture.name(), arguments).as<std::string>();
+ }
+};
+
+TEST_P(DeviceArchitecturePropertyTests, IsSupported) {
+ ASSERT_TRUE(propertiesManager->isPropertySupported(ov::device::architecture.name()));
+}
+
+TEST_P(DeviceArchitecturePropertyTests, DefaultDeviceReturnsDeviceName) {
+ std::string architecture;
+ OV_ASSERT_NO_THROW(architecture = getArchitecture());
+ ASSERT_FALSE(architecture.empty());
+ ASSERT_EQ(architecture, expectedArchitecture);
+}
+
+TEST_P(DeviceArchitecturePropertyTests, DeviceIdAsIndexArgumentReturnsDeviceName) {
+ std::string architecture;
+ OV_ASSERT_NO_THROW(architecture = getArchitecture({ov::device::id("0")}));
+ ASSERT_NE(architecture, "0");
+ ASSERT_EQ(architecture, expectedArchitecture);
+}
+
+TEST_P(DeviceArchitecturePropertyTests, DeviceIdAsNameArgumentReturnsDeviceName) {
+ std::string architecture;
+ OV_ASSERT_NO_THROW(architecture = getArchitecture({ov::device::id(expectedArchitecture)}));
+ ASSERT_EQ(architecture, expectedArchitecture);
+}
+
+TEST_P(DeviceArchitecturePropertyTests, DeviceIdAsIndexInConfigReturnsDeviceName) {
+ OV_ASSERT_NO_THROW(propertiesManager->setProperty({ov::device::id("0")}));
+
+ std::string architecture;
+ OV_ASSERT_NO_THROW(architecture = getArchitecture());
+ ASSERT_NE(architecture, "0");
+ ASSERT_EQ(architecture, expectedArchitecture);
+}
+
+TEST_P(DeviceArchitecturePropertyTests, UnknownDeviceIdIsNotSupported) {
+ OV_EXPECT_THROW(getArchitecture({ov::device::id("UNKNOWN_DEVICE")}),
+ ov::Exception,
+ HasSubstr("Unsupported configuration key: DEVICE_ARCHITECTURE"));
+}
+
} // namespace behavior
} // namespace test
} // namespace ov
@@ -1048,3 +1107,9 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,
::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
::testing::Values(std::string{})),
PropertiesManagerTests::getTestCaseName);
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
+ DeviceArchitecturePropertyTests,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::Values(std::string{})),
+ PropertiesManagerTests::getTestCaseName);
diff --git a/src/plugins/intel_npu/tests/unit/CMakeLists.txt b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
index 787b5495e3b..7d67f988365 100644
--- a/src/plugins/intel_npu/tests/unit/CMakeLists.txt
+++ b/src/plugins/intel_npu/tests/unit/CMakeLists.txt
@@ -172,6 +172,7 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/npu/executor_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npu/should_use_host_compile_interpreter_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npu/compiler_option_support_helper_test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/npu/device_helpers_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npu/option_support_cache_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npu/state_tensor_binding_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/npuw/llm_compiled_model_graph_options_test.cpp
diff --git a/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp b/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp
new file mode 100644
index 00000000000..0dec94d84c7
--- /dev/null
+++ b/src/plugins/intel_npu/tests/unit/npu/device_helpers_test.cpp
@@ -0,0 +1,150 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_npu/common/device_helpers.hpp"
+
+#include <gtest/gtest.h>
+
+#include <algorithm>
+#include <cctype>
+
+#include "intel_npu/npu_private_properties.hpp"
+#include "openvino/core/except.hpp"
+
+namespace {
+
+class MockDevice : public ::intel_npu::IDevice {
+public:
+ explicit MockDevice(std::string name) : _name(std::move(name)) {}
+
+ std::string getName() const override {
+ return _name;
+ }
+ std::string getFullDeviceName() const override {
+ return "Mock NPU " + _name;
+ }
+ std::shared_ptr<::intel_npu::InferRequest> createInferRequest(
+ const std::shared_ptr<const ::intel_npu::ICompiledModel>&,
+ const ::intel_npu::Config&) override {
+ return nullptr;
+ }
+ void updateInfo(const ov::AnyMap&) override {}
+ bool validateCompatibilityDescriptor(const std::string&) const override {
+ return true;
+ }
+ DeviceProperties getDeviceProperties() const override {
+ return {};
+ }
+
+private:
+ std::string _name;
+};
+
+// Mirrors ZeroEngineBackend::getDevice(name) lookup: empty -> first device, number -> index if in range, otherwise
+// name.
+class MockEngineBackend : public ::intel_npu::IEngineBackend {
+public:
+ explicit MockEngineBackend(std::vector<std::string> deviceNames) {
+ for (auto& name : deviceNames) {
+ _devices.push_back(std::make_shared<MockDevice>(std::move(name)));
+ }
+ }
+
+ const std::shared_ptr<::intel_npu::IDevice> getDevice() const override {
+ return _devices.empty() ? nullptr : _devices.front();
+ }
+ const std::shared_ptr<::intel_npu::IDevice> getDevice(const std::string& name) const override {
+ if (_devices.empty()) {
+ return nullptr;
+ }
+ if (name.empty()) {
+ return getDevice();
+ }
+ // A number is an index first, otherwise it is searched as an arch name (e.g. "5010")
+ if (std::all_of(name.begin(), name.end(), ::isdigit)) {
+ const auto index = static_cast<size_t>(std::stoul(name));
+ if (index < _devices.size()) {
+ return _devices[index];
+ }
+ }
+ for (const auto& device : _devices) {
+ if (device->getName() == name) {
+ return device;
+ }
+ }
+ OPENVINO_THROW("Could not find available NPU device with the specified name: NPU.", name);
+ }
+ const std::vector<std::string> getDeviceNames() const override {
+ std::vector<std::string> names;
+ for (const auto& device : _devices) {
+ names.push_back(device->getName());
+ }
+ return names;
+ }
+ const std::string getName() const override {
+ return "MOCK";
+ }
+ bool isCommandQueueExtSupported() const override {
+ return false;
+ }
+ bool isLUIDExtSupported() const override {
+ return false;
+ }
+ bool isContextExtSupported() const override {
+ return false;
+ }
+ void updateInfo(const ov::AnyMap&) override {}
+
+private:
+ std::vector<std::shared_ptr<MockDevice>> _devices;
+};
+
+ov::SoPtr<::intel_npu::IEngineBackend> makeBackend(std::vector<std::string> deviceNames) {
+ return ov::SoPtr<::intel_npu::IEngineBackend>(std::make_shared<MockEngineBackend>(std::move(deviceNames)));
+}
+
+const std::string NPU4000{ov::intel_npu::Platform::NPU4000};
+const std::string NPU5010{ov::intel_npu::Platform::NPU5010};
+
+using ::intel_npu::utils::getDeviceArchitecture;
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, ReturnsEmptyWithoutBackend) {
+ EXPECT_EQ(getDeviceArchitecture({nullptr}, ""), "");
+ EXPECT_EQ(getDeviceArchitecture({nullptr}, NPU4000), "");
+}
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, ReturnsEmptyWhenBackendHasNoDevices) {
+ const auto backend = makeBackend({});
+
+ EXPECT_NO_THROW(EXPECT_EQ(getDeviceArchitecture(backend, ""), ""));
+ EXPECT_NO_THROW(EXPECT_EQ(getDeviceArchitecture(backend, NPU4000), ""));
+}
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, EmptyDeviceIdUsesFirstDevice) {
+ const auto backend = makeBackend({NPU4000, NPU5010});
+
+ EXPECT_EQ(getDeviceArchitecture(backend, ""), NPU4000);
+}
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, DeviceIdAsNameReturnsMatchingDevice) {
+ const auto backend = makeBackend({NPU4000, NPU5010});
+
+ EXPECT_EQ(getDeviceArchitecture(backend, NPU5010), NPU5010);
+}
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, DeviceIdAsIndexReturnsDeviceNameNotIndex) {
+ const auto backend = makeBackend({NPU4000, NPU5010});
+
+ EXPECT_EQ(getDeviceArchitecture(backend, "0"), NPU4000);
+ EXPECT_EQ(getDeviceArchitecture(backend, "1"), NPU5010);
+}
+
+TEST(DeviceHelpersGetDeviceArchitectureTests, ReturnsEmptyForUnknownDevice) {
+ const auto backend = makeBackend({NPU4000});
+
+ EXPECT_NO_THROW(EXPECT_EQ(getDeviceArchitecture(backend, "UNKNOWN"), ""));
+ EXPECT_NO_THROW(EXPECT_EQ(getDeviceArchitecture(backend, "7"), ""));
+}
+
+} // namespace