From 7d948bf596af3a6d0b8e0b2b5d1ad6637b59f630 Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Thu, 28 Dec 2023 14:48:13 +0400 Subject: [PATCH] [GPU] Add set_arguments() call in case of dynamic dependencies of static inst (#21664) (#21884) Co-authored-by: Sergey Shlyapnikov --- src/plugins/intel_gpu/src/graph/primitive_inst.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index 83b7fb730f4..9cf1c457fc0 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -494,7 +494,7 @@ event::ptr primitive_inst::realloc_if_needed() { for (auto user : get_user_insts()) { // Since fake alignment is applicable for input tensor as well, make sure we allocate enough memory // to prevemt reading beyound the allocated memory bounds - if (user->get_node().is_type()) { + if (user->get_node().is_type() && user->is_dynamic()) { user->update_shape(); user->update_shape_done_by_other = true; @@ -1112,8 +1112,14 @@ event::ptr primitive_inst::execute(const std::vector& events) { update_shape_done_by_other = false; // reset OPENVINO_ASSERT(_impl != nullptr, "[GPU] Implementation is nullptr for ", primitive_id, " primitive"); + // Dynamic insts may reallocate its' output buffer, so we need to update kernel's args respectively + bool has_dynamic_dependencies_insts = std::any_of(_deps.begin(), _deps.end(), + [](const std::pair, int32_t>& dep) { + return dep.first->is_dynamic(); + }); + // Output buffer may be changed under the following conditions, so we need to set args to kernel on each iteration - if ((is_dynamic() && need_args_update) || has_mutable_input() || is_output()) { + if ((is_dynamic() && need_args_update) || has_mutable_input() || is_output() || (!is_dynamic() && has_dynamic_dependencies_insts)) { set_arguments(); } on_execute();