OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPUW] Extend remote memory check in set_tensor() with sliced tensor case (#32025)
Alexey Smirnove9ab56b01b45
diff --git a/src/plugins/intel_npu/src/plugin/npuw/base_sync_infer_request.cpp b/src/plugins/intel_npu/src/plugin/npuw/base_sync_infer_request.cppindex 5f03015874c..2a9d7cd0ebf 100644--- a/src/plugins/intel_npu/src/plugin/npuw/base_sync_infer_request.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/base_sync_infer_request.cpp@@ -8,6 +8,7 @@#include "intel_npu/config/npuw.hpp"#include "intel_npu/utils/zero/zero_host_tensor.hpp"#include "intel_npu/utils/zero/zero_remote_tensor.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"#include "logging.hpp"#include "openvino/core/parallel.hpp"#include "util.hpp"@@ -191,10 +192,21 @@ void ov::npuw::IBaseInferRequest::handle_set_remote_input(const ov::Output<const// Later in runtime we rely on m_input_allocated to check if the memory is// allocated internally to prevent the copy. Here we need to check if the memory// is properly allocated externally, to prevent runtime copy as well.- if (std::dynamic_pointer_cast<::intel_npu::ZeroRemoteTensor>(tensor._ptr) != nullptr ||- std::dynamic_pointer_cast<::intel_npu::ZeroHostTensor>(tensor._ptr) != nullptr) {- // ZeroRemoteTensor and ZeroHostTensor should guarantee the correct memory allocation- m_input_allocated.insert(tensor->data());+ // Also we can get a strided remote tensor. In this case the copy cannot be avoided for now.+ if (m_npuw_model->global_mem_device() == "NPU") {+ auto remote_ctx =+ m_npuw_model->get_plugin()->get_core()->get_default_context(m_npuw_model->global_mem_device())._ptr;+ auto zrh = remote_ctx->get_property().at(ov::intel_npu::l0_context.name());+ if (::intel_npu::zeroUtils::memory_was_allocated_in_the_same_l0_context(+ static_cast<ze_context_handle_t>(zrh.as<void*>()),+ tensor->data())) {+ if (tensor->is_continuous()) {+ m_input_allocated.insert(tensor->data());+ } else {+ LOG_WARN("Strided remote tensor is not supported on the device! Expect worse performance due "+ "to CPU runtime copy.");+ }+ }}}}