Skip to content

Commit

Permalink
[GPU] Cleanup buffer optimization code
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-paramuzov committed Nov 20, 2023
1 parent dddc85f commit 7257cd0
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 62 deletions.
12 changes: 1 addition & 11 deletions src/plugins/intel_gpu/src/graph/crop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/intel_gpu/src/graph/include/crop_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class typed_primitive_inst<crop> : public typed_primitive_inst_base<crop> {

private:
void on_execute() override;

void reuse_input();
};

using crop_inst = typed_primitive_inst<crop>;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/intel_gpu/src/graph/include/permute_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class typed_primitive_inst<permute> : public typed_primitive_inst_base<permute>

private:
void on_execute() override;
void reuse_input();
};

using permute_inst = typed_primitive_inst<permute>;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/intel_gpu/src/graph/include/reorder_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class typed_primitive_inst<reorder> : public typed_primitive_inst_base<reorder>

private:
void on_execute() override;
void reuse_input();

bool _req_reinterpr = false;
};
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/intel_gpu/src/graph/include/reshape_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ class typed_primitive_inst<reshape> : public typed_primitive_inst_base<reshape>

private:
void on_execute() override;

void reuse_input();
};

using reshape_inst = typed_primitive_inst<reshape>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class typed_primitive_inst<scatter_elements_update> : public typed_primitive_ins

private:
void on_execute() override;
void reuse_input();
};

using scatter_elements_update_inst = typed_primitive_inst<scatter_elements_update>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class typed_primitive_inst<scatter_nd_update> : public typed_primitive_inst_base

private:
void on_execute() override;
void reuse_input();
};

using scatter_nd_update_inst = typed_primitive_inst<scatter_nd_update>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class typed_primitive_inst<scatter_update> : public typed_primitive_inst_base<sc

private:
void on_execute() override;
void reuse_input();
};

using scatter_update_inst = typed_primitive_inst<scatter_update>;
Expand Down
10 changes: 2 additions & 8 deletions src/plugins/intel_gpu/src/graph/permute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/intel_gpu/src/graph/reorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
14 changes: 2 additions & 12 deletions src/plugins/intel_gpu/src/graph/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
6 changes: 1 addition & 5 deletions src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/intel_gpu/src/graph/scatter_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7257cd0

Please sign in to comment.