Skip to content

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

[`NPU`][`ZeroInferRequest`][`set_tensor`] Provide precision hint for allocation of `ZeroTensor` (#34264)

Mircea-Aurelian Dandfbb82a45900
diff --git a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
index 76b2b2908be..e6990ef369e 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_infer_request.hpp
@@ -58,13 +58,12 @@ protected:
* @brief Allocates a tensor on host and stores the reference inside multiple attributes.
* @param index The index which the allocated tensor shall use.
* @param isInput Determines the containers in which the newly allocated tensors will be stored.
- * @param allocator If provided, the tensor uses the custom allocator instead of using the default one.
- * @param batchSize If provided, the value of the shape on the 0th axis is overriden with this value.
+ * @param batchSize If provided, the value of the shape on the 0th axis is overridden with this value.
* @return Pointer towards the allocated tensor
*/
std::shared_ptr<ZeroTensor> allocate_tensor(const size_t index,
const bool isInput,
- const std::optional<std::size_t> batchSize = std::nullopt) const;
+ const std::optional<std::size_t>& batchSize = std::nullopt) const;
void add_state(const IODescriptor& descriptor, size_t tensorIndex) const;
diff --git a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
index e60646ac458..7d12c15f716 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_infer_request.cpp
@@ -140,8 +140,10 @@ void ZeroInferRequest::create_pipeline() {
_logger.debug("ZeroInferRequest::create_pipeline - tensors %s were already allocated",
_metadata.inputs.at(inputIndex).nodeFriendlyName.c_str());
} else {
- get_level_zero_input(inputIndex) =
- allocate_tensor(inputIndex, INPUT, get_user_inputs(inputIndex).size());
+ if (get_level_zero_input(inputIndex) == nullptr) {
+ get_level_zero_input(inputIndex) =
+ allocate_tensor(inputIndex, INPUT, get_user_inputs(inputIndex).size());
+ }
}
continue;
}
@@ -344,15 +346,23 @@ void ZeroInferRequest::set_tensor(const ov::Output<const ov::Node>& port, const
void ZeroInferRequest::update_command_list_for_tensor(SyncInferRequest::FoundPort& foundPort,
const ov::SoPtr<ov::ITensor>& tensor) {
OV_ITT_TASK_CHAIN(ZERO_SET_TENSOR, itt::domains::LevelZeroBackend, "set_tensor", "update_command_list_for_tensor");
- if (_initStructs->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0)) {
- auto& levelZeroTensor =
- foundPort.is_input() ? get_level_zero_input(foundPort.idx) : _levelZeroOutputTensors.at(foundPort.idx);
+ const bool isMutableCommandListSupported = _initStructs->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0);
+ auto& levelZeroTensor =
+ foundPort.is_input() ? get_level_zero_input(foundPort.idx) : _levelZeroOutputTensors.at(foundPort.idx);
+ if (isMutableCommandListSupported || levelZeroTensor == nullptr) {
bool updateCommandListArg = false;
try {
_logger.debug("ZeroInferRequest::set_tensor - create zero tensor");
OV_ITT_TASK_NEXT(ZERO_SET_TENSOR, "create zero tensor");
+
+ if (!isMutableCommandListSupported) {
+ // Forbid memory import when tensor reallocation is not supported
+ // Copies into level zero tensor will cause altering the initial user tensor
+ throw ZeroMemException{"Importing standard allocation is forbidden with this driver version"};
+ }
+
// Try to use the user tensor directly if its underlying data is already allocated in the same Level Zero
// context.
levelZeroTensor = std::make_shared<ZeroTensor>(_initStructs, tensor);
@@ -377,7 +387,7 @@ void ZeroInferRequest::update_command_list_for_tensor(SyncInferRequest::FoundPor
}
}
- if (_pipelineIsCreated && updateCommandListArg && !_dynamicBatchValueChanged) {
+ if (isMutableCommandListSupported && _pipelineIsCreated && updateCommandListArg && !_dynamicBatchValueChanged) {
_logger.debug("ZeroInferRequest::infer_async - update command list");
OPENVINO_ASSERT(levelZeroTensor->data(), "Empty buffer");
@@ -389,6 +399,13 @@ void ZeroInferRequest::update_command_list_for_tensor(SyncInferRequest::FoundPor
levelZeroTensor);
}
}
+
+ OPENVINO_ASSERT(levelZeroTensor, "Zero tensor is not allocated.");
+ // corner case for boolean inputs as compiler maps them to u8
+ const auto& userTensorElementType = tensor->get_element_type();
+ if (userTensorElementType == ov::element::boolean && levelZeroTensor->get_element_type() == ov::element::u8) {
+ levelZeroTensor->set_element_type(userTensorElementType);
+ }
// If command list updates are not supported, fallback to copying tensors every time.
}
@@ -448,55 +465,71 @@ void ZeroInferRequest::update_command_list_for_tensors(SyncInferRequest::FoundPo
itt::domains::LevelZeroBackend,
"set_tensors",
"update_command_list_for_tensors");
- if (_initStructs->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0)) {
- if (batchSizeCandidate.has_value()) {
- get_level_zero_inputs(foundPort.idx).resize(tensors.size());
-
- for (size_t i = 0; i < tensors.size(); i++) {
- try {
- _logger.debug("ZeroInferRequest::set_tensors - create zero tensor");
- OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "create zero tensor");
- get_level_zero_input(foundPort.idx, i) = std::make_shared<ZeroTensor>(_initStructs, tensors.at(i));
- } catch (const ZeroMemException& exception) {
- _logger.debug(
- "ZeroInferRequest::set_tensors - exception caught while trying to create a Level Zero tensor "
- "from the user tensor: %s",
- exception.what());
-
- _logger.debug("ZeroInferRequest::set_tensors - allocate locally L0 tensor");
- OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "allocate tensor");
- get_level_zero_input(foundPort.idx, i) = allocate_tensor(foundPort.idx, INPUT, batchSizeCandidate);
- }
- if (_pipelineIsCreated && !_dynamicBatchValueChanged) {
- OPENVINO_ASSERT(get_level_zero_input(foundPort.idx, i)->data(), "Empty buffer");
- OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "updateCommandList");
- _pipeline->update_graph_arguments(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
- get_level_zero_input(foundPort.idx, i),
- i);
- }
- }
- } else {
- auto& levelZeroTensor = get_level_zero_input(foundPort.idx);
- // Check if the current Level Zero tensor was previously shared with the user. If so, it cannot be reused;
- // allocate a new tensor to back up the user tensor (which cannot be imported or used directly).
- if (levelZeroTensor == nullptr || !levelZeroTensor->can_be_reused()) {
+ const bool isMutableCommandListSupported = _initStructs->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0);
+ if (isMutableCommandListSupported && batchSizeCandidate.has_value()) {
+ get_level_zero_inputs(foundPort.idx).resize(tensors.size());
+
+ for (size_t i = 0; i < tensors.size(); i++) {
+ try {
+ _logger.debug("ZeroInferRequest::set_tensors - create zero tensor");
+ OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "create zero tensor");
+ get_level_zero_input(foundPort.idx, i) = std::make_shared<ZeroTensor>(_initStructs, tensors.at(i));
+ } catch (const ZeroMemException& exception) {
+ _logger.debug(
+ "ZeroInferRequest::set_tensors - exception caught while trying to create a Level Zero tensor "
+ "from the user tensor: %s",
+ exception.what());
+
_logger.debug("ZeroInferRequest::set_tensors - allocate locally L0 tensor");
OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "allocate tensor");
+ get_level_zero_input(foundPort.idx, i) = allocate_tensor(foundPort.idx, INPUT, batchSizeCandidate);
+ }
- levelZeroTensor = allocate_tensor(foundPort.idx, INPUT);
+ if (_pipelineIsCreated && !_dynamicBatchValueChanged) {
+ OPENVINO_ASSERT(get_level_zero_input(foundPort.idx, i)->data(), "Empty buffer");
+ OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "updateCommandList");
+ _pipeline->update_graph_arguments(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
+ get_level_zero_input(foundPort.idx, i),
+ i);
+ }
- if (_pipelineIsCreated && !_dynamicBatchValueChanged) {
- OPENVINO_ASSERT(levelZeroTensor->data(), "Empty buffer");
- OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "updateCommandList");
- _pipeline->update_graph_arguments(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
- levelZeroTensor);
- }
- } else {
- _logger.debug("ZeroInferRequest::set_tensors - reusing the level zero tensor since it is not shared "
- "with the user");
+ auto& levelZeroTensor = get_level_zero_input(foundPort.idx, i);
+ OPENVINO_ASSERT(levelZeroTensor, "Zero tensor is not allocated.");
+ // corner case for boolean inputs as compiler maps them to u8
+ const auto& userTensorElementType = tensors.at(i)->get_element_type();
+ if (userTensorElementType == ov::element::boolean &&
+ levelZeroTensor->get_element_type() == ov::element::u8) {
+ levelZeroTensor->set_element_type(userTensorElementType);
}
}
+ } else {
+ auto& levelZeroTensor = get_level_zero_input(foundPort.idx);
+ // Check if the current Level Zero tensor was previously shared with the user. If so, it cannot be reused;
+ // allocate a new tensor to back up the user tensor (which cannot be imported or used directly).
+ if (levelZeroTensor == nullptr || !levelZeroTensor->can_be_reused()) {
+ _logger.debug("ZeroInferRequest::set_tensors - allocate locally L0 tensor");
+ OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "allocate tensor");
+
+ levelZeroTensor = allocate_tensor(foundPort.idx, INPUT, tensors.size());
+
+ if (isMutableCommandListSupported && _pipelineIsCreated && !_dynamicBatchValueChanged) {
+ OPENVINO_ASSERT(levelZeroTensor->data(), "Empty buffer");
+ OV_ITT_TASK_NEXT(ZERO_SET_TENSORS, "updateCommandList");
+ _pipeline->update_graph_arguments(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
+ levelZeroTensor);
+ }
+ } else {
+ _logger.debug("ZeroInferRequest::set_tensors - reusing the level zero tensor since it is not shared "
+ "with the user");
+ }
+
+ OPENVINO_ASSERT(levelZeroTensor, "Zero tensor is not allocated.");
+ // corner case for boolean inputs as compiler maps them to u8
+ const auto& userTensorElementType = tensors.at(SINGLE_TENSOR)->get_element_type();
+ if (userTensorElementType == ov::element::boolean && levelZeroTensor->get_element_type() == ov::element::u8) {
+ levelZeroTensor->set_element_type(userTensorElementType);
+ }
}
// If command list updates are not supported, fallback to copying tensors every time.
}
@@ -569,7 +602,7 @@ ov::SoPtr<ov::ITensor> ZeroInferRequest::get_tensor(const ov::Output<const ov::N
std::shared_ptr<ZeroTensor> ZeroInferRequest::allocate_tensor(const size_t index,
const bool isInput,
- const std::optional<std::size_t> batchSize) const {
+ const std::optional<std::size_t>& batchSize) const {
const auto& descriptor = isInput ? _metadata.inputs.at(index) : _metadata.outputs.at(index);
check_network_precision(descriptor.precision);
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_tensor.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_tensor.hpp
index 90255973553..cfae57fdc3f 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_tensor.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_tensor.hpp
@@ -41,8 +41,7 @@ public:
* @param init_structs Shared pointer to ZeroInitStructsHolder
* @param user_tensor Tensor to create ZeroTensor from
*/
- ZeroTensor(const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
- const ov::SoPtr<ov::ITensor>& user_tensor);
+ ZeroTensor(const std::shared_ptr<ZeroInitStructsHolder>& init_structs, const ov::SoPtr<ov::ITensor>& user_tensor);
void* data() override;
void* data(const ov::element::Type& type) override;
@@ -55,6 +54,16 @@ public:
const ov::element::Type& get_element_type() const override;
+ /**
+ * @brief Special-purpose override for the tensor element type.
+ *
+ * This API is intended only for the narrow boolean/u8 handling case used by
+ * the Zero inference pipeline. It must not be used as a general-purpose
+ * element type mutator. The implementation asserts that only the supported
+ * conversion(s) are requested and may fail if used with other element types.
+ */
+ void set_element_type(const ov::element::Type& element_type);
+
const ov::Shape& get_shape() const override;
void set_shape(ov::Shape new_shape) override;
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_tensor.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_tensor.cpp
index 1ae5f70c545..4975c1bf091 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_tensor.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_tensor.cpp
@@ -139,6 +139,12 @@ const ov::element::Type& ZeroTensor::get_element_type() const {
return _element_type;
}
+void ZeroTensor::set_element_type(const ov::element::Type& element_type) {
+ OPENVINO_ASSERT(element_type == ov::element::boolean && _element_type == ov::element::u8,
+ "set_element_type should be used only for special case of boolean and u8 types!");
+ _element_type = element_type;
+}
+
const ov::Shape& ZeroTensor::get_shape() const {
return _shape;
}
diff --git a/src/plugins/intel_npu/tests/functional/CMakeLists.txt b/src/plugins/intel_npu/tests/functional/CMakeLists.txt
index 330b88d4012..5351164113c 100644
--- a/src/plugins/intel_npu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_npu/tests/functional/CMakeLists.txt
@@ -42,7 +42,11 @@ ov_add_test_target(
"${CMAKE_CURRENT_SOURCE_DIR}/behavior"
"${CMAKE_CURRENT_SOURCE_DIR}/internal"
OBJECT_FILES
+ "${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/async_infer_request.cpp"
+ "${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp"
+ "${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/metadata.cpp"
"${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/remote_context.cpp"
+ "${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/transformations.cpp"
"${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/properties.cpp"
"${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/src/metrics.cpp"
LINK_LIBRARIES
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
index a65b1afbd33..51b29330c9b 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp
@@ -12,6 +12,15 @@ using namespace ov::test::behavior;
namespace {
const std::vector<ov::AnyMap> configsInferRequestRunTests = {{}};
+const std::vector<ov::AnyMap> configsBooleanPrecisionInferRequestRunTests = {
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}}};
INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,
InferRequestRunTests,
@@ -19,6 +28,15 @@ INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,
::testing::ValuesIn(configsInferRequestRunTests)),
InferRequestRunTests::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(compatibility_smoke_BehaviorTest,
+ BooleanPrecisionInferRequestRunTests,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(configsBooleanPrecisionInferRequestRunTests),
+ ::testing::ValuesIn(std::vector<bool>{true, false}), // with warmup infer
+ ::testing::ValuesIn(std::vector<bool>{true,
+ false})), // with reset infer request
+ ov::test::utils::appendPlatformTypeTestName<BooleanPrecisionInferRequestRunTests>);
+
const std::vector<ov::AnyMap> profilingConfigs{{ov::intel_npu::profiling_type(ov::intel_npu::ProfilingType::MODEL)},
{ov::intel_npu::profiling_type(ov::intel_npu::ProfilingType::INFER)}};
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp
index 27126ce1e1d..3c4d5053795 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp
@@ -17,6 +17,7 @@
#include "behavior/ov_infer_request/inference.hpp"
#include "common/npu_test_env_cfg.hpp"
#include "common/utils.hpp"
+#include "common_test_utils/ov_tensor_utils.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "intel_npu/utils/zero/zero_types.hpp"
@@ -142,6 +143,68 @@ public:
}
};
+using BooleanPrecisionCompilationParams = std::tuple<std::string, // Device name
+ ov::AnyMap, // Config
+ bool, // With warmup infer()
+ bool>; // With reset Infer Request
+
+class BooleanPrecisionInferRequestRunTests : public ov::test::behavior::OVPluginTestBase,
+ public testing::WithParamInterface<BooleanPrecisionCompilationParams> {
+protected:
+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();
+ ov::AnyMap configuration;
+ std::shared_ptr<ov::Model> ov_model;
+ bool withWarmUpInfer = false;
+ bool withResetInferRequest = false;
+
+ std::shared_ptr<ov::Model> createTwoInputLessEqualModel(const PartialShape& shape = {2, 16, 16, 16}) {
+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);
+ param0->get_output_tensor(0).set_names({"tensor_input_0"});
+ param0->set_layout("N...");
+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);
+ param1->get_output_tensor(0).set_names({"tensor_input_1"});
+ param1->set_layout("N...");
+ auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);
+ auto result = std::make_shared<ov::op::v0::Result>(lessEqual);
+ result->get_output_tensor(0).set_names({"tensor_output"});
+
+ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});
+ model->set_friendly_name("TwoInputLessEqual");
+ return model;
+ }
+
+ std::shared_ptr<ov::Model> createTwoInputNonZeroAddModel(const PartialShape& shape = {2, 16, 16, 16}) {
+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);
+ param0->get_output_tensor(0).set_names({"tensor_input_0"});
+ param0->set_layout("N...");
+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);
+ param1->get_output_tensor(0).set_names({"tensor_input_1"});
+ param1->set_layout("N...");
+ auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);
+ auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);
+ // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input
+ // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf
+ auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);
+ auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);
+ auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);
+ auto result = std::make_shared<ov::op::v0::Result>(add);
+ result->get_output_tensor(0).set_names({"tensor_output"});
+
+ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});
+ model->set_friendly_name("TwoTwoInputNonZeroAddModel");
+ return model;
+ }
+
+public:
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+
+ std::tie(target_device, configuration, withWarmUpInfer, withResetInferRequest) = this->GetParam();
+ OVPluginTestBase::SetUp();
+ ov_model = createTwoInputNonZeroAddModel();
+ }
+};
+
TEST_P(InferRequestRunTests, AllocatorCanDisposeBlobWhenOnlyInferRequestIsInScope) {
SKIP_IF_CURRENT_TEST_IS_DISABLED() {
ov::InferRequest req;
@@ -207,6 +270,119 @@ TEST_P(InferRequestRunTests, MultipleExecutorStreamsTestsAsyncInfers) {
}
}
+TEST_P(BooleanPrecisionInferRequestRunTests, BooleanTensorDataTypesForBooleanModelsWork) {
+ // TODO: Also test createTwoInputLessEqualModel model when we have compiler support
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ ov::CompiledModel compiled_model_boolean, compiled_model_boolean_imported;
+ std::shared_ptr<ov::InferRequest> infer_request_boolean, infer_request_boolean_imported;
+
+ try {
+ (void)core->get_property(target_device, ov::intel_npu::batch_mode);
+ } catch (...) {
+ configuration.erase(ov::intel_npu::batch_mode.name());
+ }
+
+ bool isPVDriver = (core->get_property(target_device, ov::intel_npu::driver_version) == 1688);
+
+ bool isDriverCompiler =
+ (configuration.find(ov::intel_npu::compiler_type.name()) != configuration.end() &&
+ configuration.find(ov::intel_npu::compiler_type.name())->second.as<ov::intel_npu::CompilerType>() ==
+ ov::intel_npu::CompilerType::DRIVER);
+ if (isPVDriver && isDriverCompiler) {
+ GTEST_SKIP() << "CID from PV driver cannot compile models with boolean inputs!";
+ }
+
+ OV_ASSERT_NO_THROW(compiled_model_boolean = core->compile_model(ov_model, target_device, configuration));
+ OPENVINO_ASSERT(compiled_model_boolean.input(0).get_element_type() == ov::element::boolean);
+ OPENVINO_ASSERT(compiled_model_boolean.input(1).get_element_type() == ov::element::boolean);
+
+ if (!isPVDriver) {
+ std::stringstream ss;
+ compiled_model_boolean.export_model(ss);
+ OV_ASSERT_NO_THROW(compiled_model_boolean_imported = core->import_model(ss, target_device, configuration));
+ infer_request_boolean_imported =
+ std::make_shared<ov::InferRequest>(compiled_model_boolean_imported.create_infer_request());
+ }
+ infer_request_boolean = std::make_shared<ov::InferRequest>(compiled_model_boolean.create_infer_request());
+
+ const auto infer_requests =
+ (isPVDriver
+ ? std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean}
+ : std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean, infer_request_boolean_imported});
+
+ auto [importMemoryBatchedTensor,
+ importMemoryTensor_1,
+ importMemoryTensor_2,
+ unalignedBatchedTensor,
+ unalignedTensor_1,
+ unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);
+
+ ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());
+ ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());
+ importMemoryBatchedTensor.copy_to(ref_import_tensor);
+ unalignedBatchedTensor.copy_to(ref_tensor_unaligned);
+
+ for (auto infer_request : infer_requests) {
+ auto reset_infer_request_cb = [&infer_request]() {
+ auto compiled_model = infer_request->get_compiled_model();
+ infer_request = std::make_shared<ov::InferRequest>(compiled_model.create_infer_request());
+ };
+
+ if (withWarmUpInfer) {
+ infer_request->infer();
+ }
+
+ const auto& compiled_model = infer_request->get_compiled_model();
+
+ OV_ASSERT_NO_THROW(
+ ov::test::utils::set_tensors_and_infer(infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiled_model.input(0),
+ std::vector<ov::Tensor>{importMemoryTensor_1, unalignedTensor_2},
+ reset_infer_request_cb));
+ OV_ASSERT_NO_THROW(
+ ov::test::utils::set_tensors_and_infer(infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiled_model.input(1),
+ std::vector<ov::Tensor>{importMemoryTensor_2, unalignedTensor_1},
+ reset_infer_request_cb));
+
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiled_model.input(0),
+ importMemoryBatchedTensor,
+ reset_infer_request_cb));
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiled_model.input(1),
+ unalignedBatchedTensor,
+ reset_infer_request_cb));
+
+ OV_ASSERT_NO_THROW(
+ ov::test::utils::set_tensors_and_infer(infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiled_model.input(0),
+ std::vector<ov::Tensor>{unalignedTensor_1, importMemoryTensor_1},
+ reset_infer_request_cb));
+ OV_ASSERT_NO_THROW(
+ ov::test::utils::set_tensors_and_infer(infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiled_model.input(1),
+ std::vector<ov::Tensor>{unalignedTensor_2, importMemoryTensor_2},
+ reset_infer_request_cb));
+ } // for infer_request
+
+ // ensure user tensors don't get altered during tests
+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));
+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));
+}
+
using ProfilingBlob = InferRequestRunTests;
TEST_P(ProfilingBlob, NoProfilingCompileProfilingImport) {
diff --git a/src/plugins/intel_npu/tests/functional/common/utils.cpp b/src/plugins/intel_npu/tests/functional/common/utils.cpp
index b80961ec80b..ee903aba7f6 100644
--- a/src/plugins/intel_npu/tests/functional/common/utils.cpp
+++ b/src/plugins/intel_npu/tests/functional/common/utils.cpp
@@ -6,11 +6,14 @@
#include <string>
+#include "common_test_utils/data_utils.hpp"
#include "intel_npu/npu_private_properties.hpp"
+#include "intel_npu/utils/utils.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/multiply.hpp"
#include "openvino/op/op.hpp"
#include "openvino/op/sigmoid.hpp"
+#include "openvino/runtime/make_tensor.hpp"
std::string getBackendName(const ov::Core& core) {
return core.get_property("NPU", ov::intel_npu::backend_name.name()).as<std::string>();
@@ -132,3 +135,44 @@ std::shared_ptr<ov::Model> createModelWithStates(ov::element::Type type, const o
auto function = std::make_shared<ov::Model>(ov::OutputVector{sigm}, ov::ParameterVector{input}, "add_output");
return function;
}
+namespace ov {
+
+namespace test {
+
+namespace utils {
+
+std::tuple<ov::Tensor, ov::Tensor, ov::Tensor, ov::Tensor, ov::Tensor, ov::Tensor> allocate_tensors(
+ const std::shared_ptr<ov::Model>& model,
+ const ov::element::Type& element_type) {
+ auto model_shape = model->get_parameters()[0]->get_shape();
+ ov::Coordinate start_coordinate{model_shape};
+ ov::Coordinate stop_coordinate{model_shape};
+ start_coordinate[0] = 1;
+ stop_coordinate[0] = 2;
+
+ ov::Allocator alignedAllocator{::intel_npu::utils::AlignedAllocator{::intel_npu::utils::STANDARD_PAGE_SIZE}};
+ ov::Tensor importMemoryBatchedTensor(element_type, model_shape, alignedAllocator);
+ ov::Tensor importMemoryTensor_1(importMemoryBatchedTensor, ov::Coordinate{0, 0, 0, 0}, start_coordinate);
+ ov::Tensor importMemoryTensor_2(importMemoryBatchedTensor, ov::Coordinate{1, 0, 0, 0}, stop_coordinate);
+
+ ov::Allocator unAlignedAllocator{DefaultAllocatorNotAligned{}};
+ ov::Tensor unalignedBatchedTensor(element_type, model_shape, unAlignedAllocator);
+ ov::Tensor unalignedTensor_1(unalignedBatchedTensor, ov::Coordinate{0, 0, 0, 0}, start_coordinate);
+ ov::Tensor unalignedTensor_2(unalignedBatchedTensor, ov::Coordinate{1, 0, 0, 0}, stop_coordinate);
+
+ ov::test::utils::fill_tensor_random(importMemoryBatchedTensor);
+ ov::test::utils::fill_tensor_random(unalignedBatchedTensor);
+
+ return {importMemoryBatchedTensor,
+ importMemoryTensor_1,
+ importMemoryTensor_2,
+ unalignedBatchedTensor,
+ unalignedTensor_1,
+ unalignedTensor_2};
+};
+
+} // namespace utils
+
+} // namespace test
+
+} // namespace ov
diff --git a/src/plugins/intel_npu/tests/functional/common/utils.hpp b/src/plugins/intel_npu/tests/functional/common/utils.hpp
index 64d16ae3134..5199d41f11e 100644
--- a/src/plugins/intel_npu/tests/functional/common/utils.hpp
+++ b/src/plugins/intel_npu/tests/functional/common/utils.hpp
@@ -142,6 +142,48 @@ private:
size_t _offset = 16;
};
+std::tuple</* importMemoryBatched */ ov::Tensor,
+ /* importMemoryTensor_1 */ ov::Tensor,
+ /* importMemoryTensor_2 */ ov::Tensor,
+ /* unalignedBatchedTensor */ ov::Tensor,
+ /* unalignedTensor_1 */ ov::Tensor,
+ /* unalignedTensor_2 */ ov::Tensor>
+allocate_tensors(const std::shared_ptr<ov::Model>& model, const ov::element::Type& element_type);
+
+template <typename T, typename U>
+void set_tensor_and_infer(const std::shared_ptr<T>& infer_request,
+ const bool should_infer,
+ const bool withResetInferRequest,
+ const ov::Output<const ov::Node>& port,
+ const U& tensor,
+ const std::function<void(void)>& reset_cb) {
+ infer_request->set_tensor(port, tensor);
+ if (should_infer) {
+ infer_request->infer();
+ }
+
+ if (withResetInferRequest) {
+ reset_cb();
+ }
+};
+
+template <typename T, typename U>
+void set_tensors_and_infer(const std::shared_ptr<T>& infer_request,
+ const bool should_infer,
+ const bool withResetInferRequest,
+ const ov::Output<const ov::Node>& port,
+ const std::vector<U>& tensors,
+ const std::function<void(void)>& reset_cb) {
+ infer_request->set_tensors(port, tensors);
+ if (should_infer) {
+ infer_request->infer();
+ }
+
+ if (withResetInferRequest) {
+ reset_cb();
+ }
+};
+
} // namespace utils
} // namespace test
diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
new file mode 100644
index 00000000000..7de01aa89d2
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "internal/backend/zero_infer_request_tests.hpp"
+
+using namespace ov::test::behavior;
+
+const std::vector<ov::AnyMap> configs = {{{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}}};
+const std::vector<ov::element::Type> specialTensorDataTypes = {ov::element::boolean};
+
+INSTANTIATE_TEST_SUITE_P(
+ smoke_BehaviorTest,
+ ZeroInferRequestTests,
+ ::testing::Combine(
+ ::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(configs),
+ ::testing::ValuesIn(specialTensorDataTypes),
+ ::testing::ValuesIn(std::vector<bool>{true, false}), // with warmup infer
+ ::testing::ValuesIn(std::vector<bool>{true, false}), // with reset infer request
+ // Simulate PV driver having 1.5 graph extension version and no mutable command list extension version
+ ::testing::ValuesIn(std::vector<std::pair<uint32_t, uint32_t>>{
+ {ZE_GRAPH_EXT_VERSION_1_5, ZE_MAKE_VERSION(0, 0)},
+ {intel_npu::test_constants::TARGET_ZE_GRAPH_NPU_EXT_VERSION,
+ intel_npu::test_constants::TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION}})),
+ ZeroInferRequestTests::getTestCaseName);
diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp
new file mode 100644
index 00000000000..cd74c4f4025
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp
@@ -0,0 +1,339 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <gtest/gtest.h>
+
+#include "../compiler_adapter/zero_init_mock.hpp"
+#include "common/npu_test_env_cfg.hpp"
+#include "common/utils.hpp"
+#include "common_test_utils/file_utils.hpp"
+#include "common_test_utils/ov_plugin_cache.hpp"
+#include "common_test_utils/ov_tensor_utils.hpp"
+#include "compiled_model.hpp"
+#include "driver_compiler_adapter.hpp"
+#include "graph.hpp"
+#include "intel_npu/common/compiler_adapter_factory.hpp"
+#include "intel_npu/common/device_helpers.hpp"
+#include "intel_npu/config/config.hpp"
+#include "intel_npu/utils/utils.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/less_eq.hpp"
+#include "openvino/op/non_zero.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/openvino.hpp"
+#include "openvino/runtime/make_tensor.hpp"
+#include "plugin_compiler_adapter.hpp"
+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
+#include "transformations.hpp"
+#include "zero_backend.hpp"
+#include "zero_infer_request.hpp"
+
+namespace {
+[[maybe_unused]] std::shared_ptr<ov::Model> make_2_input_less_eq(const ov::Shape& input_shape = {2, 16, 16, 16}) {
+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);
+ param0->get_output_tensor(0).set_names({"tensor_input_0"});
+ param0->set_layout("N...");
+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);
+ param1->get_output_tensor(0).set_names({"tensor_input_1"});
+ param1->set_layout("N...");
+ auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);
+ auto result = std::make_shared<ov::op::v0::Result>(lessEqual);
+ result->get_output_tensor(0).set_names({"tensor_output"});
+
+ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});
+ model->set_friendly_name("TwoInputLessEqual");
+ return model;
+}
+
+std::shared_ptr<ov::Model> make_2_input_less_eq_non_zero(const ov::Shape& input_shape = {2, 16, 16, 16}) {
+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);
+ param0->get_output_tensor(0).set_names({"tensor_input_0"});
+ param0->set_layout("N...");
+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);
+ param1->get_output_tensor(0).set_names({"tensor_input_1"});
+ param1->set_layout("N...");
+ auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);
+ auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);
+ // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input
+ // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf
+ auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);
+ auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);
+ auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);
+ auto result = std::make_shared<ov::op::v0::Result>(add);
+ result->get_output_tensor(0).set_names({"tensor_output"});
+
+ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});
+ model->set_friendly_name("TwoTwoInputNonZeroAddModel");
+ return model;
+}
+
+} // namespace
+
+namespace ov {
+namespace test {
+namespace behavior {
+
+using CompilationParamsAndTensorDataType =
+ std::tuple<std::string, // Device name
+ ov::AnyMap, // Config
+ ov::element::Type, // Tensor data type
+ bool, // With warmup infer
+ bool, // With reset infer request
+ std::pair<uint32_t, uint32_t>>; // Graph Ext Version and Mutable Command List Version
+
+class ZeroInferRequestTests : public ov::test::behavior::OVPluginTestBase,
+ public testing::WithParamInterface<CompilationParamsAndTensorDataType> {
+protected:
+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();
+ ov::AnyMap configuration;
+ ov::element::Type element_type;
+ bool withWarmUpInfer;
+ bool withResetInferRequest;
+ uint32_t zeGraphNpuExtVersion;
+ uint32_t zeMutableCommandListExtVersion;
+ std::unique_ptr<::intel_npu::FilteredConfig> npu_config;
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zeroInitStruct;
+ std::shared_ptr<ov::Model> ov_model;
+
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndTensorDataType>& obj) {
+ std::string targetDevice;
+ ov::AnyMap configuration;
+ ov::element::Type type;
+ bool withWarmUpInfer;
+ bool withResetInferRequest;
+ std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;
+
+ std::tie(targetDevice,
+ configuration,
+ type,
+ withWarmUpInfer,
+ withResetInferRequest,
+ graphExtMutableCommandListExtPair) = obj.param;
+ auto [zeGraphNpuExtVersion, zeMutableCommandListExtVersion] = graphExtMutableCommandListExtPair;
+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');
+
+ std::ostringstream result;
+ result << "targetDevice=" << targetDevice << "_";
+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";
+ if (!configuration.empty()) {
+ for (auto& configItem : configuration) {
+ result << "configItem=" << configItem.first << "_";
+ configItem.second.print(result);
+ result << "_";
+ }
+ }
+ if (!type.get_type_name().empty()) {
+ result << "tensorDataType=" << type.get_type_name() << "_";
+ }
+
+ result << "withWarmUpInfer=" << withWarmUpInfer << "_" << "withResetInferRequest=" << withResetInferRequest
+ << "_";
+ result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." +
+ std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion))
+ << "_";
+ result << "zeMutableCommandListExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeMutableCommandListExtVersion)) +
+ "." + std::to_string(ZE_MINOR_VERSION(zeMutableCommandListExtVersion));
+
+ return result.str();
+ }
+
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+ std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;
+ std::tie(target_device,
+ configuration,
+ element_type,
+ withWarmUpInfer,
+ withResetInferRequest,
+ graphExtMutableCommandListExtPair) = this->GetParam();
+ zeGraphNpuExtVersion = graphExtMutableCommandListExtPair.first;
+ zeMutableCommandListExtVersion = graphExtMutableCommandListExtPair.second;
+
+ auto options = std::make_shared<::intel_npu::OptionsDesc>();
+ options->add<::intel_npu::PLATFORM>();
+ options->add<::intel_npu::COMPILER_TYPE>();
+ options->add<::intel_npu::BATCH_MODE>();
+ options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();
+ options->add<::intel_npu::ENABLE_CPU_PINNING>();
+ npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);
+ ::intel_npu::Config::ConfigMap configMap{
+ {::intel_npu::PLATFORM::key().data(),
+ ov::intel_npu::Platform::standardize(ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device))}};
+ npu_config->enable(::intel_npu::PLATFORM::key().data(), true);
+ npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), true);
+ npu_config->enable(::intel_npu::ENABLE_CPU_PINNING::key().data(), true);
+ for (const auto& [propertyName, propertyValue] : configuration) {
+ configMap[propertyName] = propertyValue.as<std::string>();
+ npu_config->enable(propertyName, true);
+ }
+ npu_config->update(configMap);
+
+ auto zeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>(
+ ::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,
+ zeGraphNpuExtVersion,
+ ::intel_npu::test_constants::TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION,
+ ::intel_npu::test_constants::TARGET_ZE_PROFILING_NPU_EXT_VERSION,
+ ::intel_npu::test_constants::TARGET_ZE_CONTEXT_NPU_EXT_VERSION,
+ zeMutableCommandListExtVersion);
+ zeroInitStruct = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zeroInitMock);
+
+ OVPluginTestBase::SetUp();
+ }
+
+ void TearDown() override {
+ if (!configuration.empty()) {
+ utils::PluginCache::get().reset();
+ }
+
+ APIBaseTest::TearDown();
+ }
+};
+
+} // namespace behavior
+} // namespace test
+} // namespace ov
+
+TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {
+ // TODO: Also test make_2_input_less_eq model when we have compiler support
+ ov_model = make_2_input_less_eq_non_zero();
+
+ // FIXME: OV needs to update ov::util::load_shared_object logic to check if certain module was already loaded in
+ // memory
+ // Force loading compiler lib via core flow to avoid missing library in the current path
+ core->set_property(target_device, ov::intel_npu::compiler_type(npu_config->get<::intel_npu::COMPILER_TYPE>()));
+ (void)core->get_property(target_device, ov::supported_properties);
+
+ auto zero_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();
+ auto device = intel_npu::utils::getDeviceById(zero_backend,
+ ov::test::utils::getDeviceNameID(ov::test::utils::getDeviceName()));
+
+ std::shared_ptr<::intel_npu::ICompilerAdapter> compiler;
+ try {
+ compiler = npu_config->get<::intel_npu::COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER
+ ? std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(
+ std::make_shared<::intel_npu::DriverCompilerAdapter>(zeroInitStruct))
+ : std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(
+ std::make_shared<::intel_npu::PluginCompilerAdapter>(zeroInitStruct));
+ } catch (...) {
+ GTEST_SKIP() << "Couldn't load compiler library";
+ }
+
+ // WA for error `[NPU_VCL] Unsupported IR API version! Val: 48.0`
+ if (compiler->is_option_supported(::intel_npu::MODEL_SERIALIZER_VERSION::key().data())) {
+ npu_config->update({{::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),
+ ::intel_npu::MODEL_SERIALIZER_VERSION::toString(
+ ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)}});
+ }
+
+ // logic for batch
+ auto copy_model = ov_model;
+ std::optional<int64_t> batch = std::nullopt;
+ if (npu_config->has<::intel_npu::BATCH_MODE>() &&
+ npu_config->get<::intel_npu::BATCH_MODE>() == ov::intel_npu::BatchMode::PLUGIN) {
+ std::optional<ov::Dimension> originalBatch = std::nullopt;
+ auto [batchedModel, successfullyDebatched] = intel_npu::batch_helpers::handlePluginBatching(
+ ov_model,
+ *npu_config,
+ [&](ov::intel_npu::BatchMode mode) {
+ npu_config->update({{::intel_npu::BATCH_MODE::key().data(), ::intel_npu::BATCH_MODE::toString(mode)}});
+ },
+ originalBatch,
+ ::intel_npu::Logger::global());
+ OPENVINO_ASSERT(successfullyDebatched, "Couldn't debatch test model!");
+ batch = originalBatch.value().get_length();
+ copy_model = batchedModel;
+ }
+
+ auto graph = compiler->compile(copy_model, *npu_config);
+ if (batch) {
+ graph->set_batch_size(batch.value());
+ }
+
+ auto compiledModel =
+ std::make_shared<intel_npu::CompiledModel>(ov_model,
+ std::make_shared<ov::test::utils::MockPlugin>(),
+ device,
+ graph,
+ *npu_config,
+ batch); // MockPlugin needed only to avoid throw for nullptr
+ OPENVINO_ASSERT(compiledModel->inputs()[0].get_element_type() == element_type);
+ OPENVINO_ASSERT(compiledModel->inputs()[1].get_element_type() == element_type);
+
+ auto zero_infer_request =
+ std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);
+ auto [importMemoryBatchedTensor,
+ importMemoryTensor_1,
+ importMemoryTensor_2,
+ unalignedBatchedTensor,
+ unalignedTensor_1,
+ unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);
+
+ ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());
+ ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());
+ importMemoryBatchedTensor.copy_to(ref_import_tensor);
+ unalignedBatchedTensor.copy_to(ref_tensor_unaligned);
+
+ auto reset_infer_cb = [this, &zero_infer_request, &compiledModel]() -> void {
+ zero_infer_request =
+ std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);
+ };
+
+ if (withWarmUpInfer) {
+ zero_infer_request->infer();
+ }
+
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(
+ zero_infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiledModel->inputs()[0],
+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_1),
+ ov::get_tensor_impl(unalignedTensor_2)},
+ reset_infer_cb));
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(
+ zero_infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiledModel->inputs()[1],
+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_2),
+ ov::get_tensor_impl(unalignedTensor_1)},
+ reset_infer_cb));
+
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiledModel->inputs()[0],
+ ov::get_tensor_impl(importMemoryBatchedTensor),
+ reset_infer_cb));
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiledModel->inputs()[1],
+ ov::get_tensor_impl(unalignedBatchedTensor),
+ reset_infer_cb));
+
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(
+ zero_infer_request,
+ /* should_infer = */ false,
+ withResetInferRequest,
+ compiledModel->inputs()[0],
+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_1),
+ ov::get_tensor_impl(importMemoryTensor_1)},
+ reset_infer_cb));
+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(
+ zero_infer_request,
+ /* should_infer = */ true,
+ withResetInferRequest,
+ compiledModel->inputs()[1],
+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_2),
+ ov::get_tensor_impl(importMemoryTensor_2)},
+ reset_infer_cb));
+
+ // ensure user tensors don't get altered during tests
+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));
+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));
+}
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
index bcbccc38028..a7e0814082c 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp
@@ -37,8 +37,8 @@ public:
static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndExtensionVersion>& obj) {
std::string targetDevice;
ov::AnyMap configuration;
- int graphExtVersion;
- std::tie(targetDevice, configuration, graphExtVersion) = obj.param;
+ uint32_t zeGraphNpuExtVersion;
+ std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = obj.param;
std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');
std::ostringstream result;
@@ -50,8 +50,8 @@ public:
configItem.second.print(result);
}
}
- result << "graphExtVersion=" + std::to_string(ZE_MAJOR_VERSION(graphExtVersion)) + "." +
- std::to_string(ZE_MINOR_VERSION(graphExtVersion));
+ result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." +
+ std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion));
return result.str();
}
@@ -80,12 +80,14 @@ protected:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED();
- std::tie(targetDevice, configuration, graphExtVersion) = this->GetParam();
+ std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = this->GetParam();
model = ov::test::utils::make_multi_single_conv();
blob = nullptr;
- std::shared_ptr<ZeroInitStructsMock> zeroInitMock = std::make_shared<ZeroInitStructsMock>(graphExtVersion);
+ std::shared_ptr<ZeroInitStructsMock> zeroInitMock =
+ std::make_shared<ZeroInitStructsMock>(::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,
+ zeGraphNpuExtVersion);
zeroInitStruct = std::reinterpret_pointer_cast<ZeroInitStructsHolder>(zeroInitMock);
zeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);
}
@@ -136,7 +138,7 @@ protected:
std::string targetDevice;
std::string blobPath;
- int graphExtVersion;
+ uint32_t zeGraphNpuExtVersion;
};
using ZeroGraphCompilationTests = ZeroGraphTest;
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.cpp
index 4852bc42785..0f628f380d8 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.cpp
@@ -13,13 +13,6 @@
namespace {
-constexpr uint32_t TARGET_ZE_DRIVER_NPU_EXT_VERSION = ZE_DRIVER_NPU_EXT_VERSION_1_0;
-constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION = ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_1;
-constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DATA_EXT_VERSION_1_0;
-constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
-constexpr uint32_t TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION = ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_1;
-constexpr uint32_t TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION = ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION_1_0;
-
constexpr ze_driver_uuid_t uuid = ze_intel_npu_driver_uuid;
std::tuple<uint32_t, std::string> queryDriverExtensionVersion(const char* extName,
@@ -95,7 +88,7 @@ void ZeroInitStructsMock::initNpuDriver() {
auto result = zelGetLoaderVersion(&version);
if (result == ZE_RESULT_SUCCESS) {
loader_version = version.component_lib_version;
- get_loader_version= true;
+ get_loader_version = true;
}
} catch (...) {
// Ignore exceptions - fallback to zeInit
@@ -121,9 +114,9 @@ void ZeroInitStructsMock::initNpuDriver() {
}
_log.debug("ZeroInitStructsHolder::initNpuDriver - ze_loader.dll version: %d.%d.%d",
- loader_version.major,
- loader_version.minor,
- loader_version.patch);
+ loader_version.major,
+ loader_version.minor,
+ loader_version.patch);
if (loader_version.major > 1 || (loader_version.major == 1 && loader_version.minor > 18) ||
(loader_version.major == 1 && loader_version.minor == 18 && loader_version.patch >= 5)) {
@@ -152,7 +145,13 @@ void ZeroInitStructsMock::initNpuDriver() {
fallbackToZeDriverGet();
}
-ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
+ZeroInitStructsMock::ZeroInitStructsMock(uint32_t zeDriverNpuExtVersion,
+ uint32_t zeGraphNpuExtVersion,
+ uint32_t zeCommandQueueNpuExtVersion,
+ uint32_t zeProfilingNpuExtVersion,
+ uint32_t zeContextNpuExtVersion,
+ uint32_t zeMutableCommandListExtVersion,
+ uint32_t zeExternalMemMapSysMemExtVersion)
: _zero_api(ZeroApi::getInstance()),
_log("NPUZeroInitStructsHolder", Logger::global().level()) {
_log.debug("ZeroInitStructsHolder - initialize NPU Driver");
@@ -195,7 +194,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
std::string driver_ext_name;
uint32_t driver_ext_version = 0;
std::tie(driver_ext_version, driver_ext_name) =
- queryDriverExtensionVersion(ZE_DRIVER_NPU_EXT_NAME, TARGET_ZE_DRIVER_NPU_EXT_VERSION, extProps, count);
+ queryDriverExtensionVersion(ZE_DRIVER_NPU_EXT_NAME, zeDriverNpuExtVersion, extProps, count);
_log.debug("NPU driver ext version %d.%d",
ZE_MAJOR_VERSION(driver_ext_version),
@@ -216,7 +215,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
// Query npu graph extension version
std::string graph_ext_name;
uint32_t graph_ext_version = 0;
- uint32_t target_graph_ext_version = extVersion;
+ uint32_t target_graph_ext_version = zeGraphNpuExtVersion;
_log.debug("Try to find graph ext version: %d.%d",
ZE_MAJOR_VERSION(target_graph_ext_version),
@@ -254,10 +253,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
std::string command_queue_ext_name;
uint32_t command_queue_ext_version = 0;
std::tie(command_queue_ext_version, command_queue_ext_name) =
- queryDriverExtensionVersion(ZE_COMMAND_QUEUE_NPU_EXT_NAME,
- TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION,
- extProps,
- count);
+ queryDriverExtensionVersion(ZE_COMMAND_QUEUE_NPU_EXT_NAME, zeCommandQueueNpuExtVersion, extProps, count);
_log.debug("NPU command queue version %d.%d",
ZE_MAJOR_VERSION(command_queue_ext_version),
@@ -278,10 +274,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
// Query the mutable command list version
[[maybe_unused]] std::string mutuable_command_list_ext_name;
std::tie(_mutable_command_list_ext_version, mutuable_command_list_ext_name) =
- queryDriverExtensionVersion(ZE_MUTABLE_COMMAND_LIST_EXP_NAME,
- TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION,
- extProps,
- count);
+ queryDriverExtensionVersion(ZE_MUTABLE_COMMAND_LIST_EXP_NAME, zeMutableCommandListExtVersion, extProps, count);
_log.debug("Mutable command list version %d.%d",
ZE_MAJOR_VERSION(_mutable_command_list_ext_version),
@@ -291,7 +284,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
std::string profiling_ext_name;
uint32_t profiling_ext_version = 0;
std::tie(profiling_ext_version, profiling_ext_name) =
- queryDriverExtensionVersion(ZE_PROFILING_DATA_EXT_NAME, TARGET_ZE_PROFILING_NPU_EXT_VERSION, extProps, count);
+ queryDriverExtensionVersion(ZE_PROFILING_DATA_EXT_NAME, zeProfilingNpuExtVersion, extProps, count);
// Load npu profiling extension
ze_graph_profiling_dditable_ext_t* graph_profiling_ddi_table_ext = nullptr;
@@ -306,7 +299,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
std::string context_ext_name;
uint32_t context_ext_version = 0;
std::tie(context_ext_version, context_ext_name) =
- queryDriverExtensionVersion(ZE_CONTEXT_NPU_EXT_NAME, TARGET_ZE_CONTEXT_NPU_EXT_VERSION, extProps, count);
+ queryDriverExtensionVersion(ZE_CONTEXT_NPU_EXT_NAME, zeContextNpuExtVersion, extProps, count);
_log.debug("NPU context version %d.%d",
ZE_MAJOR_VERSION(context_ext_version),
@@ -356,7 +349,7 @@ ZeroInitStructsMock::ZeroInitStructsMock(int extVersion)
uint32_t external_memory_mapping_ext_version = 0;
std::tie(external_memory_mapping_ext_version, std::ignore) =
queryDriverExtensionVersion(ZE_EXTERNAL_MEMORY_MAPPING_EXT_NAME,
- TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION,
+ zeExternalMemMapSysMemExtVersion,
extProps,
count);
diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.hpp
index 87f2b2be3c8..cef26bda2a7 100644
--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_init_mock.hpp
@@ -16,8 +16,25 @@
namespace intel_npu {
+namespace test_constants {
+inline constexpr uint32_t TARGET_ZE_DRIVER_NPU_EXT_VERSION = ZE_DRIVER_NPU_EXT_VERSION_1_0;
+inline constexpr uint32_t TARGET_ZE_GRAPH_NPU_EXT_VERSION = ZE_GRAPH_EXT_VERSION_1_16;
+inline constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION = ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_1;
+inline constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DATA_EXT_VERSION_1_0;
+inline constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
+inline constexpr uint32_t TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION = ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_1;
+inline constexpr uint32_t TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION = ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION_1_0;
+} // namespace test_constants
struct ZeroInitStructsMock {
- ZeroInitStructsMock(int extVersion);
+ ZeroInitStructsMock(
+ uint32_t zeDriverNpuExtVersion = intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,
+ uint32_t zeGraphNpuExtVersion = intel_npu::test_constants::TARGET_ZE_GRAPH_NPU_EXT_VERSION,
+ uint32_t zeCommandQueueNpuExtVersion = intel_npu::test_constants::TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION,
+ uint32_t zeProfilingNpuExtVersion = intel_npu::test_constants::TARGET_ZE_PROFILING_NPU_EXT_VERSION,
+ uint32_t zeContextNpuExtVersion = intel_npu::test_constants::TARGET_ZE_CONTEXT_NPU_EXT_VERSION,
+ uint32_t zeMutableCommandListExtVersion = intel_npu::test_constants::TARGET_ZE_MUTABLE_COMMAND_LIST_EXT_VERSION,
+ uint32_t zeExternalMemMapSysMemExtVersion =
+ intel_npu::test_constants::TARGET_ZE_EXTERNAL_MEMMAP_SYSMEM_EXT_VERSION);
~ZeroInitStructsMock();
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
index 0f63381f56f..2566dafd391 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
@@ -876,4 +876,15 @@ Example:
</filters>
</skip_config>
+ <skip_config>
+ <message>PV driver cannot create infer request for models with boolean inputs</message>
+ <enable_rules>
+ <backend>LEVEL0</backend>
+ <driver_version>1688</driver_version>
+ </enable_rules>
+ <filters>
+ <filter>.*BooleanPrecisionInferRequestRunTests.*</filter>
+ </filters>
+ </skip_config>
+
</skip_configs>