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
[NPU] Fix dynamic models regressions (#31583)
Daria Mityaginad6727a7b8733
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.cppindex b62c6527c40..5929c5e7a85 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@@ -385,32 +385,35 @@ void ZeroInferRequest::set_tensor(const ov::Output<const ov::Node>& port, const_logger.debug("ZeroInferRequest::set_tensor - got the same tensor, do nothing");return;}- // Check if batch has been changed- if (get_user_input(foundPort.idx) != nullptr) {- _logger.debug(- "ZeroInferRequest::set_tensor - check if input tensors may have their sizes changed, existing: %zu and "- "count: %zu, new: %zu - to determine whether we need for pipeline reallocation",- get_user_input(foundPort.idx)->get_byte_size(),- get_user_inputs(foundPort.idx).size(),- tensor->get_byte_size());- if (get_user_input(foundPort.idx)->get_byte_size() * get_user_inputs(foundPort.idx).size() !=- tensor->get_byte_size()) {- _pipelineNeedsReallocation = true;- }- }std::vector<ov::SoPtr<ov::ITensor>> tensorVector = {tensor};_graph->reset_last_batch_size();auto batchSizeCandidate =_graph->get_batch_size(_metadata, tensorVector, _graphInputDescriptors.at(foundPort.idx));- if (is_batched_input(foundPort.idx) || batchSizeCandidate.has_value()) {++ // Check if batch has been changed+ if (batchSizeCandidate.has_value()) {+ if (get_user_input(foundPort.idx) != nullptr) {+ _logger.debug("ZeroInferRequest::set_tensor - check if input tensors may have their sizes changed, "+ "existing: %zu and "+ "count: %zu, new: %zu - to determine whether we need for pipeline reallocation",+ get_user_input(foundPort.idx)->get_byte_size(),+ get_user_inputs(foundPort.idx).size(),+ tensor->get_byte_size());+ if (get_user_input(foundPort.idx)->get_byte_size() * get_user_inputs(foundPort.idx).size() !=+ tensor->get_byte_size()) {+ _pipelineNeedsReallocation = true;+ }+ }+ _graph->set_batch_size(batchSizeCandidate.has_value() ? batchSizeCandidate.value() : DEFAULT_BATCH_SIZE);+ }++ if (is_batched_input(foundPort.idx)) {// resize vector size to 1 if set_tensor is called after set_tensorsget_level_zero_inputs(foundPort.idx).resize(1);get_level_zero_inputs(foundPort.idx).shrink_to_fit();get_user_inputs(foundPort.idx).resize(1);get_user_inputs(foundPort.idx).shrink_to_fit();-- _graph->set_batch_size(batchSizeCandidate.has_value() ? batchSizeCandidate.value() : DEFAULT_BATCH_SIZE);}get_user_input(foundPort.idx) = tensor;@@ -838,7 +841,7 @@ void ZeroInferRequest::infer_async() {OPENVINO_THROW("Empty buffer");}- _logger.info(+ _logger.debug("Batched Tensors - Tensor by index: %zu is not allocated in the current Level Zero ""context, copy bytes from user tensor: %zu, into L0 with expected size: %zu",inputIndex,@@ -852,11 +855,11 @@ void ZeroInferRequest::infer_async() {} else {void* levelZeroBuffer = get_level_zero_input(inputIndex)->data();- _logger.info("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",- inputIndex,- get_level_zero_input(inputIndex)->get_byte_size());+ _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",+ inputIndex,+ 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);diff --git a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cppindex 1a535aafc26..4ecdee49af9 100644--- a/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp+++ b/src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp@@ -36,9 +36,9 @@ Pipeline::Pipeline(const Config& config,_graph->resize_last_submitted_event(_number_of_command_lists);}- _logger.info("Pipeline - initialize started, batch %i, number_of_command_lists %i",- batch,- _number_of_command_lists);+ _logger.debug("Pipeline - initialize started, batch %i, number_of_command_lists %i",+ batch,+ _number_of_command_lists);OPENVINO_ASSERT(_sync_output_with_fences || !_config.get<RUN_INFERENCES_SEQUENTIALLY>() ||_init_structs->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1),