Skip to content

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

[NPU] Support for strided I/O tensors (#32634)

Bogdan Pereanu38d391354ad7
diff --git a/src/inference/include/openvino/runtime/intel_npu/properties.hpp b/src/inference/include/openvino/runtime/intel_npu/properties.hpp
index 2f6a5f31da1..c7707d8e628 100644
--- a/src/inference/include/openvino/runtime/intel_npu/properties.hpp
+++ b/src/inference/include/openvino/runtime/intel_npu/properties.hpp
@@ -110,6 +110,7 @@ static constexpr ov::Property<bool> turbo{"NPU_TURBO"};
* @brief [Only for NPU Compiler]
* Type: integer, default is -1
* Sets the number of npu tiles to compile the model for.
+ * @ingroup ov_runtime_npu_prop_cpp_api
*/
static constexpr ov::Property<int64_t> tiles{"NPU_TILES"};
@@ -118,6 +119,7 @@ static constexpr ov::Property<int64_t> tiles{"NPU_TILES"};
* Type: integer, default is -1
* Maximum number of tiles supported by the device we compile for. Can be set for offline compilation. If not set, it
* will be populated by driver.
+ * @ingroup ov_runtime_npu_prop_cpp_api
*/
static constexpr ov::Property<int64_t> max_tiles{"NPU_MAX_TILES"};
@@ -133,6 +135,7 @@ static constexpr ov::Property<bool> bypass_umd_caching{"NPU_BYPASS_UMD_CACHING"}
* @brief [Only for NPU Plugin]
* Type: boolean, default is false
* This option allows to delay loading the weights until inference is created
+ * @ingroup ov_runtime_npu_prop_cpp_api
*/
static constexpr ov::Property<bool> defer_weights_load{"NPU_DEFER_WEIGHTS_LOAD"};
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
index 266df15671e..a17fe93ac28 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
@@ -1475,4 +1475,18 @@ struct MODEL_SERIALIZER_VERSION final : OptionBase<MODEL_SERIALIZER_VERSION, ov:
}
};
+struct ENABLE_STRIDES_FOR final : OptionBase<ENABLE_STRIDES_FOR, std::string> {
+ static std::string_view key() {
+ return ov::intel_npu::enable_strides_for.name();
+ }
+
+ static std::string defaultValue() {
+ return {};
+ }
+
+ static OptionMode mode() {
+ return OptionMode::CompileTime;
+ }
+};
+
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
index 8c70f8dc510..3441af61a32 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/network_metadata.hpp
@@ -126,6 +126,14 @@ struct IODescriptor {
* outputs are assigned in the same vector and could have different indexing.
*/
uint32_t indexUsedByDriver;
+
+ /**
+ * @brief Indicates whether strided memory layout is supported for this tensor.
+ * @details When set to true, this tensor can use non-contiguous memory layout with custom strides,
+ * allowing for more flexible memory access patterns. Strided tensors enable efficient representation of sliced or
+ * transposed data without copying.
+ */
+ bool supportsStridedLayout = false;
};
struct NetworkMetadata final {
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
index 27693f7bd89..9c406540d25 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/npu_private_properties.hpp
@@ -510,5 +510,14 @@ static constexpr ov::Property<bool> import_raw_blob{"NPU_IMPORT_RAW_BLOB"};
*/
static constexpr ov::Property<bool> export_raw_blob{"NPU_EXPORT_RAW_BLOB"};
+/**
+ * @brief [Only for NPU Plugin]
+ * Type: std::string, default is empty
+ * Enables custom stride support for specified input/output tensors by name. This allows working with non-contiguous
+ * memory layouts without copying data. The plugin automatically maps these names to the appropriate input/output
+ * indices for the compiler.
+ */
+static constexpr ov::Property<std::string> enable_strides_for("NPU_ENABLE_STRIDES_FOR");
+
} // namespace intel_npu
} // namespace ov
diff --git a/src/plugins/intel_npu/src/al/src/config/config.cpp b/src/plugins/intel_npu/src/al/src/config/config.cpp
index 542edef1798..532b647cde6 100644
--- a/src/plugins/intel_npu/src/al/src/config/config.cpp
+++ b/src/plugins/intel_npu/src/al/src/config/config.cpp
@@ -50,7 +50,7 @@ int32_t OptionParser<int32_t>::parse(std::string_view val) {
try {
return std::stol(val.data());
} catch (...) {
- OPENVINO_THROW("Value '%s' is not a valid INT32 option", val.data());
+ OPENVINO_THROW("Value '", val.data(), "' is not a valid INT32 option");
}
}
@@ -58,7 +58,7 @@ uint32_t OptionParser<uint32_t>::parse(std::string_view val) {
try {
return std::stoul(val.data());
} catch (...) {
- OPENVINO_THROW("Value '%s' is not a valid UINT32 option", val.data());
+ OPENVINO_THROW("Value '", val.data(), "' is not a valid UINT32 option");
}
}
diff --git a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
index aaa30f19bf4..b4b436d5459 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_pipeline.hpp
@@ -29,8 +29,8 @@ public:
void pull();
void reset() const;
- void update_graph_arguments(uint32_t arg_index, const void* arg_data, size_t byte_size);
- void update_graph_arguments_batching(uint32_t arg_index, const void* arg_data, size_t batch_index);
+ void update_graph_arguments(uint32_t index, const std::shared_ptr<ZeroTensor>& tensor);
+ void update_graph_arguments(uint32_t index, const std::shared_ptr<ZeroTensor>& tensor, size_t batch_index);
std::vector<ov::ProfilingInfo> get_profiling_info() const;
diff --git a/src/plugins/intel_npu/src/backend/include/zero_tensor.hpp b/src/plugins/intel_npu/src/backend/include/zero_tensor.hpp
index 42f00062af3..ba030e02291 100644
--- a/src/plugins/intel_npu/src/backend/include/zero_tensor.hpp
+++ b/src/plugins/intel_npu/src/backend/include/zero_tensor.hpp
@@ -76,15 +76,16 @@ public:
private:
void update_strides() const;
- size_t get_capacity() const;
size_t get_bytes_capacity() const;
std::shared_ptr<ZeroInitStructsHolder> _init_structs;
Logger _logger;
+ ov::SoPtr<ov::ITensor> _user_tensor;
+
ov::element::Type _element_type;
ov::Shape _shape;
- ov::Shape _capacity;
+ size_t _bytes_capacity;
mutable ov::Strides _strides;
mutable std::once_flag _strides_once;
void* _ptr = nullptr;
@@ -92,8 +93,6 @@ private:
bool _is_input = false;
bool _can_be_reused = false;
- ov::SoPtr<ov::ITensor> _user_tensor;
-
std::shared_ptr<ZeroMem> _mem_ref;
};
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 0e8c872d9f1..b652d31639c 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
@@ -9,8 +9,10 @@
#include "intel_npu/prefix.hpp"
#include "intel_npu/utils/utils.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
+#include "intel_npu/utils/zero/zero_utils.hpp"
#include "openvino/op/util/op_types.hpp"
#include "openvino/runtime/intel_npu/remote_properties.hpp"
+#include "openvino/runtime/make_tensor.hpp"
#include "zero_variable_state.hpp"
using namespace intel_npu;
@@ -51,6 +53,25 @@ std::optional<size_t> determine_dynamic_batch_size(const IODescriptor& desc,
return tensor->get_shape()[intel_npu::utils::BATCH_AXIS];
}
+void* get_tensor_data_ptr(const std::shared_ptr<ov::ITensor>& tensor) {
+ if (auto userRemoteTensor = std::dynamic_pointer_cast<ov::IRemoteTensor>(tensor)) {
+ if (auto userZeroRemoteTensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(userRemoteTensor)) {
+ return userZeroRemoteTensor->get_original_memory();
+ } else {
+ std::optional<void*> memHandleObject =
+ zeroUtils::extract_object(userRemoteTensor->get_properties(), ov::intel_npu::mem_handle);
+ OPENVINO_ASSERT(memHandleObject.has_value(),
+ "Remote tensor does not have parameter with key ",
+ ov::intel_npu::mem_handle.name());
+ return static_cast<uint8_t*>(memHandleObject.value()) + ov::get_tensor_data_offset(*userRemoteTensor);
+ }
+ } else {
+ return tensor->data();
+ }
+
+ return nullptr;
+}
+
} // namespace
//------------------------------------------------------------------------------
@@ -246,7 +267,10 @@ void ZeroInferRequest::set_tensor(const ov::Output<const ov::Node>& port, const
auto foundPort = find_port(port);
OPENVINO_ASSERT(foundPort.found(), "Cannot find tensor for port ", port);
try {
- check_tensor(port, tensor);
+ check_tensor(port,
+ tensor,
+ foundPort.is_input() ? _metadata.inputs.at(foundPort.idx).supportsStridedLayout
+ : _metadata.outputs.at(foundPort.idx).supportsStridedLayout);
} catch (const ov::Exception& ex) {
OPENVINO_THROW("Failed to set tensor. ", ex.what());
}
@@ -368,8 +392,7 @@ void ZeroInferRequest::set_tensor(const ov::Output<const ov::Node>& port, const
_pipeline->update_graph_arguments(foundPort.is_input()
? _metadata.inputs.at(foundPort.idx).indexUsedByDriver
: _metadata.outputs.at(foundPort.idx).indexUsedByDriver,
- levelZeroTensor->data(),
- levelZeroTensor->get_byte_size());
+ levelZeroTensor);
}
}
// If command list updates are not supported, fallback to copying tensors every time.
@@ -389,7 +412,7 @@ void ZeroInferRequest::set_tensors(const ov::Output<const ov::Node>& port,
OPENVINO_THROW("set_input_tensors/set_tensors is not supported for output port.");
}
- check_batched_tensors(port, tensors);
+ check_batched_tensors(port, tensors, _metadata.inputs.at(foundPort.idx).supportsStridedLayout);
_logger.debug("ZeroInferRequest::set_tensors: %zu", tensors.size());
@@ -444,10 +467,9 @@ void ZeroInferRequest::set_tensors(const ov::Output<const ov::Node>& port,
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_batching(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
- get_level_zero_input(foundPort.idx, i)->data(),
- i);
+ _pipeline->update_graph_arguments(_metadata.inputs.at(foundPort.idx).indexUsedByDriver,
+ get_level_zero_input(foundPort.idx, i),
+ i);
}
}
}
@@ -567,10 +589,8 @@ void ZeroInferRequest::update_pipeline_if_memory_changed() {
_logger.debug("Update input graph descriptor with the new tensor");
OPENVINO_ASSERT(levelZeroTensor.at(SINGLE_TENSOR)->data(), "Empty buffer");
-
_pipeline->update_graph_arguments(_metadata.inputs.at(ioIndex).indexUsedByDriver,
- levelZeroTensor.at(SINGLE_TENSOR)->data(),
- levelZeroTensor.at(SINGLE_TENSOR)->get_byte_size());
+ levelZeroTensor.at(SINGLE_TENSOR));
if (!inputDescriptor.isStateInput) {
levelZeroTensor.at(SINGLE_TENSOR)->reset_memory_flag();
@@ -599,10 +619,7 @@ void ZeroInferRequest::update_pipeline_if_memory_changed() {
_logger.debug("Update output graph descriptor with the new tensor");
OPENVINO_ASSERT(levelZeroTensor->data(), "Empty buffer");
-
- _pipeline->update_graph_arguments(_metadata.outputs.at(ioIndex).indexUsedByDriver,
- levelZeroTensor->data(),
- levelZeroTensor->get_byte_size());
+ _pipeline->update_graph_arguments(_metadata.outputs.at(ioIndex).indexUsedByDriver, levelZeroTensor);
levelZeroTensor->reset_memory_flag();
}
@@ -632,13 +649,11 @@ void ZeroInferRequest::update_states_if_memory_changed() {
zeroState->clear_zero_state_update_pending();
_pipeline->update_graph_arguments(_metadata.inputs.at(zeroState->get_tensor_index()).indexUsedByDriver,
- get_level_zero_input(zeroState->get_tensor_index())->data(),
- get_level_zero_input(zeroState->get_tensor_index())->get_byte_size());
+ get_level_zero_input(zeroState->get_tensor_index()));
_pipeline->update_graph_arguments(
_metadata.outputs.at(zeroState->get_related_tensor_index()).indexUsedByDriver,
- _levelZeroOutputTensors.at(zeroState->get_related_tensor_index())->data(),
- _levelZeroOutputTensors.at(zeroState->get_related_tensor_index())->get_byte_size());
+ _levelZeroOutputTensors.at(zeroState->get_related_tensor_index()));
}
}
}
@@ -699,13 +714,9 @@ void ZeroInferRequest::infer_async() {
if (is_batched_input(inputIndex)) {
if (batch_size.has_value()) {
for (size_t i = 0; i < userTensor.size(); i++) {
+ void* userBuffer = get_tensor_data_ptr(userTensor.at(i)._ptr);
void* levelZeroBuffer = get_level_zero_input(inputIndex, i)->data();
- auto userBatchRemoteTensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(userTensor.at(i)._ptr);
-
- void* userBuffer = !userBatchRemoteTensor ? userTensor.at(i)->data()
- : userBatchRemoteTensor->get_original_memory();
-
if (userBuffer != levelZeroBuffer) {
if (userBuffer == nullptr || levelZeroBuffer == nullptr) {
OPENVINO_THROW("Empty buffer");
@@ -718,12 +729,10 @@ void ZeroInferRequest::infer_async() {
userTensor.at(i)->get_byte_size(),
get_level_zero_input(inputIndex, i)->get_byte_size());
OV_ITT_TASK_NEXT(ZERO_INFER, "memcpy");
- std::memcpy(levelZeroBuffer, userBuffer, userTensor.at(i)->get_byte_size());
+ userTensor.at(i)->copy_to(get_level_zero_input(inputIndex, i));
}
}
} else {
- void* levelZeroBuffer = get_level_zero_input(inputIndex)->data();
-
_logger.debug("Batched Tensors - Tensor by index: %zu is not allocated in the current Level Zero "
"context or must be "
"in a continued memory space, copy into L0 with size: %zu",
@@ -731,19 +740,14 @@ void ZeroInferRequest::infer_async() {
get_level_zero_input(inputIndex)->get_byte_size());
size_t copied_bytes_from_user = 0;
for (size_t i = 0; i < userTensor.size(); i++) {
- auto userBatchRemoteTensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(userTensor.at(i)._ptr);
-
- void* userBuffer = !userBatchRemoteTensor ? userTensor.at(i)->data()
- : userBatchRemoteTensor->get_original_memory();
+ auto viewTensor =
+ ov::make_tensor(get_level_zero_input(inputIndex)->get_element_type(),
+ get_level_zero_input(inputIndex)->get_shape(),
+ static_cast<unsigned char*>(get_level_zero_input(inputIndex)->data()) +
+ (i * userTensor.at(i)->get_byte_size()));
- std::memcpy(static_cast<unsigned char*>(levelZeroBuffer) + (i * userTensor.at(i)->get_byte_size()),
- userBuffer,
- userTensor.at(i)->get_byte_size());
+ userTensor.at(i)->copy_to(viewTensor);
copied_bytes_from_user += userTensor.at(i)->get_byte_size();
- _logger.debug("Batched Tensors - Tensor by index: %zu copied bytes: [%zu/%zu]",
- inputIndex,
- copied_bytes_from_user,
- get_level_zero_input(inputIndex)->get_byte_size());
}
OPENVINO_ASSERT(get_level_zero_input(inputIndex)->get_byte_size() == copied_bytes_from_user,
"Bytes copied must be equal");
@@ -758,9 +762,7 @@ void ZeroInferRequest::infer_async() {
continue;
}
- auto userRemoteTensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(userTensor.at(SINGLE_TENSOR)._ptr);
- void* userBuffer =
- !userRemoteTensor ? userTensor.at(SINGLE_TENSOR)->data() : userRemoteTensor->get_original_memory();
+ void* userBuffer = get_tensor_data_ptr(userTensor.at(SINGLE_TENSOR)._ptr);
void* levelZeroBuffer = get_level_zero_input(inputIndex)->data();
if (userBuffer == nullptr || levelZeroBuffer == nullptr) {
@@ -770,7 +772,7 @@ void ZeroInferRequest::infer_async() {
if (userBuffer != levelZeroBuffer) {
_logger.info("Tensor is not allocated in the current Level Zero context");
OV_ITT_TASK_NEXT(ZERO_INFER, "memcpy");
- std::memcpy(levelZeroBuffer, userBuffer, userTensor.at(SINGLE_TENSOR)->get_byte_size());
+ userTensor.at(SINGLE_TENSOR)->copy_to(get_level_zero_input(inputIndex));
}
++inputIndex;
@@ -804,8 +806,7 @@ void ZeroInferRequest::get_result() {
tensorToBeReshaped->set_shape(actualDims);
}
- auto userRemoteTensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(userTensor._ptr);
- void* userBuffer = !userRemoteTensor ? userTensor->data() : userRemoteTensor->get_original_memory();
+ void* userBuffer = get_tensor_data_ptr(userTensor._ptr);
void* levelZeroBuffer = _levelZeroOutputTensors.at(outputIndex)->data();
if (userBuffer == nullptr || levelZeroBuffer == nullptr) {
@@ -815,7 +816,7 @@ void ZeroInferRequest::get_result() {
if (userBuffer != levelZeroBuffer) {
_logger.info("Output tensor by index: %zu is not allocated in the current Level Zero context", outputIndex);
OV_ITT_TASK_NEXT(ZERO_RESULT, "memcpy");
- std::memcpy(userBuffer, levelZeroBuffer, userTensor->get_byte_size());
+ _levelZeroOutputTensors.at(outputIndex)->copy_to(userTensor._ptr);
}
++outputIndex;
diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
index 11fcb75d5e2..6491e30aa3d 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp
@@ -15,6 +15,28 @@
#include "intel_npu/utils/zero/zero_remote_tensor.hpp"
#include "intel_npu/utils/zero/zero_types.hpp"
+namespace {
+std::vector<size_t> get_strides(const std::vector<size_t>& strides_in_bytes, size_t element_size) {
+ std::vector<size_t> element_strides(strides_in_bytes.size());
+ std::transform(strides_in_bytes.rbegin(),
+ strides_in_bytes.rend(),
+ element_strides.begin(),
+ [element_size](size_t byte_stride) {
+ OPENVINO_ASSERT(byte_stride % element_size == 0,
+ "Stride ",
+ byte_stride,
+ " bytes is not aligned to element size ",
+ element_size,
+ " bytes. Strides must be multiples of element size.");
+
+ return byte_stride / element_size;
+ });
+
+ return element_strides;
+};
+
+} // namespace
+
namespace intel_npu {
Pipeline::Pipeline(const Config& config,
const std::shared_ptr<ZeroInitStructsHolder>& init_structs,
@@ -95,27 +117,49 @@ Pipeline::Pipeline(const Config& config,
if (input_tensors.at(io_index).size() > 1) {
_logger.debug("Pipeline - set args for input index: %zu", io_index);
-
- graph->set_argument_value(desc.indexUsedByDriver, input_tensors.at(io_index).at(i)->data());
-
+ const auto& tensor = input_tensors.at(io_index).at(i);
+
+ if (tensor->get_element_type().bitwidth() < 8 || tensor->is_continuous() ||
+ tensor->get_strides().empty()) {
+ _graph->set_argument_value(desc.indexUsedByDriver, tensor->data());
+ } else {
+ _graph->set_argument_value_with_strides(
+ desc.indexUsedByDriver,
+ tensor->data(),
+ get_strides(tensor->get_strides(), tensor->get_element_type().size()));
+ }
++io_index;
continue;
}
- graph->set_argument_value(
- desc.indexUsedByDriver,
- static_cast<unsigned char*>(input_tensors.at(io_index).at(0)->data()) +
- (i * input_tensors.at(io_index).at(0)->get_byte_size()) / _number_of_command_lists);
+ const auto& tensor = input_tensors.at(io_index).at(0);
+ if (tensor->get_element_type().bitwidth() < 8 || tensor->is_continuous() || tensor->get_strides().empty()) {
+ _graph->set_argument_value(desc.indexUsedByDriver,
+ static_cast<unsigned char*>(tensor->data()) +
+ (i * tensor->get_byte_size()) / _number_of_command_lists);
+ } else {
+ _graph->set_argument_value_with_strides(
+ desc.indexUsedByDriver,
+ static_cast<unsigned char*>(tensor->data()) + (i * tensor->get_strides()[0]),
+ get_strides(tensor->get_strides(), tensor->get_element_type().size()));
+ }
++io_index;
}
io_index = 0;
for (const auto& desc : _graph->get_metadata().outputs) {
- graph->set_argument_value(
- desc.indexUsedByDriver,
- static_cast<unsigned char*>(output_tensors.at(io_index)->data()) +
- (i * output_tensors.at(io_index)->get_byte_size()) / _number_of_command_lists);
+ const auto& tensor = output_tensors.at(io_index);
+ if (tensor->get_element_type().bitwidth() < 8 || tensor->is_continuous() || tensor->get_strides().empty()) {
+ _graph->set_argument_value(desc.indexUsedByDriver,
+ static_cast<unsigned char*>(tensor->data()) +
+ (i * tensor->get_byte_size()) / _number_of_command_lists);
+ } else {
+ _graph->set_argument_value_with_strides(
+ desc.indexUsedByDriver,
+ static_cast<unsigned char*>(tensor->data()) + (i * tensor->get_strides()[0]),
+ get_strides(tensor->get_strides(), tensor->get_element_type().size()));
+ }
++io_index;
}
@@ -132,7 +176,7 @@ Pipeline::Pipeline(const Config& config,
_command_lists.at(i)->appendNpuTimestamp(reinterpret_cast<uint64_t*>(_npu_profiling->npu_ts_infer_start));
}
- _command_lists.at(i)->appendGraphExecute(static_cast<ze_graph_handle_t>(graph->get_handle()),
+ _command_lists.at(i)->appendGraphExecute(static_cast<ze_graph_handle_t>(_graph->get_handle()),
_profiling_query ? _profiling_query->getHandle() : nullptr);
/// append timestamp command if feature was activated
@@ -223,30 +267,45 @@ void Pipeline::reset() const {
_logger.debug("Pipeline - rest() completed");
};
-void Pipeline::update_graph_arguments(uint32_t arg_index, const void* arg_data, size_t byte_size) {
+void Pipeline::update_graph_arguments(uint32_t index, const std::shared_ptr<ZeroTensor>& tensor) {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "updateCommandList");
_logger.debug("Pipeline - updateCommandList");
const size_t number_of_command_lists = _command_lists.size();
for (size_t i = 0; i < number_of_command_lists; i++) {
- _command_lists.at(i)->updateMutableCommandList(
- arg_index,
- static_cast<const unsigned char*>(arg_data) + (i * byte_size) / number_of_command_lists);
+ if (tensor->get_element_type().bitwidth() < 8 || tensor->is_continuous() || tensor->get_strides().empty()) {
+ _command_lists.at(i)->updateMutableCommandList(index,
+ static_cast<const unsigned char*>(tensor->data()) +
+ (i * tensor->get_byte_size()) / number_of_command_lists);
+ } else {
+ _command_lists.at(i)->updateMutableCommandListWithStrides(
+ index,
+ static_cast<const unsigned char*>(tensor->data()) + (i * tensor->get_strides()[0]),
+ get_strides(tensor->get_strides(), tensor->get_element_type().size()));
+ }
}
};
-void Pipeline::update_graph_arguments_batching(uint32_t arg_index, const void* arg_data, size_t command_list_index) {
+void Pipeline::update_graph_arguments(uint32_t index, const std::shared_ptr<ZeroTensor>& tensor, size_t batch_index) {
OV_ITT_TASK_CHAIN(ZERO_EXECUTOR_IP_UMCL, itt::domains::LevelZeroBackend, "Pipeline", "updateCommandListIndex");
_logger.debug("Pipeline - updateCommandListIndex");
const size_t number_of_command_lists = _command_lists.size();
- OPENVINO_ASSERT(command_list_index < number_of_command_lists,
+ OPENVINO_ASSERT(batch_index < number_of_command_lists,
"Command list index is higher than the number of Command lists ",
- command_list_index);
+ batch_index);
- _command_lists.at(command_list_index)->updateMutableCommandList(arg_index, arg_data);
+ if (tensor->get_element_type().bitwidth() < 8 || tensor->is_continuous() || tensor->get_strides().empty()) {
+ _command_lists.at(batch_index)->updateMutableCommandList(index, tensor->data());
+ } else {
+ _command_lists.at(batch_index)
+ ->updateMutableCommandListWithStrides(
+ index,
+ tensor->data(),
+ get_strides(tensor->get_strides(), tensor->get_element_type().size()));
+ }
};
std::vector<ov::ProfilingInfo> Pipeline::get_profiling_info() const {
diff --git a/src/plugins/intel_npu/src/backend/src/zero_tensor.cpp b/src/plugins/intel_npu/src/backend/src/zero_tensor.cpp
index 9f81050c997..d7723d9a406 100644
--- a/src/plugins/intel_npu/src/backend/src/zero_tensor.cpp
+++ b/src/plugins/intel_npu/src/backend/src/zero_tensor.cpp
@@ -9,7 +9,9 @@
#include "intel_npu/utils/zero/zero_api.hpp"
#include "intel_npu/utils/zero/zero_mem_pool.hpp"
#include "intel_npu/utils/zero/zero_remote_tensor.hpp"
+#include "intel_npu/utils/zero/zero_utils.hpp"
#include "openvino/core/memory_util.hpp"
+#include "openvino/runtime/make_tensor.hpp"
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/tensor.hpp"
@@ -36,7 +38,6 @@ ZeroTensor::ZeroTensor(const std::shared_ptr<ZeroInitStructsHolder>& init_struct
_logger("ZeroTensor", config.get<LOG_LEVEL>()),
_element_type{element_type},
_shape{shape},
- _capacity{_shape},
_strides{},
_strides_once{},
_is_input(is_input) {
@@ -44,6 +45,8 @@ ZeroTensor::ZeroTensor(const std::shared_ptr<ZeroInitStructsHolder>& init_struct
const auto byte_size = ov::util::get_memory_size_safe(element_type, _shape);
OPENVINO_ASSERT(byte_size, "Cannot allocate memory for type: ", element_type, " and shape: ", _shape);
+ _bytes_capacity = get_byte_size();
+
_mem_ref = ZeroMemPool::get_instance().allocate_zero_memory(_init_structs,
byte_size.value(),
utils::STANDARD_PAGE_SIZE,
@@ -59,31 +62,39 @@ ZeroTensor::ZeroTensor(const std::shared_ptr<ZeroInitStructsHolder>& init_struct
const ov::SoPtr<ov::ITensor>& user_tensor)
: _init_structs(init_structs),
_logger("ZeroTensor", config.get<LOG_LEVEL>()),
- _element_type{user_tensor->get_element_type()},
- _shape{user_tensor->get_shape()},
- _capacity{_shape},
- _strides{_element_type.bitwidth() >= 8 ? user_tensor->get_strides() : ov::Strides{}},
- _strides_once{},
- _user_tensor(user_tensor) {
+ _user_tensor(user_tensor),
+ _element_type{_user_tensor->get_element_type()},
+ _shape{_user_tensor->get_shape()},
+ _strides{_element_type.bitwidth() >= 8 ? _user_tensor->get_strides() : ov::Strides{}},
+ _strides_once{} {
OPENVINO_ASSERT(_element_type.is_static());
+ _bytes_capacity = get_bytes_capacity();
+
// Data pointer of the given user_tensor must be a valid address in the level zero context
- // Check first if the given tensor is a ZeroRemoteTensor (which has a different method to expose the internal
+ // Check first if the given tensor is a ov::IRemoteTensor (which has a different methods to expose the internal
// storage)
- auto remote_tensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(_user_tensor._ptr);
- if (remote_tensor == nullptr) {
- _ptr = _user_tensor->data();
+ if (auto remote_tensor = std::dynamic_pointer_cast<ov::IRemoteTensor>(_user_tensor._ptr)) {
+ if (auto zero_remote_tensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(remote_tensor)) {
+ _ptr = zero_remote_tensor->get_original_memory();
+ } else {
+ std::optional<void*> mem_handle_object =
+ zeroUtils::extract_object(remote_tensor->get_properties(), ov::intel_npu::mem_handle);
+ OPENVINO_ASSERT(mem_handle_object.has_value(),
+ "Parameter with key ",
+ ov::intel_npu::mem_handle.name(),
+ " not found");
+ _ptr = static_cast<uint8_t*>(mem_handle_object.value()) + ov::get_tensor_data_offset(*remote_tensor);
+ }
} else {
- _ptr = remote_tensor->get_original_memory();
+ _ptr = _user_tensor->data();
}
// Check if [data, data + size] was previously imported or allocated in the current level zero context. In such case
// _mem_ref will keep a reference to that allocation. Otherwise the function will try to import it into the level
// zero context.
_logger.debug("ZeroTensor::ZeroTensor - get tensor from pool or import it");
- _mem_ref = ZeroMemPool::get_instance().import_standard_allocation_memory(_init_structs,
- _ptr,
- _user_tensor->get_byte_size());
+ _mem_ref = ZeroMemPool::get_instance().import_standard_allocation_memory(_init_structs, _ptr, _bytes_capacity);
}
// Note: Override data() members to not used OpenVINO library code to improve performance
@@ -146,20 +157,25 @@ void ZeroTensor::update_strides() const {
}
}
+size_t ZeroTensor::get_bytes_capacity() const {
+ size_t original_shape_size = ov::shape_size(_shape);
+
+ if (_user_tensor == nullptr || _element_type.bitwidth() < 8 || original_shape_size == 0 || _shape.empty() ||
+ _strides.empty()) {
+ return ov::util::get_memory_size(_element_type, original_shape_size);
+ }
+
+ return intel_npu::zeroUtils::get_capacity_size(_shape, _strides);
+}
+
const ov::Strides& ZeroTensor::get_strides() const {
OPENVINO_ASSERT(_element_type.bitwidth() >= 8,
"Could not get strides for types with bitwidths less than 8 bit. Tensor type: ",
_element_type);
- std::call_once(_strides_once, &ZeroTensor::update_strides, this);
- return _strides;
-}
-size_t ZeroTensor::get_capacity() const {
- return shape_size(_capacity);
-}
+ std::call_once(_strides_once, &ZeroTensor::update_strides, this);
-size_t ZeroTensor::get_bytes_capacity() const {
- return ov::util::get_memory_size(get_element_type(), get_capacity());
+ return _strides;
}
void ZeroTensor::set_shape(ov::Shape new_shape) {
@@ -169,7 +185,7 @@ void ZeroTensor::set_shape(ov::Shape new_shape) {
_shape = std::move(new_shape);
- if (get_size() > get_capacity()) {
+ if (get_byte_size() > _bytes_capacity) {
OPENVINO_ASSERT(_init_structs->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0),
"Re-shaping the tensor with a larger shape is not available using this driver version. "
"Please update the driver to the latest version.");
@@ -181,13 +197,15 @@ void ZeroTensor::set_shape(ov::Shape new_shape) {
_ptr = nullptr;
// allocate buffer and initialize objects from scratch
- _capacity = _shape;
+ const auto byte_size = ov::util::get_memory_size_safe(_element_type, _shape);
+ OPENVINO_ASSERT(byte_size, "Cannot allocate memory for type: ", _element_type, " and shape: ", _shape);
_mem_ref = ZeroMemPool::get_instance().allocate_zero_memory(_init_structs,
- get_bytes_capacity(),
+ byte_size.value(),
utils::STANDARD_PAGE_SIZE,
_is_input);
_ptr = _mem_ref->data();
- OPENVINO_ASSERT(get_bytes_capacity() == 0 || _ptr != nullptr, "Failed to allocate zero memory");
+ OPENVINO_ASSERT(byte_size.value() == 0 || _ptr != nullptr, "Failed to allocate zero memory");
+ _bytes_capacity = get_byte_size();
_reset_tensor_memory = true;
}
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
index 159f671adae..0c89b4e031e 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/igraph.hpp
@@ -33,7 +33,10 @@ public:
virtual std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
const Config& config) const = 0;
- virtual void set_argument_value(uint32_t argi, const void* argv) const = 0;
+ virtual void set_argument_value(uint32_t id, const void* data) const = 0;
+ virtual void set_argument_value_with_strides(uint32_t id,
+ const void* data,
+ const std::vector<size_t>& strides) const = 0;
virtual void initialize(const Config& config) = 0;
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/sync_infer_request.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/sync_infer_request.hpp
index 9c068a5cb80..fd371b30d96 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/sync_infer_request.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/sync_infer_request.hpp
@@ -124,7 +124,9 @@ protected:
* @param port Input/Output port
* @param tensor Input/Output tensor
*/
- void check_tensor(const ov::Output<const ov::Node>& port, const ov::SoPtr<ov::ITensor>& tensor) const;
+ void check_tensor(const ov::Output<const ov::Node>& port,
+ const ov::SoPtr<ov::ITensor>& tensor,
+ const bool support_strides) const;
/**
* @brief Basic checks for input tensors
@@ -133,7 +135,8 @@ protected:
* @param tensors Input tensors
*/
void check_batched_tensors(const ov::Output<const ov::Node>& port,
- const std::vector<ov::SoPtr<ov::ITensor>>& tensors) const;
+ const std::vector<ov::SoPtr<ov::ITensor>>& tensors,
+ const bool support_strides) const;
/**
* @brief Check that all tensors are valid. Throws an exception if it's not.
diff --git a/src/plugins/intel_npu/src/common/src/sync_infer_request.cpp b/src/plugins/intel_npu/src/common/src/sync_infer_request.cpp
index d3eed4e7357..7a75c35def1 100644
--- a/src/plugins/intel_npu/src/common/src/sync_infer_request.cpp
+++ b/src/plugins/intel_npu/src/common/src/sync_infer_request.cpp
@@ -128,7 +128,10 @@ void SyncInferRequest::set_tensor(const ov::Output<const ov::Node>& port, const
auto foundPort = find_port(port);
OPENVINO_ASSERT(foundPort.found(), "Cannot find tensor for port ", port);
try {
- check_tensor(port, tensor);
+ check_tensor(port,
+ tensor,
+ foundPort.is_input() ? _metadata.inputs.at(foundPort.idx).supportsStridedLayout
+ : _metadata.outputs.at(foundPort.idx).supportsStridedLayout);
} catch (const ov::Exception& ex) {
OPENVINO_THROW("Failed to set tensor. ", ex.what());
}
@@ -165,14 +168,22 @@ void SyncInferRequest::set_tensors(const ov::Output<const ov::Node>& port,
}
void SyncInferRequest::check_tensor(const ov::Output<const ov::Node>& port,
- const ov::SoPtr<ov::ITensor>& tensor) const {
+ const ov::SoPtr<ov::ITensor>& tensor,
+ const bool support_strides) const {
if (tensor == nullptr)
OPENVINO_THROW("The tensor is not initialized!");
bool is_input = ov::op::util::is_parameter(port.get_node());
std::string tensor_type = is_input ? "input" : "output";
- OPENVINO_ASSERT(tensor->is_continuous(), "The tensor is not continuous");
+ if (!support_strides) {
+ OPENVINO_ASSERT(
+ tensor->is_continuous(),
+ "The tensor has a non-contiguous memory layout (custom strides), which is not supported by the "
+ "current driver/compiler version. To use strided tensors, either:\n"
+ " 1. Upgrade to a driver version that supports strides, or\n"
+ " 2. Enable stride support using the 'enable_strides_for' configuration property if this is supported.");
+ }
if ((port.get_element_type() == ov::element::Type_t::boolean ||
tensor->get_element_type() == ov::element::Type_t::boolean) &&
@@ -230,7 +241,8 @@ void SyncInferRequest::check_tensor(const ov::Output<const ov::Node>& port,
}
void SyncInferRequest::check_batched_tensors(const ov::Output<const ov::Node>& port,
- const std::vector<ov::SoPtr<ov::ITensor>>& tensors) const {
+ const std::vector<ov::SoPtr<ov::ITensor>>& tensors,
+ const bool support_strides) const {
OPENVINO_ASSERT(!tensors.empty(), "set_input_tensors/set_tensors can't be called with empty tensors");
OPENVINO_ASSERT(
tensors.size() != 1,
@@ -299,7 +311,16 @@ void SyncInferRequest::check_batched_tensors(const ov::Output<const ov::Node>& p
element_type,
" and shape ",
batched_shape);
- OPENVINO_ASSERT(item->is_continuous(), "Strides for batched tensors should be default.");
+
+ if (!support_strides) {
+ OPENVINO_ASSERT(
+ item->is_continuous(),
+ "The tensor has a non-contiguous memory layout (custom strides), which is not supported by the "
+ "current driver/compiler version. To use strided tensors, either:\n"
+ " 1. Upgrade to a driver version that supports strides, or\n"
+ " 2. Enable stride support using the 'NPU_ENABLE_STRIDES_FOR' configuration property if this is "
+ "supported.");
+ }
}
}
@@ -307,18 +328,18 @@ void SyncInferRequest::check_tensors() const {
const auto& inputs = _compiledModel->inputs();
for (size_t i = 0; i < inputs.size(); i++) {
if (is_batched_input(i)) {
- check_batched_tensors(inputs[i], get_user_inputs(i));
+ check_batched_tensors(inputs[i], get_user_inputs(i), _metadata.inputs.at(i).supportsStridedLayout);
continue;
}
if (get_user_input(i)) {
- check_tensor(inputs[i], get_user_input(i));
+ check_tensor(inputs[i], get_user_input(i), _metadata.inputs.at(i).supportsStridedLayout);
}
}
const auto& outputs = _compiledModel->outputs();
for (size_t i = 0; i < outputs.size(); i++) {
if (_userOutputTensors.at(i)) {
- check_tensor(outputs[i], _userOutputTensors.at(i));
+ check_tensor(outputs[i], _userOutputTensors.at(i), _metadata.outputs.at(i).supportsStridedLayout);
}
}
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
index d9dacc3e7cb..0352a098687 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/graph.hpp
@@ -33,7 +33,10 @@ public:
std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
const Config& config) const override;
- void set_argument_value(uint32_t argi, const void* argv) const override;
+ void set_argument_value(uint32_t id, const void* data) const override;
+ void set_argument_value_with_strides(uint32_t id,
+ const void* data,
+ const std::vector<size_t>& strides) const override;
void initialize(const Config& config) override;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
index 574c3f11e2e..322c696b0dc 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
@@ -53,7 +53,12 @@ public:
const uint8_t*& blobPtr,
size_t& blobSize) const;
- void setGraphArgumentValue(const GraphDescriptor& graphDescriptor, uint32_t argi_, const void* argv) const;
+ void setGraphArgumentValue(const GraphDescriptor& graphDescriptor, uint32_t id, const void* data) const;
+
+ void setGraphArgumentValueWithStrides(const GraphDescriptor& graphDescriptor,
+ uint32_t id,
+ const void* data,
+ const std::vector<size_t>& strides) const;
void initializeGraph(const GraphDescriptor& graphDescriptor, uint32_t commandQueueGroupOrdinal) const;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
index 19b0ef84996..ce3f5e23419 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -149,11 +149,18 @@ std::vector<ov::ProfilingInfo> Graph::process_profiling_output(const std::vector
return _compiler->process_profiling_output(profData, blob, config);
}
-void Graph::set_argument_value(uint32_t argi, const void* argv) const {
+void Graph::set_argument_value(uint32_t id, const void* data) const {
if (_zeGraphExt == nullptr) {
OPENVINO_THROW("Zero compiler adapter wasn't initialized");
}
- _zeGraphExt->setGraphArgumentValue(_graphDesc, argi, argv);
+ _zeGraphExt->setGraphArgumentValue(_graphDesc, id, data);
+}
+
+void Graph::set_argument_value_with_strides(uint32_t id, const void* data, const std::vector<size_t>& strides) const {
+ if (_zeGraphExt == nullptr) {
+ OPENVINO_THROW("Zero compiler adapter wasn't initialized");
+ }
+ _zeGraphExt->setGraphArgumentValueWithStrides(_graphDesc, id, data, strides);
}
void Graph::initialize(const Config& config) {
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
index e59d9fcc258..019003c61e6 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
@@ -17,13 +17,6 @@
#include "openvino/core/dimension.hpp"
#include "openvino/core/partial_shape.hpp"
-// A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to
-// "ze_graph_dditable_ext_1_6_t".
-// See: E#117498
-#define NotSupportArgumentMetadata(T) (T < ZE_GRAPH_EXT_VERSION_1_6)
-
-#define UseCopyForNativeBinary(T) (T < ZE_GRAPH_EXT_VERSION_1_7)
-
namespace {
using namespace intel_npu;
/**
@@ -102,6 +95,15 @@ static IODescriptor getIODescriptor(const uint32_t indexUsedByDriver,
isMainInputWeights = true;
}
+ bool supportsStridedLayout = false;
+ if (arg.pNext != nullptr) {
+ if (*reinterpret_cast<const ze_structure_type_graph_ext_t*>(arg.pNext) ==
+ ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTY_STRIDES) {
+ auto& supports_strides = *reinterpret_cast<const ze_graph_argument_property_strides_t*>(arg.pNext);
+ supportsStridedLayout = supports_strides.supportsDynamicStrides;
+ }
+ }
+
return {std::move(nameFromCompiler),
precision,
shapeFromCompiler,
@@ -115,7 +117,8 @@ static IODescriptor getIODescriptor(const uint32_t indexUsedByDriver,
arg.debug_friendly_name,
std::move(outputTensorNames),
metadata.has_value() ? std::optional(shapeFromIRModel) : std::nullopt,
- indexUsedByDriver};
+ indexUsedByDriver,
+ supportsStridedLayout};
}
} // namespace
@@ -132,9 +135,6 @@ ZeGraphExtWrappers::ZeGraphExtWrappers(const std::shared_ptr<ZeroInitStructsHold
_logger.info("Graph ext version used by zero wrapper: %d.%d",
ZE_MAJOR_VERSION(_graphExtVersion),
ZE_MINOR_VERSION(_graphExtVersion));
- _logger.debug("capabilities:");
- _logger.debug("-SupportArgumentMetadata :%d", !NotSupportArgumentMetadata(_graphExtVersion));
- _logger.debug("-UseCopyForNativeBinary :%d", UseCopyForNativeBinary(_graphExtVersion));
}
ZeGraphExtWrappers::~ZeGraphExtWrappers() {
@@ -166,7 +166,7 @@ void ZeGraphExtWrappers::getGraphBinary(const GraphDescriptor& graphDescriptor,
_logger.debug("getGraphBinary - get blob from graphHandle");
- if (UseCopyForNativeBinary(_graphExtVersion)) {
+ if (_graphExtVersion < ZE_MAKE_VERSION(1, 7)) {
// Get blob size first
_logger.debug("getGraphBinary - perform pfnGetNativeBinary to get size");
auto result =
@@ -197,16 +197,53 @@ void ZeGraphExtWrappers::getGraphBinary(const GraphDescriptor& graphDescriptor,
}
void ZeGraphExtWrappers::setGraphArgumentValue(const GraphDescriptor& graphDescriptor,
- uint32_t argi,
- const void* argv) const {
+ uint32_t id,
+ const void* data) const {
_logger.debug("setGraphArgumentValue - perform pfnSetArgumentValue");
- auto result = _zeroInitStruct->getGraphDdiTable().pfnSetArgumentValue(graphDescriptor._handle, argi, argv);
- THROW_ON_FAIL_FOR_LEVELZERO_EXT("zeGraphSetArgumentValue", result, _zeroInitStruct->getGraphDdiTable());
+ auto result = _zeroInitStruct->getGraphDdiTable().pfnSetArgumentValue(graphDescriptor._handle, id, data);
+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnSetArgumentValue", result, _zeroInitStruct->getGraphDdiTable());
+}
+
+void ZeGraphExtWrappers::setGraphArgumentValueWithStrides(const GraphDescriptor& graphDescriptor,
+ uint32_t id,
+ const void* data,
+ const std::vector<size_t>& strides) const {
+ OPENVINO_ASSERT(_graphExtVersion >= ZE_MAKE_VERSION(1, 15),
+ "Strides are not supported by the current driver version.");
+ ze_graph_argument_value_tensor_t tensorValue = {};
+ ze_graph_argument_value_strides_t stridesValue = {};
+ tensorValue.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_TENSOR;
+ tensorValue.pTensor = data;
+
+ if (!strides.empty()) {
+ if (strides.size() > ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE) {
+ OPENVINO_THROW("The driver does not support strides with more than",
+ ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE,
+ "dimensions.");
+ }
+
+ stridesValue.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_STRIDES;
+ for (size_t i = 0; i < strides.size(); ++i) {
+ if (strides[i] > std::numeric_limits<uint32_t>::max()) {
+ OPENVINO_THROW("Stride value exceeds uint32_t range supported by the driver");
+ }
+ stridesValue.userStrides[i] = static_cast<uint32_t>(strides[i]);
+ }
+
+ _logger.debug("setGraphArgumentValue - set strides");
+ tensorValue.pNext = &stridesValue;
+ }
+
+ _logger.debug("setGraphArgumentValue - perform pfnSetArgumentValue2 for data");
+ auto result = _zeroInitStruct->getGraphDdiTable().pfnSetArgumentValue2(graphDescriptor._handle,
+ id,
+ static_cast<const void*>(&tensorValue));
+ THROW_ON_FAIL_FOR_LEVELZERO_EXT("pfnSetArgumentValue2 for data", result, _zeroInitStruct->getGraphDdiTable());
}
void ZeGraphExtWrappers::initializeGraph(const GraphDescriptor& graphDescriptor,
uint32_t commandQueueGroupOrdinal) const {
- if (_zeroInitStruct->getGraphDdiTable().version() < ZE_GRAPH_EXT_VERSION_1_8) {
+ if (_graphExtVersion < ZE_MAKE_VERSION(1, 8)) {
_logger.debug("Use initializeGraphThroughCommandList for ext version smaller than 1.8");
initializeGraphThroughCommandList(graphDescriptor._handle, commandQueueGroupOrdinal);
} else {
@@ -273,7 +310,6 @@ std::unordered_set<std::string> parseQueryResult(std::vector<char>& data) {
std::unordered_set<std::string> ZeGraphExtWrappers::queryGraph(SerializedIR serializedIR,
const std::string& buildFlags) const {
ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr;
-
ze_graph_desc_2_t desc = {
_graphExtVersion < ZE_MAKE_VERSION(1, 16) ? ZE_STRUCTURE_TYPE_GRAPH_DESC : ZE_STRUCTURE_TYPE_GRAPH_DESC_2,
nullptr,
@@ -420,7 +456,10 @@ void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle,
uint32_t indexUsedByDriver,
std::vector<IODescriptor>& inputs,
std::vector<IODescriptor>& outputs) const {
- if (NotSupportArgumentMetadata(_graphExtVersion)) {
+ // A bug inside the driver makes the "pfnGraphGetArgumentMetadata" call not safe for use prior to
+ // "ze_graph_dditable_ext_1_6_t".
+ // See: E#117498
+ if (_graphExtVersion < ZE_MAKE_VERSION(1, 6)) {
ze_graph_argument_properties_3_t arg = {};
arg.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES_3;
_logger.debug("getMetadata - perform pfnGetArgumentProperties3");
@@ -443,6 +482,12 @@ void ZeGraphExtWrappers::getMetadata(ze_graph_handle_t graphHandle,
} else {
ze_graph_argument_properties_3_t arg = {};
arg.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES_3;
+ ze_graph_argument_property_strides_t supports_strides = {};
+ if (_graphExtVersion >= ZE_MAKE_VERSION(1, 15)) {
+ supports_strides.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTY_STRIDES;
+ arg.pNext = &supports_strides;
+ }
+
_logger.debug("getMetadata - perform pfnGetArgumentProperties3");
auto result =
_zeroInitStruct->getGraphDdiTable().pfnGetArgumentProperties3(graphHandle, indexUsedByDriver, &arg);
diff --git a/src/plugins/intel_npu/src/plugin/include/properties.hpp b/src/plugins/intel_npu/src/plugin/include/properties.hpp
index 87e4313eedd..c6fb019d68d 100644
--- a/src/plugins/intel_npu/src/plugin/include/properties.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/properties.hpp
@@ -72,17 +72,18 @@ private:
void registerCompiledModelProperties();
const std::vector<ov::PropertyName> _cachingProperties = {
+ ov::cache_mode.name(),
ov::device::architecture.name(),
+ ov::hint::execution_mode.name(),
+ ov::intel_npu::batch_mode.name(),
+ ov::intel_npu::compilation_mode.name(),
ov::intel_npu::compilation_mode_params.name(),
ov::intel_npu::compiler_dynamic_quantization.name(),
- ov::intel_npu::tiles.name(),
+ ov::intel_npu::compiler_type.name(),
ov::intel_npu::dma_engines.name(),
- ov::intel_npu::compilation_mode.name(),
ov::intel_npu::driver_version.name(),
- ov::intel_npu::compiler_type.name(),
- ov::intel_npu::batch_mode.name(),
- ov::hint::execution_mode.name(),
- ov::cache_mode.name(),
+ ov::intel_npu::enable_strides_for.name(),
+ ov::intel_npu::tiles.name(),
// NPUW caching properties
ov::intel_npu::use_npuw.name(),
ov::intel_npu::npuw::devices.name(),
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 1f864cecbd4..bb1072f602b 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -324,6 +324,7 @@ void Plugin::init_options() {
REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);
REGISTER_OPTION(USE_BASE_MODEL_SERIALIZER);
REGISTER_OPTION(MODEL_SERIALIZER_VERSION);
+ REGISTER_OPTION(ENABLE_STRIDES_FOR);
if (_backend) {
if (_backend->isCommandQueueExtSupported()) {
@@ -674,8 +675,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
OV_ITT_TASK_CHAIN(PLUGIN_COMPILE_MODEL, itt::domains::NPUPlugin, "Plugin::compile_model", "fork_local_config");
auto localConfig = fork_local_config(localPropertiesMap, compiler);
- const auto set_cache_dir = localConfig.get<CACHE_DIR>();
- if (!set_cache_dir.empty()) {
+ const auto setCacheDir = localConfig.get<CACHE_DIR>();
+ if (!setCacheDir.empty()) {
const auto compilerType = localConfig.get<COMPILER_TYPE>();
if (compilerType == ov::intel_npu::CompilerType::PLUGIN) {
OPENVINO_THROW("Option 'CACHE_DIR' is not supported with PLUGIN compiler type");
@@ -729,6 +730,18 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
intel_npu::batch_helpers::handlePluginBatching(model, localConfig, updateBatchMode, originalBatch, _logger);
}
+ if (localConfig.has(ov::intel_npu::enable_strides_for.name())) {
+ if (model->is_dynamic()) {
+ OPENVINO_ASSERT(
+ !intel_npu::batch_helpers::checkModelDynamicDims(model),
+ "Dynamic shape tensors are not supported with the dynamic strides feature (ENABLE_STRIDES_FOR).");
+
+ OPENVINO_ASSERT(successfullyDebatched || !localConfig.isAvailable(ov::intel_npu::batch_mode.name()) ||
+ localConfig.get<BATCH_MODE>() != ov::intel_npu::BatchMode::COMPILER,
+ "Dynamic batching is not supported with the dynamic strides feature (ENABLE_STRIDES_FOR).");
+ }
+ }
+
// Update stepping w/ information from driver, unless provided by user or we are off-device
// Ignore, if compilation was requested for platform, different from current
if (!localConfig.has<STEPPING>() && device != nullptr &&
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index 7409e0bf7e0..338a72ab7b6 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -388,6 +388,7 @@ void Properties::registerPluginProperties() {
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::separate_weights_version, SEPARATE_WEIGHTS_VERSION);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::use_base_model_serializer, USE_BASE_MODEL_SERIALIZER);
TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::model_serializer_version, MODEL_SERIALIZER_VERSION);
+ TRY_REGISTER_SIMPLE_PROPERTY(ov::intel_npu::enable_strides_for, ENABLE_STRIDES_FOR);
TRY_REGISTER_CUSTOMFUNC_PROPERTY(ov::intel_npu::stepping, STEPPING, [&](const Config& config) {
if (!config.has<STEPPING>()) {
@@ -628,6 +629,7 @@ void Properties::registerCompiledModelProperties() {
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::weightless_blob, WEIGHTLESS_BLOB);
TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::separate_weights_version, SEPARATE_WEIGHTS_VERSION);
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET(ov::intel_npu::enable_strides_for, ENABLE_STRIDES_FOR);
TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::batch_mode, BATCH_MODE, false);
diff --git a/src/plugins/intel_npu/src/plugin/src/remote_context.cpp b/src/plugins/intel_npu/src/plugin/src/remote_context.cpp
index c901724f68d..194bbac0cbc 100644
--- a/src/plugins/intel_npu/src/plugin/src/remote_context.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/remote_context.cpp
@@ -4,21 +4,9 @@
#include "remote_context.hpp"
-using namespace ov::intel_npu;
-
-namespace {
-
-template <typename Type>
-std::optional<Type> extract_object(const ov::AnyMap& params, const ov::Property<Type>& p) {
- auto itrHandle = params.find(p.name());
- if (itrHandle == params.end()) {
- return std::nullopt;
- }
+#include "intel_npu/utils/zero/zero_utils.hpp"
- return ov::Any(itrHandle->second).as<Type>();
-}
-
-} // namespace
+using namespace ov::intel_npu;
namespace intel_npu {
@@ -34,10 +22,10 @@ RemoteContextImpl::RemoteContextImpl(const ov::SoPtr<IEngineBackend>& engineBack
_properties = {l0_context(engineBackend->getContext())};
if (!remote_properties.empty()) {
- _mem_type_object = extract_object(remote_properties, mem_type);
- _tensor_type_object = extract_object(remote_properties, tensor_type);
- _mem_handle_object = extract_object(remote_properties, mem_handle);
- _file_descriptor_object = extract_object(remote_properties, file_descriptor);
+ _mem_type_object = zeroUtils::extract_object(remote_properties, mem_type);
+ _tensor_type_object = zeroUtils::extract_object(remote_properties, tensor_type);
+ _mem_handle_object = zeroUtils::extract_object(remote_properties, mem_handle);
+ _file_descriptor_object = zeroUtils::extract_object(remote_properties, file_descriptor);
}
}
@@ -56,10 +44,10 @@ ov::SoPtr<ov::IRemoteTensor> RemoteContextImpl::create_tensor(const ov::element:
if (!params.empty()) {
// Save local remote properties.
- mem_type_object = extract_object(params, mem_type);
- tensor_type_object = extract_object(params, tensor_type);
- mem_handle_object = extract_object(params, mem_handle);
- file_descriptor_object = extract_object(params, file_descriptor);
+ mem_type_object = zeroUtils::extract_object(params, mem_type);
+ tensor_type_object = zeroUtils::extract_object(params, tensor_type);
+ mem_handle_object = zeroUtils::extract_object(params, mem_handle);
+ file_descriptor_object = zeroUtils::extract_object(params, file_descriptor);
}
// Merge local remote properties with global remote properties.
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_remote_tensor.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_remote_tensor.hpp
index 324d23e7e5e..1aeabd4e8f2 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_remote_tensor.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_remote_tensor.hpp
@@ -63,6 +63,16 @@ public:
*/
const ov::Strides& get_strides() const override;
+ void copy_to(const std::shared_ptr<ov::ITensor>& dst,
+ size_t src_offset,
+ size_t dst_offset,
+ const ov::Shape& roi_shape) const override;
+
+ void copy_from(const std::shared_ptr<const ov::ITensor>& src,
+ size_t src_offset,
+ size_t dst_offset,
+ const ov::Shape& roi_shape) override;
+
/**
* @return The remote context
*/
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
index 1c269d2ebd4..cc30b2b5dd3 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_utils.hpp
@@ -8,6 +8,8 @@
#include <ze_api.h>
#include <ze_graph_ext.h>
+#include <optional>
+
#include "intel_npu/utils/logger/logger.hpp"
#include "intel_npu/utils/zero/zero_api.hpp"
#include "intel_npu/utils/zero/zero_result.hpp"
@@ -217,5 +219,31 @@ static inline uint64_t get_l0_context_memory_allocation_id(ze_context_handle_t h
return 0;
}
+template <typename Type>
+std::optional<Type> extract_object(const ov::AnyMap& params, const ov::Property<Type>& p) {
+ auto itrHandle = params.find(p.name());
+ if (itrHandle == params.end()) {
+ return std::nullopt;
+ }
+
+ return ov::Any(itrHandle->second).as<Type>();
+}
+
+static inline size_t get_capacity_size(const ov::Shape& shape, const ov::Strides& strides) {
+ size_t capacity = 0;
+ const size_t rank = shape.size();
+ for (size_t i = 0; i < rank; ++i) {
+ if (i == rank - 1) {
+ // Last dimension: use shape[i] * stride[i]
+ capacity += shape[i] * strides[i];
+ } else {
+ // Other dimensions: use (shape[i] - 1) * stride[i]
+ capacity += (shape[i] - 1) * strides[i];
+ }
+ }
+
+ return capacity;
+}
+
} // namespace zeroUtils
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
index 0a51287c241..28db9d0dd61 100644
--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/zero/zero_wrappers.hpp
@@ -72,7 +72,10 @@ public:
void appendGraphInitialize(const ze_graph_handle_t& graph_handle) const;
void appendGraphExecute(const ze_graph_handle_t& graph_handle,
const ze_graph_profiling_query_handle_t& profiling_query_handle) const;
- void updateMutableCommandList(uint32_t arg_index, const void* arg_value) const;
+ void updateMutableCommandList(uint32_t index, const void* data) const;
+ void updateMutableCommandListWithStrides(uint32_t index,
+ const void* data,
+ const std::vector<size_t>& strides) const;
void appendNpuTimestamp(uint64_t* timestamp_buff) const;
void appendBarrier() const;
void close() const;
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_remote_tensor.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_remote_tensor.cpp
index 480c1e3fe72..ff80c4ce9b8 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_remote_tensor.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_remote_tensor.cpp
@@ -8,10 +8,201 @@
#include "intel_npu/utils/utils.hpp"
#include "intel_npu/utils/zero/zero_mem_pool.hpp"
+#include "intel_npu/utils/zero/zero_utils.hpp"
#include "openvino/core/memory_util.hpp"
#include "openvino/runtime/tensor.hpp"
using namespace ov::intel_npu;
+
+namespace {
+
+/**
+ * @brief Validates that offset and ROI shape fit within the parent tensor
+ * @param owner_shape The shape of the owner tensor
+ * @param offset The byte offset from the start of parent tensor
+ * @param roi_shape The shape of the ROI
+ * @param owner_strides The strides of the owner tensor
+ * @param element_size Size of one element in bytes
+ * @return true if valid, throws otherwise
+ */
+void validate_src_roi_bounds(const ov::Shape& owner_shape,
+ size_t offset,
+ const ov::Shape& roi_shape,
+ const ov::Strides& owner_strides,
+ const ov::element::Type& type) {
+ OPENVINO_ASSERT(owner_shape.size() == roi_shape.size(), "ROI rank must match parent tensor rank");
+
+ size_t total_bytes = ov::util::get_memory_size(type, ov::shape_size(owner_shape));
+ size_t roi_bytes = intel_npu::zeroUtils::get_capacity_size(roi_shape, owner_strides);
+
+ OPENVINO_ASSERT(offset + roi_bytes <= total_bytes,
+ "ROI with offset ",
+ offset,
+ " and size ",
+ roi_bytes,
+ " bytes exceeds parent tensor size of ",
+ total_bytes,
+ " bytes");
+}
+
+/**
+ * @brief Validates that offset and ROI shape fit within the dst tensor
+ * @param dst_shape The shape of the dst tensor
+ * @param offset The byte offset from the start of parent tensor
+ * @param roi_shape The shape of the ROI
+ * @param dst_strides The strides of the dst tensor
+ * @return true if valid, throws otherwise
+ */
+void validate_dst_roi_bounds(const ov::Shape& dst_shape,
+ size_t offset,
+ const ov::Shape& roi_shape,
+ const ov::Strides& dst_strides) {
+ OPENVINO_ASSERT(dst_shape.size() == roi_shape.size(), "ROI rank must match parent tensor rank");
+
+ size_t roi_offset = 0;
+ for (auto i = dst_strides.size() - 1; i > 0; --i) {
+ roi_offset = offset % dst_strides[i];
+ auto check_dim = roi_offset / dst_strides[i - 1];
+ if (check_dim + roi_shape[i - 1] > dst_shape[i - 1]) {
+ OPENVINO_THROW("ROI with offset ", offset, " exceeds destination tensor shape.");
+ }
+ }
+}
+
+ov::Strides default_byte_strides(const ov::Shape& shape, const ov::element::Type& et) {
+ auto strides = ov::Strides(shape.size());
+ if (!strides.empty()) {
+ strides.back() = et.size();
+ std::transform(shape.crbegin(),
+ shape.crend() - 1,
+ strides.rbegin(),
+ strides.rbegin() + 1,
+ std::multiplies<size_t>());
+ }
+ return strides;
+}
+
+/**
+ * @brief Copies tensor data between source and destination, handling strided memory layouts
+ * @param src Source tensor
+ * @param dst Destination tensor
+ * @param roi_shape Shape of region of interest to copy
+ * @param shape Bigger shape
+ * @param src_data Pointer to source data (with offset applied)
+ * @param dst_data Pointer to destination data (with offset applied)
+ */
+void copy_data(const std::shared_ptr<const ov::ITensor>& src,
+ const std::shared_ptr<ov::ITensor>& dst,
+ const ov::Shape& roi_shape,
+ const ov::Shape& shape,
+ const uint8_t* src_data,
+ uint8_t* dst_data) {
+ const auto& is_scalar = [](const ov::Shape& shape) {
+ return shape.empty() || (shape.size() == 1 && shape[0] == 1);
+ };
+
+ ov::Strides src_strides{src->get_byte_size()};
+ ov::Strides dst_strides{dst->get_byte_size()};
+ ov::Shape cur_pos{0};
+ ov::Shape max_pos{1};
+
+ if (src->get_element_type().bitwidth() < 8 || (src->get_strides() == dst->get_strides() && src->is_continuous()) ||
+ (is_scalar(roi_shape) && is_scalar(shape))) {
+ // OpenVINO doesn't support strides for LP types
+ // or both tensors have default strides
+ // Strides and positions already initialized
+ } else {
+ // Tensors have default strides
+ const auto& type = src->get_element_type();
+ const auto shape_rank = roi_shape.size();
+ const auto default_strides = default_byte_strides(src->get_shape(), type);
+
+ src_strides = src->get_strides();
+ dst_strides = dst->get_strides();
+
+ ov::Strides src_str, dst_str;
+
+ // Calculate src and dst shapes
+ bool found_step = false;
+ for (size_t inverted_idx = shape_rank - 1; inverted_idx < shape_rank; --inverted_idx) {
+ if (!found_step) {
+ if (default_strides[inverted_idx] == src_strides[inverted_idx] &&
+ src_strides[inverted_idx] == dst_strides[inverted_idx]) {
+ continue;
+ } else {
+ found_step = true;
+ size_t strides_size = inverted_idx + 1;
+ // Set right size
+ src_str.resize(strides_size + 1);
+ dst_str.resize(strides_size + 1);
+ max_pos.resize(strides_size + 1);
+ cur_pos.resize(strides_size + 1);
+ // In case of default continuous strides we can copy several elements
+ // In other case only one element
+ size_t dim = 1;
+ size_t strides = type.size();
+
+ if (strides_size < default_strides.size()) {
+ strides = default_strides[strides_size];
+ dim = roi_shape[strides_size];
+ }
+ src_str[strides_size] = strides;
+ dst_str[strides_size] = strides;
+ max_pos[strides_size] = dim;
+ cur_pos[strides_size] = 0;
+ }
+ }
+ src_str[inverted_idx] = src_strides[inverted_idx];
+ dst_str[inverted_idx] = dst_strides[inverted_idx];
+ max_pos[inverted_idx] = roi_shape[inverted_idx];
+ cur_pos[inverted_idx] = 0;
+ }
+ src_strides = std::move(src_str);
+ dst_strides = std::move(dst_str);
+ }
+
+ const auto update_index = [](const ov::Shape& pos, const ov::Strides& strides) {
+ return std::inner_product(pos.begin(), pos.end(), strides.begin(), static_cast<size_t>(0));
+ };
+
+ using copy_function_def = std::function<void(const uint8_t*, uint8_t*, size_t)>;
+ copy_function_def memcpy_based_copy = [](const uint8_t* src_data, uint8_t* dst_data, size_t bytes_size) {
+ memcpy(dst_data, src_data, bytes_size);
+ };
+ copy_function_def strings_copy = [](const uint8_t* src_data, uint8_t* dst_data, size_t bytes_size) {
+ // in case string tensors, it needs to copy of new values for std::string objects
+ // memcpy is not suitable
+ auto dst_string = reinterpret_cast<std::string*>(dst_data);
+ auto src_string = reinterpret_cast<const std::string*>(src_data);
+ size_t num_elements_stride = bytes_size / ov::element::string.size();
+ std::copy_n(src_string, num_elements_stride, dst_string);
+ };
+ copy_function_def copy_function =
+ (src->get_element_type() == ov::element::string) ? strings_copy : memcpy_based_copy;
+
+ bool finish = false;
+
+ for (size_t dst_idx = 0, src_idx = 0; !finish;) {
+ copy_function(src_data + src_idx, dst_data + dst_idx, src_strides[src_strides.size() - 1]);
+
+ // update indexes
+ for (size_t i = 0; i < cur_pos.size(); i++) {
+ size_t inverted_idx = cur_pos.size() - i - 1;
+ cur_pos[inverted_idx]++;
+ if (cur_pos[inverted_idx] != max_pos[inverted_idx]) {
+ break;
+ }
+ if (inverted_idx)
+ cur_pos[inverted_idx] = 0;
+ else
+ finish = true;
+ }
+ src_idx = update_index(cur_pos, src_strides);
+ dst_idx = update_index(cur_pos, dst_strides);
+ }
+}
+
+} // namespace
namespace intel_npu {
ZeroRemoteTensor::ZeroRemoteTensor(const std::shared_ptr<ov::IRemoteContext>& context,
@@ -252,6 +443,90 @@ ze_context_handle_t ZeroRemoteTensor::get_zero_context_handle() const {
return _init_structs->getContext();
}
+void ZeroRemoteTensor::copy_to(const std::shared_ptr<ov::ITensor>& dst,
+ size_t src_offset,
+ size_t dst_offset,
+ const ov::Shape& roi_shape) const {
+ OPENVINO_ASSERT(dst, "Destination tensor was not initialized.");
+ OPENVINO_ASSERT(dst->get_element_type() == get_element_type(),
+ "Tensor element types are not equal. (src: ",
+ get_element_type(),
+ " != dst: ",
+ dst->get_element_type(),
+ ")");
+
+ OPENVINO_ASSERT(roi_shape.empty() || get_element_type().bitwidth() >= 8,
+ "ROI copy is not supported for bitwidth < 8.");
+
+ if (!roi_shape.empty()) {
+ validate_src_roi_bounds(get_shape(), src_offset, roi_shape, get_strides(), get_element_type());
+ validate_dst_roi_bounds(dst->get_shape(), dst_offset, roi_shape, dst->get_strides());
+ } else {
+ if (get_shape() != dst->get_shape()) {
+ dst->set_shape(get_shape());
+ }
+ }
+
+ const auto& src_shape = roi_shape.empty() ? get_shape() : roi_shape;
+ const auto& dst_shape = dst->get_shape();
+
+ auto dst_zero_remote_tensor = std::dynamic_pointer_cast<ZeroRemoteTensor>(dst);
+ if (dst_zero_remote_tensor == nullptr) {
+ if (auto remote_tensor_dst = std::dynamic_pointer_cast<ov::IRemoteTensor>(dst)) {
+ OPENVINO_THROW("Copy to other remote tensor types is not supported.");
+ }
+ }
+
+ auto* src_data = static_cast<const uint8_t*>(get_original_memory()) + src_offset;
+ auto* dst_data = dst_zero_remote_tensor == nullptr
+ ? static_cast<uint8_t*>(dst->data()) + dst_offset
+ : static_cast<uint8_t*>(dst_zero_remote_tensor->get_original_memory()) + dst_offset;
+
+ copy_data(shared_from_this(), dst, src_shape, dst_shape, src_data, dst_data);
+}
+
+void ZeroRemoteTensor::copy_from(const std::shared_ptr<const ov::ITensor>& src,
+ size_t src_offset,
+ size_t dst_offset,
+ const ov::Shape& roi_shape) {
+ OPENVINO_ASSERT(src, "Destination tensor was not initialized.");
+ OPENVINO_ASSERT(src->get_element_type() == get_element_type(),
+ "Tensor element types are not equal. (src: ",
+ get_element_type(),
+ " != dst: ",
+ src->get_element_type(),
+ ")");
+
+ OPENVINO_ASSERT(roi_shape.empty() || get_element_type().bitwidth() >= 8,
+ "ROI copy is not supported for bitwidth < 8.");
+
+ if (!roi_shape.empty()) {
+ validate_src_roi_bounds(src->get_shape(), src_offset, roi_shape, src->get_strides(), get_element_type());
+ validate_dst_roi_bounds(get_shape(), dst_offset, roi_shape, get_strides());
+ } else {
+ if (src->get_shape() != get_shape()) {
+ set_shape(src->get_shape());
+ }
+ }
+
+ const auto& src_shape = src->get_shape();
+ const auto& dst_shape = roi_shape.empty() ? get_shape() : roi_shape;
+
+ auto src_zero_remote_tensor = std::dynamic_pointer_cast<const ZeroRemoteTensor>(src);
+ if (src_zero_remote_tensor == nullptr) {
+ if (auto remote_tensor_src = std::dynamic_pointer_cast<const ov::IRemoteTensor>(src)) {
+ OPENVINO_THROW("Copy from other remote tensor types is not supported.");
+ }
+ }
+
+ auto* src_data = src_zero_remote_tensor == nullptr
+ ? static_cast<const uint8_t*>(src->data()) + src_offset
+ : static_cast<const uint8_t*>(src_zero_remote_tensor->get_original_memory()) + src_offset;
+ auto* dst_data = static_cast<uint8_t*>(get_original_memory()) + dst_offset;
+
+ copy_data(src, shared_from_this(), dst_shape, src_shape, src_data, dst_data);
+}
+
ZeroRemoteTensor::~ZeroRemoteTensor() {
_host_memory = nullptr; // Ensure that zero memory is destroyed before the _mmap_tensor tensor is released
}
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
index 5bcd81227ff..65474d87731 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_wrappers.cpp
@@ -129,15 +129,57 @@ CommandList::~CommandList() {
_handle = nullptr;
}
-void CommandList::updateMutableCommandList(uint32_t arg_index, const void* arg_value) const {
- ze_mutable_graph_argument_exp_desc_t desc = {
- (_init_structs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 11))
- ? ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC
- : static_cast<ze_structure_type_t>(ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED),
- nullptr,
- _command_id,
- arg_index,
- arg_value};
+void CommandList::updateMutableCommandList(uint32_t index, const void* data) const {
+ ze_mutable_graph_argument_exp_desc_t desc = {};
+
+ desc.stype = (_init_structs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 11))
+ ? ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC
+ : static_cast<ze_structure_type_t>(ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED);
+ desc.commandId = _command_id;
+ desc.argIndex = index;
+ desc.pArgValue = data;
+
+ ze_mutable_commands_exp_desc_t mutable_commands_exp_desc_t = {ZE_STRUCTURE_TYPE_MUTABLE_COMMANDS_EXP_DESC,
+ &desc,
+ 0};
+
+ THROW_ON_FAIL_FOR_LEVELZERO("zeCommandListUpdateMutableCommandsExp",
+ zeCommandListUpdateMutableCommandsExp(_handle, &mutable_commands_exp_desc_t));
+}
+void CommandList::updateMutableCommandListWithStrides(uint32_t index,
+ const void* data,
+ const std::vector<size_t>& strides) const {
+ ze_mutable_graph_argument_exp_desc_t desc = {};
+
+ desc.stype = (_init_structs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 11))
+ ? ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC
+ : static_cast<ze_structure_type_t>(ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED);
+ desc.commandId = _command_id;
+ desc.argIndex = index;
+ desc.pArgValue = data;
+
+ ze_graph_argument_value_strides_t strides_value = {};
+ if (!strides.empty()) {
+ if (_init_structs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 15)) {
+ OPENVINO_THROW("Strides are not supported by the current driver version.");
+ }
+
+ if (strides.size() > ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE) {
+ OPENVINO_THROW("The driver does not support strides with more than",
+ ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE,
+ "dimensions.");
+ }
+
+ strides_value.stype = ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_STRIDES;
+ for (size_t i = 0; i < strides.size(); ++i) {
+ if (strides[i] > std::numeric_limits<uint32_t>::max()) {
+ OPENVINO_THROW("Stride value exceeds uint32_t range supported by the driver");
+ }
+ strides_value.userStrides[i] = static_cast<uint32_t>(strides[i]);
+ }
+
+ desc.pNext = &strides_value;
+ }
ze_mutable_commands_exp_desc_t mutable_commands_exp_desc_t = {ZE_STRUCTURE_TYPE_MUTABLE_COMMANDS_EXP_DESC,
&desc,
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 2cbfa2aefbb..1723b02aeba 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
@@ -1318,7 +1318,7 @@ TEST_P(ROITensorInference, InferenceROITensor) {
OV_EXPECT_THROW_HAS_SUBSTRING(req.set_tensor(tensor_name, m_param.m_input_tensor),
ov::Exception,
- "The tensor is not continuous");
+ "tensor has a non-contiguous memory");
}
using SetShapeInferRunTests = InferRequestRunTests;
diff --git a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp
new file mode 100644
index 00000000000..5b75bbcb52e
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp
@@ -0,0 +1,19 @@
+// Copyright (C) 2018-2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "roi_tensors_tests.hpp"
+
+#include "common/npu_test_env_cfg.hpp"
+#include "common/utils.hpp"
+#include "intel_npu/config/options.hpp"
+
+using namespace ov::test::behavior;
+
+const std::vector<ov::AnyMap> roiConfigs = {{}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTest,
+ RoiTensorsTestsRun,
+ ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
+ ::testing::ValuesIn(roiConfigs)),
+ RoiTensorsTestsRun::getTestCaseName);
diff --git a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hpp
new file mode 100644
index 00000000000..518e2d6bd3a
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hpp
@@ -0,0 +1,1121 @@
+// Copyright (C) 2018-2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <gmock/gmock-matchers.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "common/npu_test_env_cfg.hpp"
+#include "common/utils.hpp"
+#include "intel_npu/utils/zero/zero_init.hpp"
+#include "intel_npu/utils/zero/zero_remote_tensor.hpp"
+#include "openvino/core/any.hpp"
+#include "openvino/core/node_vector.hpp"
+#include "openvino/opsets/opset8.hpp"
+#include "openvino/runtime/compiled_model.hpp"
+#include "openvino/runtime/core.hpp"
+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"
+#include "openvino/runtime/iremote_tensor.hpp"
+#include "openvino/runtime/make_tensor.hpp"
+#include "remote_context.hpp"
+#include "zero_backend.hpp"
+#include "zero_tensor.hpp"
+
+using CompilationParams = std::tuple<std::string, // Device name
+ ov::AnyMap // Config
+ >;
+
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+
+namespace ov {
+namespace test {
+namespace behavior {
+class RoiTensorsTestsRun : public ov::test::behavior::OVPluginTestBase,
+ public testing::WithParamInterface<CompilationParams> {
+protected:
+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();
+ ov::AnyMap configuration;
+
+public:
+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {
+ std::string targetDevice;
+ ov::AnyMap configuration;
+ std::tie(targetDevice, configuration) = obj.param;
+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');
+
+ std::ostringstream result;
+ result << "targetDevice=" << targetDevice << "_";
+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";
+ if (!configuration.empty()) {
+ for (const auto& configItem : configuration) {
+ result << "configItem=" << configItem.first << "_";
+ configItem.second.print(result);
+ }
+ }
+
+ return result.str();
+ }
+
+ void SetUp() override {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED();
+
+ std::tie(target_device, configuration) = this->GetParam();
+ OVPluginTestBase::SetUp();
+
+ // TODO: Enable property check when enable_strides_for becomes part of public properties
+ // isStridedEnabled();
+ }
+
+ void TearDown() override {
+ if (!configuration.empty()) {
+ utils::PluginCache::get().reset();
+ }
+
+ APIBaseTest::TearDown();
+ }
+
+ std::shared_ptr<Model> createModelWithNInputs(element::Type type,
+ const PartialShape& shape,
+ const ov::Layout& layout,
+ size_t n = 1) {
+ ResultVector res;
+ ParameterVector params;
+
+ for (size_t i = 0; i < n; i++) {
+ auto index_str = std::to_string(i);
+ auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);
+ data1->set_friendly_name("input" + index_str);
+ data1->get_output_tensor(0).set_names({"tensor_input" + index_str});
+ data1->set_layout(layout);
+ auto constant = opset8::Constant::create(type, {1}, {1});
+ auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);
+ op1->set_friendly_name("Add" + index_str);
+ auto res1 = std::make_shared<ov::op::v0::Result>(op1);
+ res1->set_friendly_name("Result" + index_str);
+ res1->get_output_tensor(0).set_names({"tensor_output" + index_str});
+ params.push_back(data1);
+ res.push_back(res1);
+ }
+
+ return std::make_shared<Model>(res, params);
+ }
+
+ void isStridedEnabled() {
+ auto supportedProperties =
+ core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();
+
+ bool stridesEnabled =
+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const auto& property) {
+ return property == ov::intel_npu::enable_strides_for.name();
+ });
+
+ if (!stridesEnabled) {
+ GTEST_SKIP() << "NPU_ENABLE_STRIDES_FOR property is not supported";
+ }
+ }
+};
+
+TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabled) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+ OV_ASSERT_NO_THROW(req.infer());
+}
+
+TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabledInternalOperator) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+ auto input_strides = input_host_tensor.get_strides();
+ auto output_strides = output_host_tensor.get_strides();
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));
+
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+}
+
+TEST_P(RoiTensorsTestsRun, CreateStridedTensorFromHostTensorAndRunInfer) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+ auto input_strides = input_host_tensor.get_strides();
+ auto output_strides = output_host_tensor.get_strides();
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));
+
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);
+ output_view_tensor.copy_to(check_out_view_tensor);
+ auto* check_data = check_out_view_tensor.data<float>();
+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, SetStridedTensorForUnexpectedTensorExpectedThrow) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+ auto zero_context = core->get_default_context(target_device);
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+ auto output_strides = output_host_tensor.get_strides();
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0";
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ EXPECT_THROW(req.set_output_tensor(output_view_tensor), ov::Exception);
+}
+
+TEST_P(RoiTensorsTestsRun, SetStridedMultipleOutputTensorForUnexpectedTensorExpectedThrow) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...", 2);
+ auto zero_context = core->get_default_context(target_device);
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+ auto output_strides = output_host_tensor.get_strides();
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,tensor_output0";
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ EXPECT_THROW(req.set_output_tensor(1, output_view_tensor), ov::Exception);
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInfer) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatching) {
+ auto shape = Shape{2, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatchingUpdateMCL) {
+ auto shape = Shape{2, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));
+
+ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor1.copy_to(check_out_roi_tensor1);
+ auto* check_data = check_out_roi_tensor1.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+
+ ov::Tensor input_roi_tensor2 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {2, 4, 5, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor2));
+
+ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor2.copy_to(check_out_roi_tensor2);
+ check_data = check_out_roi_tensor2.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 76.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRunInferWithBatchingUpdateMCL) {
+ auto shape = Shape{2, 2, 2, 2};
+ auto batchedShape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});
+ ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_host_tensor, {2, 4, 4, 4}, {3, 6, 6, 6});
+ std::vector<ov::Tensor> tensors1;
+ tensors1.push_back(input_roi_tensor1_batched0);
+ tensors1.push_back(input_roi_tensor1_batched1);
+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););
+
+ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor1.copy_to(check_out_roi_tensor1);
+ auto* check_data = check_out_roi_tensor1.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+
+ ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});
+ ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});
+
+ std::vector<ov::Tensor> tensors2;
+ tensors2.push_back(input_roi_tensor2_batched0);
+ tensors2.push_back(input_roi_tensor2_batched1);
+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););
+
+ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor2.copy_to(check_out_roi_tensor2);
+ check_data = check_out_roi_tensor2.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 76.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRegularTensorAndRunInferWithBatchingUpdateMCL) {
+ auto shape = Shape{2, 2, 2, 2};
+ auto batchedShape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ auto input_regular_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};
+ input_data = input_regular_tensor.data<float>();
+ for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});
+ ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_regular_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ std::vector<ov::Tensor> tensors1;
+ tensors1.push_back(input_roi_tensor1_batched0);
+ tensors1.push_back(input_roi_tensor1_batched1);
+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););
+
+ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor1.copy_to(check_out_roi_tensor1);
+ auto* check_data = check_out_roi_tensor1.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ input_data = input_regular_tensor.data<float>();
+ for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+ input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+
+ ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_regular_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});
+ ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});
+
+ std::vector<ov::Tensor> tensors2;
+ tensors2.push_back(input_roi_tensor2_batched0);
+ tensors2.push_back(input_roi_tensor2_batched1);
+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););
+
+ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor2.copy_to(check_out_roi_tensor2);
+ check_data = check_out_roi_tensor2.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 76.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, FallbackOnMemcpy) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto input_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};
+ auto output_tensor = ov::Tensor{ov::element::f32, Shape{3, 8, 8, 8}};
+
+ auto* input_data = input_tensor.data<float>();
+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_tensor.data<float>();
+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContext) {
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;
+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();
+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);
+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();
+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);
+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();
+
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,
+ init_struct,
+ ov::element::f32,
+ Shape{1, 10, 10, 10});
+
+ auto output_remote_tensor =
+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});
+
+ auto input_tensor = make_tensor(input_remote_tensor);
+ auto output_tensor = make_tensor(output_remote_tensor);
+
+ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ init_struct = nullptr;
+}
+
+TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyToAnotherRemoteTensor) {
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;
+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();
+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);
+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();
+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);
+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();
+
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,
+ init_struct,
+ ov::element::f32,
+ Shape{1, 10, 10, 10});
+
+ auto output_remote_tensor =
+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});
+
+ auto input_tensor = make_tensor(input_remote_tensor);
+ auto output_tensor = make_tensor(output_remote_tensor);
+
+ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,
+ init_struct,
+ ov::element::f32,
+ Shape{1, 8, 8, 10});
+ auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);
+ ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});
+ output_roi_tensor.copy_to(check_out_roi_tensor_roi);
+
+ auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ check_out_roi_tensor_roi.copy_to(check_out_roi_roi_tensor);
+ auto* check_data = check_out_roi_roi_tensor.data<float>();
+ for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ init_struct = nullptr;
+}
+
+TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyFromAnotherRemoteTensor) {
+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;
+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();
+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);
+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();
+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);
+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();
+
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,
+ init_struct,
+ ov::element::f32,
+ Shape{1, 10, 10, 10});
+
+ auto output_remote_tensor =
+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});
+
+ auto input_tensor = make_tensor(input_remote_tensor);
+ auto output_tensor = make_tensor(output_remote_tensor);
+
+ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());
+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,
+ init_struct,
+ ov::element::f32,
+ Shape{1, 8, 8, 10});
+ auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);
+ ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});
+ auto check_out_roi_remote_tensor_roi =
+ std::dynamic_pointer_cast<ov::IRemoteTensor>(get_tensor_impl(check_out_roi_tensor_roi)._ptr);
+ check_out_roi_remote_tensor_roi->copy_from(get_tensor_impl(output_roi_tensor)._ptr);
+
+ auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ check_out_roi_remote_tensor_roi->copy_to(get_tensor_impl(check_out_roi_roi_tensor)._ptr);
+ auto* check_data = check_out_roi_roi_tensor.data<float>();
+ for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ init_struct = nullptr;
+}
+
+TEST_P(RoiTensorsTestsRun, ImportStandardAllocation) {
+ auto shape = Shape{1, 2, 2, 1024};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto shape_input = Shape{1, 4, 8, 1024};
+ auto shape_output = Shape{1, 2, 4, 2048};
+
+ auto input_data = static_cast<float*>(
+ ::operator new(ov::shape_size(shape_input) * ov::element::f32.size(), std::align_val_t(4096)));
+ auto output_data = static_cast<float*>(
+ ::operator new(ov::shape_size(shape_output) * ov::element::f32.size(), std::align_val_t(4096)));
+
+ auto input_tensor = ov::Tensor{ov::element::f32, shape_input, input_data};
+ auto output_tensor = ov::Tensor{ov::element::f32, shape_output, output_data};
+
+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 0, 0, 0}, {1, 2, 2, 1024});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {0, 0, 2, 0}, {1, 2, 4, 1024});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ req = {};
+ check_out_roi_tensor = {};
+ input_roi_tensor = {};
+ output_roi_tensor = {};
+ input_tensor = {};
+ output_tensor = {};
+
+ ::operator delete(input_data, std::align_val_t(4096));
+ ::operator delete(output_data, std::align_val_t(4096));
+}
+
+TEST_P(RoiTensorsTestsRun, RunWithRemoteTensor) {
+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();
+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 8, 8, 8});
+
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto input_data = static_cast<float*>(input_remote_tensor.get());
+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto output_data = static_cast<float*>(output_remote_tensor.get());
+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor = ov::Tensor(input_remote_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_remote_tensor, {2, 5, 6, 6}, {3, 7, 8, 8});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, MultipleIOCreateRoiTensorFromHostTensorAndRunInfer) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...", 2);
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input0_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto input1_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 12, 15, 8});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+
+ auto* input_data = input0_host_tensor.data<float>();
+ for (size_t i = 0; i < input0_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ input_data = input1_host_tensor.data<float>();
+ for (size_t i = 0; i < input1_host_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input0_roi_tensor = ov::Tensor(input0_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(0, input0_roi_tensor));
+
+ ov::Tensor input1_roi_tensor = ov::Tensor(input1_host_tensor, {1, 5, 7, 6}, {2, 7, 9, 8});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(1, input1_roi_tensor));
+
+ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(0, output_roi_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ auto check_out1_tensor = req.get_output_tensor(1);
+ check_data = check_out1_tensor.data<float>();
+ for (size_t i = 0; i < check_out1_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 76.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBatching) {
+ auto model_shape = PartialShape{-1, 5, 8, 9};
+ auto shape = Shape{2, 5, 8, 9};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+ auto input_strides = input_host_tensor.get_strides();
+ auto output_strides = output_host_tensor.get_strides();
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));
+
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);
+ output_view_tensor.copy_to(check_out_view_tensor);
+ auto* check_data = check_out_view_tensor.data<float>();
+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBoundedBatching) {
+ auto model_shape = PartialShape{ov::Dimension(1, 10), 5, 8, 9};
+ auto shape = Shape{2, 5, 8, 9};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});
+ auto input_strides = input_host_tensor.get_strides();
+ auto output_strides = output_host_tensor.get_strides();
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0 Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));
+
+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);
+ output_view_tensor.copy_to(check_out_view_tensor);
+ auto* check_data = check_out_view_tensor.data<float>();
+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, TryToCompileStridedTensorWithDynamicBoundsExpectedThrow) {
+ auto model_shape = PartialShape{ov::Dimension(1, 10), 5, ov::Dimension(2, 15), 9};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";
+
+ EXPECT_THROW(core->compile_model(model, target_device, configuration), ov::Exception);
+}
+
+TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorUpdateCommandListAndRunInfer) {
+ auto shape = Shape{1, 2, 2, 2};
+ ov::CompiledModel compiled_model;
+ auto model = createModelWithNInputs(element::f32, shape, "N...");
+
+ auto zero_context = core->get_default_context(target_device);
+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});
+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});
+
+ auto* input_data = input_host_tensor.data<float>();
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 50.0f;
+ }
+
+ auto* output_data = output_host_tensor.data<float>();
+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {
+ output_data[i] = 10.0f;
+ }
+
+ configuration[ov::intel_npu::enable_strides_for.name()] = "input0, Result0";
+
+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));
+ ov::InferRequest req;
+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());
+
+ ov::Tensor input_roi_tensor0 = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor0));
+
+ ov::Tensor output_roi_tensor0 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor0));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor0 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor0.copy_to(check_out_roi_tensor0);
+ auto* check_data = check_out_roi_tensor0.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor0.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 51.0f);
+ }
+
+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {
+ input_data[i] = 75.0f;
+ }
+
+ ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {0, 5, 6, 8}, {1, 7, 8, 10});
+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));
+
+ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 2, 19, 13}, {1, 4, 21, 15});
+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));
+
+ OV_ASSERT_NO_THROW(req.infer());
+
+ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);
+ output_roi_tensor1.copy_to(check_out_roi_tensor1);
+ check_data = check_out_roi_tensor1.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 76.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CheckRemoteCopyToWithRoiRemoteTensors) {
+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();
+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});
+
+ auto data = static_cast<float*>(input_remote_tensor.get());
+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {
+ data[i] = 50.0f;
+ }
+
+ data = static_cast<float*>(output_remote_tensor.get());
+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {
+ data[i] = 10.0f;
+ }
+
+ auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});
+ auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});
+
+ input_roi_tensor.copy_to(output_roi_tensor);
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 50.0f);
+ }
+}
+
+TEST_P(RoiTensorsTestsRun, CheckRemoteCopyFromWithRoiRemoteTensors) {
+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();
+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});
+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});
+
+ auto data = static_cast<float*>(input_remote_tensor.get());
+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {
+ data[i] = 50.0f;
+ }
+
+ data = static_cast<float*>(output_remote_tensor.get());
+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {
+ data[i] = 10.0f;
+ }
+
+ auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});
+ auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});
+ output_roi_tensor.copy_from(input_roi_tensor);
+
+ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});
+ output_roi_tensor.copy_to(check_out_roi_tensor);
+ auto* check_data = check_out_roi_tensor.data<float>();
+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {
+ EXPECT_EQ(check_data[i], 50.0f);
+ }
+}
+
+} // namespace behavior
+} // namespace test
+} // namespace ov
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 d26c47db802..ddf00c832e1 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
@@ -833,4 +833,11 @@ Example:
</filters>
</skip_config>
+ <skip_config>
+ <message>Strides are not supported with the current driver</message>
+ <filters>
+ <filter>.*RoiTensorsTestsRun.*</filter>
+ </filters>
+ </skip_config>
+
</skip_configs>