From 7257cd0e0bf16d8b79c60fee9d8bd6cfb29a2d1e Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Fri, 10 Nov 2023 13:37:42 +0400 Subject: [PATCH] [GPU] Cleanup buffer optimization code --- src/plugins/intel_gpu/src/graph/crop.cpp | 12 +----------- .../intel_gpu/src/graph/include/crop_inst.h | 2 -- .../intel_gpu/src/graph/include/permute_inst.h | 1 - .../intel_gpu/src/graph/include/reorder_inst.h | 1 - .../intel_gpu/src/graph/include/reshape_inst.h | 2 -- .../graph/include/scatter_elements_update_inst.h | 1 - .../src/graph/include/scatter_nd_update_inst.h | 1 - .../src/graph/include/scatter_update_inst.h | 1 - src/plugins/intel_gpu/src/graph/permute.cpp | 10 ++-------- src/plugins/intel_gpu/src/graph/reorder.cpp | 8 +------- src/plugins/intel_gpu/src/graph/reshape.cpp | 14 ++------------ .../src/graph/scatter_elements_update.cpp | 6 +----- .../intel_gpu/src/graph/scatter_nd_update.cpp | 6 +----- src/plugins/intel_gpu/src/graph/scatter_update.cpp | 6 +----- 14 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/crop.cpp b/src/plugins/intel_gpu/src/graph/crop.cpp index 13d81321281061..99d738258824f0 100644 --- a/src/plugins/intel_gpu/src/graph/crop.cpp +++ b/src/plugins/intel_gpu/src/graph/crop.cpp @@ -240,21 +240,11 @@ crop_inst::typed_primitive_inst(network& network, crop_node const& node) : paren if (node.can_be_optimized()) { build_deps(); - reuse_input(); + update_output_memory(); } } void crop_inst::on_execute() { - if (!can_be_optimized()) - return; - - if (_outputs[0] && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) - return; - - reuse_input(); -} - -void crop_inst::reuse_input() { update_output_memory(); } diff --git a/src/plugins/intel_gpu/src/graph/include/crop_inst.h b/src/plugins/intel_gpu/src/graph/include/crop_inst.h index 1be2e9e89e67af..e0d59917d0eb91 100644 --- a/src/plugins/intel_gpu/src/graph/include/crop_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/crop_inst.h @@ -58,8 +58,6 @@ class typed_primitive_inst : public typed_primitive_inst_base { private: void on_execute() override; - - void reuse_input(); }; using crop_inst = typed_primitive_inst; diff --git a/src/plugins/intel_gpu/src/graph/include/permute_inst.h b/src/plugins/intel_gpu/src/graph/include/permute_inst.h index f5ba4dacb933f0..12a571cc36009f 100644 --- a/src/plugins/intel_gpu/src/graph/include/permute_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/permute_inst.h @@ -71,7 +71,6 @@ class typed_primitive_inst : public typed_primitive_inst_base private: void on_execute() override; - void reuse_input(); }; using permute_inst = typed_primitive_inst; diff --git a/src/plugins/intel_gpu/src/graph/include/reorder_inst.h b/src/plugins/intel_gpu/src/graph/include/reorder_inst.h index 00e48ec8715929..75020ad070b15e 100644 --- a/src/plugins/intel_gpu/src/graph/include/reorder_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/reorder_inst.h @@ -108,7 +108,6 @@ class typed_primitive_inst : public typed_primitive_inst_base private: void on_execute() override; - void reuse_input(); bool _req_reinterpr = false; }; diff --git a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h b/src/plugins/intel_gpu/src/graph/include/reshape_inst.h index c49a1f6cb0dde7..20b8dced0b9369 100644 --- a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/reshape_inst.h @@ -111,8 +111,6 @@ class typed_primitive_inst : public typed_primitive_inst_base private: void on_execute() override; - - void reuse_input(); }; using reshape_inst = typed_primitive_inst; diff --git a/src/plugins/intel_gpu/src/graph/include/scatter_elements_update_inst.h b/src/plugins/intel_gpu/src/graph/include/scatter_elements_update_inst.h index c8d332124af1fd..0489a1e3bfdd5f 100644 --- a/src/plugins/intel_gpu/src/graph/include/scatter_elements_update_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/scatter_elements_update_inst.h @@ -26,7 +26,6 @@ class typed_primitive_inst : public typed_primitive_ins private: void on_execute() override; - void reuse_input(); }; using scatter_elements_update_inst = typed_primitive_inst; diff --git a/src/plugins/intel_gpu/src/graph/include/scatter_nd_update_inst.h b/src/plugins/intel_gpu/src/graph/include/scatter_nd_update_inst.h index 4d4a12f9df2ed9..26a0ed6571e14f 100644 --- a/src/plugins/intel_gpu/src/graph/include/scatter_nd_update_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/scatter_nd_update_inst.h @@ -28,7 +28,6 @@ class typed_primitive_inst : public typed_primitive_inst_base private: void on_execute() override; - void reuse_input(); }; using scatter_nd_update_inst = typed_primitive_inst; diff --git a/src/plugins/intel_gpu/src/graph/include/scatter_update_inst.h b/src/plugins/intel_gpu/src/graph/include/scatter_update_inst.h index 61f872724438f8..1a19f0c30c350e 100644 --- a/src/plugins/intel_gpu/src/graph/include/scatter_update_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/scatter_update_inst.h @@ -41,7 +41,6 @@ class typed_primitive_inst : public typed_primitive_inst_base; diff --git a/src/plugins/intel_gpu/src/graph/permute.cpp b/src/plugins/intel_gpu/src/graph/permute.cpp index ea4f6e507f1b89..55469130573e31 100644 --- a/src/plugins/intel_gpu/src/graph/permute.cpp +++ b/src/plugins/intel_gpu/src/graph/permute.cpp @@ -118,20 +118,14 @@ permute_inst::typed_primitive_inst(network& network, permute_node const& node) : CLDNN_ERROR_MESSAGE(node.id(), "Permute order does not contain all of required values."); } - if (node.can_be_optimized()) { - reuse_input(); - } + update_output_memory(); } void permute_inst::on_execute() { - if (can_be_optimized()) - reuse_input(); -} - -void permute_inst::reuse_input() { update_output_memory(); } + void permute_inst::update_output_memory() { if (!can_be_optimized()) return; diff --git a/src/plugins/intel_gpu/src/graph/reorder.cpp b/src/plugins/intel_gpu/src/graph/reorder.cpp index 9f5bb6615325c9..82bfe576ddf944 100644 --- a/src/plugins/intel_gpu/src/graph/reorder.cpp +++ b/src/plugins/intel_gpu/src/graph/reorder.cpp @@ -219,8 +219,7 @@ reorder_inst::typed_primitive_inst(network& network, reorder_node const& node) : parent(network, node, !node.can_be_optimized() && (node.get_output_layout().is_static() || node.get_output_layout().has_upper_bound())) , _req_reinterpr(node.requires_reinterpret()) { - if (node.can_be_optimized()) - reuse_input(); + update_output_memory(); if (is_dynamic()) return; @@ -256,11 +255,6 @@ reorder_inst::typed_primitive_inst(network& network, reorder_node const& node) : } void reorder_inst::on_execute() { - if (can_be_optimized()) - reuse_input(); -} - -void reorder_inst::reuse_input() { update_output_memory(); } diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cpp index ecfd4a471194e6..0c463f13e56a7e 100644 --- a/src/plugins/intel_gpu/src/graph/reshape.cpp +++ b/src/plugins/intel_gpu/src/graph/reshape.cpp @@ -182,25 +182,15 @@ reshape_inst::typed_primitive_inst(network& network, reshape_node const& node) : _outputs = allocate_outputs(); _mem_allocated = true; } else { - reuse_input(); + update_output_memory(); } } else { if (_exec_deps.size() > 0 && input_memory_ptr()) - reuse_input(); + update_output_memory(); } } void reshape_inst::on_execute() { - if (!can_be_optimized()) - return; - - if (_outputs[0] && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) - return; - - reuse_input(); -} - -void reshape_inst::reuse_input() { update_output_memory(); } diff --git a/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp index 6ae1a83447c98c..c11b754658d031 100644 --- a/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp +++ b/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp @@ -59,11 +59,7 @@ void scatter_elements_update_inst::on_execute() { auto input2_shape = _impl_params->input_layouts[2].get_partial_shape(); if ((ov::shape_size(input1_shape.to_shape()) == 0) || (ov::shape_size(input2_shape.to_shape()) == 0)) - reuse_input(); -} - -void scatter_elements_update_inst::reuse_input() { - update_output_memory(); + update_output_memory(); } void scatter_elements_update_inst::update_output_memory() { diff --git a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp index 0f64b64a0bcad7..155d3ef53cdb14 100644 --- a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp +++ b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp @@ -72,11 +72,7 @@ void scatter_nd_update_inst::on_execute() { auto same_layouts = _impl_params->input_layouts[0] == _impl_params->output_layouts[0]; if (same_layouts && ((ov::shape_size(input1_shape.to_shape()) == 0) || (ov::shape_size(input2_shape.to_shape()) == 0))) - reuse_input(); -} - -void scatter_nd_update_inst::reuse_input() { - update_output_memory(); + update_output_memory(); } void scatter_nd_update_inst::update_output_memory() { diff --git a/src/plugins/intel_gpu/src/graph/scatter_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_update.cpp index 157a0dd54f3b6a..66247dbfe15150 100644 --- a/src/plugins/intel_gpu/src/graph/scatter_update.cpp +++ b/src/plugins/intel_gpu/src/graph/scatter_update.cpp @@ -51,11 +51,7 @@ void scatter_update_inst::on_execute() { auto input2_shape = _impl_params->input_layouts[2].get_partial_shape(); if ((ov::shape_size(input1_shape.to_shape()) == 0) || (ov::shape_size(input2_shape.to_shape()) == 0)) - reuse_input(); -} - -void scatter_update_inst::reuse_input() { - update_output_memory(); + update_output_memory(); } void scatter_update_inst::update_output_memory() {