From 8a5ab2c0b1fc0dcace123d8efc714244fc901247 Mon Sep 17 00:00:00 2001 From: lichun Date: Thu, 29 Apr 2021 16:49:51 +0800 Subject: [PATCH] mark distance attr --- ge/graph/build/memory/block_mem_assigner.cc | 11 ----------- ge/graph/build/memory/block_mem_assigner.h | 2 -- ge/graph/build/memory/graph_mem_assigner.cc | 30 +++++++++++------------------ ge/graph/build/memory/graph_mem_assigner.h | 4 ---- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 23d53118..926ed30c 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -2160,17 +2160,6 @@ void BlockMemAssigner::SetOpMemOffset(bool is_zero_copy) { } } -size_t BlockMemAssigner::GetAnchorDataOffset(const NodeIndexIO &node_index_io, std::string &symbol) { - MemoryBlock *mem_block = nullptr; - if (IsSymbolExist(node_index_io, symbol)) { - mem_block = symbol_blocks_[symbol]; - if (mem_block != nullptr) { - return mem_block->HeadOffset(); - } - } - return kInvalidOffset; -} - Status BlockMemAssigner::Assign() { vector ranges; if (GetMemoryRanges(ranges) != SUCCESS) { diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h index 7f23cb89..474db17c 100755 --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.h @@ -239,8 +239,6 @@ class BlockMemAssigner : public MemAssigner { void SetOpMemOffset(bool is_zero_copy); std::string GetMaxBatchLabel() const { return max_batch_label_; } - - size_t GetAnchorDataOffset(const NodeIndexIO &node_index_io, std::string &symbol); protected: /// /// @ingroup domi diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index a7a6d48f..94e6f4f7 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -1983,7 +1983,7 @@ void GraphMemoryAssigner::UpdatePrevNodeInputDesc(const NodePtr &prev_node, if (prev_next_distances.size() == kPrevNextDistanceNum) { prev_next_distances[1] = distance; } else { - GELOGW("Size of prev_next_distances is not 2."); + GELOGW("Size of prev_next_distances is not %d.", kPrevNextDistanceNum); continue; } if (!ge::AttrUtils::SetListInt(input_desc, ATTR_NAME_DATA_VISIT_DISTANCE, prev_next_distances)) { @@ -2034,19 +2034,6 @@ void GraphMemoryAssigner::UpdateCurNodeInputDesc(const NodePtr &cur_node, return; } -size_t GraphMemoryAssigner::GetMemoryOffset(const HybridMemAssignerPtr &mem_assigner, - const NodePtr &peer_out_node, - const OutDataAnchorPtr &peer_out_anchor) { - NodeIndexIO node_index_io(peer_out_node, peer_out_anchor->GetIdx(), kOut); - string symbol; - size_t matched_mem_offset = mem_assigner->GetPriorityAssinger()->GetAnchorDataOffset(node_index_io, symbol); - if (matched_mem_offset == kInvalidOffset) { - // peer_out_anchor not assign MemoryBlock, we search the peer_out_anchor's data in continous memory - matched_mem_offset = peer_out_node->GetOpDesc()->GetOutputOffset().at(peer_out_anchor->GetIdx()); - } - return matched_mem_offset; -} - void GraphMemoryAssigner::CheckNeedCalcDistAndUpdateVisitInfo( map>> &mem_block_visit_info, const size_t matched_mem_offset, @@ -2101,10 +2088,13 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(mapGetOpDesc() == nullptr, is_need_skip = true; return); if (prev_node->GetOpDesc()->GetStreamId() == -1) { // producer not assigned a stream distance = 0; - } else if (node_index_in_stream.find(prev_node->GetName()) == node_index_in_stream.end()) { - distance = 0; } else { - distance = node_index_in_stream.at(node->GetName()) - node_index_in_stream.at(prev_node->GetName()) - 1; + auto iter = node_index_in_stream.find(prev_node->GetName()); + if (iter == node_index_in_stream.end()) { + distance = 0; + } else { + 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(); @@ -2125,7 +2115,7 @@ void GraphMemoryAssigner::CalcDistanceAndUpdateDesc(mapGetOpDesc() == nullptr, return); auto input_desc = node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()); bool is_end_of_inputmem_lifecycle = false; // if is_end_of_inputmem_lifecycle is true, indicating that cur node is the last customer of this data, @@ -2177,7 +2168,8 @@ void GraphMemoryAssigner::MarkNodeDistanceAttr(const ComputeGraphPtr &compute_gr auto peer_out_node = peer_out_anchor->GetOwnerNode(); GE_IF_BOOL_EXEC(peer_out_node == nullptr, continue); - auto matched_mem_offset = GetMemoryOffset(mem_assigner_, peer_out_node, peer_out_anchor); + GE_IF_BOOL_EXEC(peer_out_node->GetOpDesc() == nullptr, continue); + auto matched_mem_offset = peer_out_node->GetOpDesc()->GetOutputOffset().at(peer_out_anchor->GetIdx()); bool is_need_calc_distance = false; CheckNeedCalcDistAndUpdateVisitInfo(mem_block_visit_info, matched_mem_offset, peer_out_node, diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index dee0b755..9607841e 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -212,10 +212,6 @@ class GraphMemoryAssigner { void UpdateCurNodeInputDesc(const NodePtr &cur_node, int64_t cur_node_input_index, int64_t distance); - size_t GetMemoryOffset(const HybridMemAssignerPtr &mem_assigner, - const NodePtr &peer_out_node, - const OutDataAnchorPtr &peer_out_anchor); - void CheckNeedCalcDistAndUpdateVisitInfo(map>> &mem_block_visit_info, const size_t matched_mem_offset, const NodePtr &peer_out_node,