Skip to content

Commit

Permalink
update memory reset condition and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnyoung-paul committed Nov 23, 2024
1 parent 2d828ab commit 37b7f8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/graph/include/primitive_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class primitive_inst {
bool _can_share_buffer = true;
bool _is_constant = false;
bool _needs_completion_event = false;
bool _can_be_optimized_prev = false;
bool _no_execution_prev = false;

std::vector<size_t> _max_output_layout_count;
std::vector<size_t> max_intermediates_memory_sizes;
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/intel_gpu/src/graph/primitive_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,10 @@ void primitive_inst::realloc_if_needed() {
reset_user_output_memory(user_inst, dep_memory_ptr(0));
}
} else {
if (_can_be_optimized_prev) {
if (_outputs[0] && dep_memory_ptr(0)) {
// when this inst was not executed at the previous iteration,
// Reset output memory becuase current output memory is invalid.
if (_no_execution_prev) {
if (_outputs[0]) {
for (auto& user_inst : get_user_insts()) {
reset_user_output_memory(user_inst, _outputs[0]);
}
Expand Down Expand Up @@ -1790,7 +1792,10 @@ void primitive_inst::prepare_primitive() {
}
GPU_DEBUG_TRACE_DETAIL << "-----------------------------------------------------------------" << std::endl;

_can_be_optimized_prev = can_be_optimized();
// If it is optimized out or skipped for zero dimension at the previous iteration,
// Set this flag true to reset output memory in realloc_if_needed.
_no_execution_prev = can_be_optimized()
|| (_impl_params->output_layouts[0].is_static() && _impl_params->output_layouts[0].count() == 0);
const auto orig_outputs = _outputs;
if ((is_dynamic() || _node->is_in_shape_of_subgraph()) && !has_inner_networks()) {
do_runtime_in_place_concat();
Expand Down

0 comments on commit 37b7f8a

Please sign in to comment.