diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index dddba2cd..652977a2 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -2122,10 +2122,10 @@ void GraphMemoryAssigner::CheckNeedCalcDistAndUpdateVisitInfo( void GraphMemoryAssigner::UpdateMemBlockVisitInfo(const NodePtr &update_node, const InDataAnchorPtr &in_data_anchor, - bool need_update_node, + bool is_same_input, size_t matched_mem_offset, map>> &mem_block_visit_info) { - if (need_update_node) { + if (!is_same_input) { mem_block_visit_info[matched_mem_offset].first = node; mem_block_visit_info[matched_mem_offset].second.clear(); } @@ -2143,7 +2143,7 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & auto prev_node = mem_block_visit_info[matched_mem_offset].first; auto prev_node_input_index_vec = mem_block_visit_info[matched_mem_offset].second; GE_IF_BOOL_EXEC(prev_node == nullptr, is_need_skip = true; return); - bool need_update_node = true; + bool is_same_input = false; if (prev_node_input_index_vec.size() == 1 && prev_node_input_index_vec[0] == -1) { // prev_node is producer and the data is just be produced(not visited by other node) GE_IF_BOOL_EXEC(prev_node->GetOpDesc() == nullptr, is_need_skip = true; return); @@ -2173,13 +2173,13 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & } else { distance = prev_next_distances[0]; // use the same prev_distance as previous anchor } - need_update_node = false; + is_same_input = true; } else { distance = node_index_in_stream.at(node->GetName()) - node_index_in_stream.at(prev_node->GetName()) - 1; UpdatePrevNodeInputDesc(prev_node, prev_node_input_index_vec, distance); } } - UpdateMemBlockVisitInfo(node, in_data_anchor, matched_mem_offset, mem_block_visit_info, need_update_node); + UpdateMemBlockVisitInfo(node, in_data_anchor, matched_mem_offset, mem_block_visit_info, is_same_input); UpdateCurNodeInputDesc(node, in_data_anchor->GetIdx(), distance); } diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index f0e8a7e2..bec434e3 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -227,6 +227,7 @@ class GraphMemoryAssigner { void UpdateMemBlockVisitInfo(const NodePtr &update_node, const InDataAnchorPtr &in_data_anchor, + bool is_same_input, size_t matched_mem_offset, map>> &mem_block_visit_info);