From 3c63a0afe9483bd01132654ce24e478f2ff622dd Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Fri, 22 Dec 2023 20:56:59 +0400 Subject: [PATCH] [GPU] Add set_arguments() call in case of dynamic dependencies of static inst (#21664) --- 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 a8a69efe9bb..05ffebae0b1 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -493,7 +493,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; @@ -1116,8 +1116,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();