From ab99634e97b1d27ea60af385586a11719eeb4fbb Mon Sep 17 00:00:00 2001 From: Steve Yoo Date: Mon, 4 Mar 2024 10:23:32 +0000 Subject: [PATCH] Run build_deps before update_output_memory (#22845) --- src/plugins/intel_gpu/src/graph/network.cpp | 3 ++- src/plugins/intel_gpu/src/graph/reshape.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/network.cpp b/src/plugins/intel_gpu/src/graph/network.cpp index f13bdd917d83eb..f878a187887a26 100644 --- a/src/plugins/intel_gpu/src/graph/network.cpp +++ b/src/plugins/intel_gpu/src/graph/network.cpp @@ -763,7 +763,8 @@ void network::allocate_primitives() { if (!node->get_dependencies().empty() && opt_inst->dependencies().empty()) { opt_inst->build_deps(); } - opt_inst->update_output_memory(); + if (opt_inst->input_memory_ptr()) + opt_inst->update_output_memory(); } } diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cpp index ccfba9e8cb0c92..97ce70419ea09c 100644 --- a/src/plugins/intel_gpu/src/graph/reshape.cpp +++ b/src/plugins/intel_gpu/src/graph/reshape.cpp @@ -187,16 +187,22 @@ reshape_inst::typed_primitive_inst(network& network, reshape_node const& node) : _outputs = allocate_outputs(); _mem_allocated = true; } else { - update_output_memory(); + build_deps(); // reshape need deps + if (input_memory_ptr()) + update_output_memory(); } } else { - if (_exec_deps.size() > 0 && input_memory_ptr()) + if (_exec_deps.size() > 0 && input_memory_ptr()) { + build_deps(); // reshape need deps update_output_memory(); + } } } void reshape_inst::on_execute() { - update_output_memory(); + build_deps(); // reshape need deps + if (input_memory_ptr()) + update_output_memory(); } void reshape_inst::update_output_memory() { @@ -206,10 +212,6 @@ void reshape_inst::update_output_memory() { if (_outputs[0] && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) return; - build_deps(); // reshape need deps - if (node->get_program().get_config().get_property(ov::intel_gpu::allow_new_shape_infer) && - input_memory_ptr() == nullptr) - return; OPENVINO_ASSERT(input_memory_ptr() != nullptr, "[GPU] Failed to reuse input in ", id(), " primitive: input memory was not allocated"); _outputs = {_network.get_engine().reinterpret_buffer(input_memory(), _impl_params->get_output_layout())}; }