From ccbc14c920a80d64ce2f3c78214e9d568d2dc33e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 28 Dec 2020 19:09:42 +0800 Subject: [PATCH] block_mem_assigner comment modify --- ge/graph/build/memory/block_mem_assigner.cc | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 493f08b5..3acd4a7f 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -1081,32 +1081,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, return block; } -bool IsOutputIndexRef(const OpDescPtr &op_desc, uint32_t index) { - auto output_tensor = op_desc->GetOutputDescPtr(index); - bool dst_reuse_input = false; - (void)ge::TensorUtils::GetReuseInput(*output_tensor, dst_reuse_input); - if (dst_reuse_input) { - return true; - } - - bool is_ref = false; - (void)ge::AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); - if (is_ref) { - string output_name = op_desc->GetOutputNameByIndex(index); - for (const auto &input_name : op_desc->GetAllInputNames()) { - if (output_name == input_name) { - return true;; - } - } - } - return false; -} - void BlockMemAssigner::ContinuousOutRefCheck(bool &isAllOutputRef, bool &isOutputHasRef, const NodePtr &n) { const auto node_op_desc = n->GetOpDesc(); for (uint32_t index = 0; index < static_cast(node_op_desc->GetOutputsSize()); index++) { - if (!IsOutputIndexRef(node_op_desc, index)) { + int32_t reuse_in_index = -1; + if (!GraphUtils::IsRefFromInput(n->GetOutDataAnchor(index), reuse_in_index)) { isAllOutputRef = false; break; } else { @@ -1224,7 +1204,8 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, block->ref_count_++; } else { // if ref input is variable, can not find symbol, must judge alone - if (IsOutputIndexRef(node_op_desc, index)) { + int32_t reuse_in_index = -1; + if (GraphUtils::IsRefFromInput(n->GetOutDataAnchor(index), reuse_in_index)) { zero_memory_list_.emplace_back(n, kOutput, index, false); GELOGI("ref mode skip out block assign. node_name: %s, index:%d", n->GetName().c_str(), index); return nullptr;