From 6398a921ac942aae798e9c850f90ae9f323dbad2 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 27 May 2021 14:57:36 +0800 Subject: [PATCH 1/5] fix sc check --- ge/graph/build/memory/graph_mem_assigner.cc | 36 +++++++++++++++-------------- ge/graph/build/memory/graph_mem_assigner.h | 5 ++++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index b098a5f5..dddba2cd 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -2120,6 +2120,18 @@ void GraphMemoryAssigner::CheckNeedCalcDistAndUpdateVisitInfo( return; } +void GraphMemoryAssigner::UpdateMemBlockVisitInfo(const NodePtr &update_node, + const InDataAnchorPtr &in_data_anchor, + bool need_update_node, + size_t matched_mem_offset, + map>> &mem_block_visit_info) { + if (need_update_node) { + mem_block_visit_info[matched_mem_offset].first = node; + mem_block_visit_info[matched_mem_offset].second.clear(); + } + mem_block_visit_info[matched_mem_offset].second.push_back(in_data_anchor->GetIdx()); +} + // calculate distance, update visit info, update prev_node input desc, update cur node input desc void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map &node_index_in_stream, const InDataAnchorPtr &in_data_anchor, @@ -2131,6 +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; 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); @@ -2144,24 +2157,15 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & distance = node_index_in_stream.at(node->GetName()) - iter->second - 1; } } - mem_block_visit_info[matched_mem_offset].first = node; - mem_block_visit_info[matched_mem_offset].second.clear(); - mem_block_visit_info[matched_mem_offset].second.push_back(in_data_anchor->GetIdx()); } else { // the data is visit by other customer just before. - if (prev_node_input_index_vec.empty()) { - GELOGW("Missing prev node[%s] input index.", prev_node->GetName().c_str()); - is_need_skip = true; - return; - } + GE_IF_BOOL_EXEC(prev_node_input_index_vec.empty(), + GELOGW("Miss prev node[%s] input idx"; prev_node->GetName().c_str()); is_need_skip = true; return); if (prev_node == node) { // scene: multiple anchors of a node access the same data vector prev_next_distances; GE_IF_BOOL_EXEC(prev_node->GetOpDesc() == nullptr, is_need_skip = true; return); auto input_desc = prev_node->GetOpDesc()->GetInputDesc(prev_node_input_index_vec[0]); - if (!ge::AttrUtils::GetListInt(input_desc, ATTR_NAME_DATA_VISIT_DISTANCE, prev_next_distances)) { - GELOGW("Get ATTR_NAME_DATA_VISIT_DISTANCE failed."); - is_need_skip = true; - return; - } + GE_IF_BOOL_EXEC(!ge::AttrUtils::GetListInt(input_desc, ATTR_NAME_DATA_VISIT_DISTANCE, prev_next_distances), + GELOGW("Get ATTR_NAME_DATA_VISIT_DISTANCE failed."); is_need_skip = true; return); if (prev_next_distances.size() != kPrevNextDistanceNum) { GELOGW("Size of prev_next_distance is not %d.", kPrevNextDistanceNum); is_need_skip = true; @@ -2169,15 +2173,13 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & } else { distance = prev_next_distances[0]; // use the same prev_distance as previous anchor } - mem_block_visit_info[matched_mem_offset].second.push_back(in_data_anchor->GetIdx()); + need_update_node = false; } 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); - mem_block_visit_info[matched_mem_offset].first = node; - mem_block_visit_info[matched_mem_offset].second.clear(); - mem_block_visit_info[matched_mem_offset].second.push_back(in_data_anchor->GetIdx()); } } + UpdateMemBlockVisitInfo(node, in_data_anchor, matched_mem_offset, mem_block_visit_info, need_update_node); 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 a6a2a686..f0e8a7e2 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -225,6 +225,11 @@ class GraphMemoryAssigner { map>> &mem_block_visit_info, bool &is_need_skip); + void UpdateMemBlockVisitInfo(const NodePtr &update_node, + const InDataAnchorPtr &in_data_anchor, + size_t matched_mem_offset, + map>> &mem_block_visit_info); + void DeleteVisitInfoWhenLifecycleEnded(const NodePtr &node, const InDataAnchorPtr &in_data_anchor, size_t matched_mem_offset, From cbf9a833810a9502bf7af44b32952eb5ff6afb6e Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 27 May 2021 15:57:51 +0800 Subject: [PATCH 2/5] fix sc check --- ge/graph/build/memory/graph_mem_assigner.cc | 10 +++++----- ge/graph/build/memory/graph_mem_assigner.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) 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); From 713e5fa6e62666602d132a6d854891274fd84897 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 27 May 2021 16:55:28 +0800 Subject: [PATCH 3/5] fix sc check --- ge/graph/build/memory/graph_mem_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index 652977a2..190b147b 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -2179,7 +2179,7 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & UpdatePrevNodeInputDesc(prev_node, prev_node_input_index_vec, distance); } } - UpdateMemBlockVisitInfo(node, in_data_anchor, matched_mem_offset, mem_block_visit_info, is_same_input); + UpdateMemBlockVisitInfo(node, in_data_anchor, is_same_input, matched_mem_offset, mem_block_visit_info); UpdateCurNodeInputDesc(node, in_data_anchor->GetIdx(), distance); } From 54c0e9cab94b8c0a194754e3b1aa52c76882fc66 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 27 May 2021 16:57:03 +0800 Subject: [PATCH 4/5] fix sc check --- ge/graph/build/memory/graph_mem_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index 190b147b..a2e30b52 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -2159,7 +2159,7 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(const map & } } else { // the data is visit by other customer just before. GE_IF_BOOL_EXEC(prev_node_input_index_vec.empty(), - GELOGW("Miss prev node[%s] input idx"; prev_node->GetName().c_str()); is_need_skip = true; return); + GELOGW("Miss prev node[%s] input idx", prev_node->GetName().c_str()); is_need_skip = true; return); if (prev_node == node) { // scene: multiple anchors of a node access the same data vector prev_next_distances; GE_IF_BOOL_EXEC(prev_node->GetOpDesc() == nullptr, is_need_skip = true; return); From 51eacef1b0462ca96b560891504d21f87d8db9bf Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 27 May 2021 16:57:54 +0800 Subject: [PATCH 5/5] fix sc check --- ge/graph/build/memory/graph_mem_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index a2e30b52..7b37d4cf 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -2126,7 +2126,7 @@ void GraphMemoryAssigner::UpdateMemBlockVisitInfo(const NodePtr &update_node, size_t matched_mem_offset, map>> &mem_block_visit_info) { if (!is_same_input) { - mem_block_visit_info[matched_mem_offset].first = node; + mem_block_visit_info[matched_mem_offset].first = update_node; mem_block_visit_info[matched_mem_offset].second.clear(); } mem_block_visit_info[matched_mem_offset].second.push_back(in_data_anchor->GetIdx());