|
|
@@ -318,7 +318,11 @@ void MemoryBlock::AddDependLifeBegin(DependStreamLife &total_node_depend_stream_ |
|
|
|
AddDependLife(node, node, stream_id_, depend_stream_life_, total_node_depend_stream_life); |
|
|
|
} |
|
|
|
} |
|
|
|
depend_stream_life_[stream_id_] = GetLifeBegin(); |
|
|
|
|
|
|
|
// not same stream can't be reused by life time directly, should be reused by dependence |
|
|
|
if (same_stream_) { |
|
|
|
depend_stream_life_[stream_id_] = GetLifeBegin(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
size_t MemoryBlock::GetLifeEnd() { |
|
|
@@ -1130,15 +1134,21 @@ bool IsKnownSubgraphData(const NodePtr &node) { |
|
|
|
return node->GetOpDesc()->HasAttr(ATTR_NAME_PARENT_NODE_INDEX); |
|
|
|
} |
|
|
|
|
|
|
|
void BlockMemAssigner::ReleaseMemory(MemoryBlock *to_release, vector<MemoryBlock *> &reusable_memory) { |
|
|
|
void BlockMemAssigner::ReleaseMemory(MemoryBlock *to_release, vector<MemoryBlock *> &reusable_memory, |
|
|
|
bool same_stream) { |
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(to_release == nullptr, return, "Input parameter to_release is null."); |
|
|
|
GE_CHK_TRUE_EXEC_INFO(to_release->ref_count_ <= 0, return, "Release memory"); |
|
|
|
GE_CHK_TRUE_EXEC_INFO(!to_release->reuse_mem_, return, "doesn't reuse memory"); |
|
|
|
--to_release->ref_count_; |
|
|
|
if (!same_stream) { |
|
|
|
to_release->same_stream_ = false; |
|
|
|
} |
|
|
|
if (to_release->ref_count_ == 0) { |
|
|
|
to_release->SetLifeTimeEnd(life_time_); |
|
|
|
reusable_memory.emplace_back(to_release); |
|
|
|
AddReusableBlockCount(*to_release, reusable_block_counts_); |
|
|
|
if (to_release->same_stream_) { |
|
|
|
reusable_memory.emplace_back(to_release); |
|
|
|
AddReusableBlockCount(*to_release, reusable_block_counts_); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -1178,10 +1188,9 @@ void BlockMemAssigner::ReleaseInputNodeOutMemory(const unordered_map<string, vec |
|
|
|
node_type_indexs.back().node->GetName().c_str()); |
|
|
|
|
|
|
|
if ((node_type_indexs.back().node == in_anchor->GetPeerOutAnchor()->GetOwnerNode()) && |
|
|
|
(node_type_indexs.back().index == static_cast<uint32_t>(in_anchor->GetPeerOutAnchor()->GetIdx())) && |
|
|
|
(node->GetOpDesc()->GetStreamId() == block->stream_id_)) { |
|
|
|
ReleaseMemory(block, reusable_memory); |
|
|
|
if (block->ref_count_ == 0) { |
|
|
|
(node_type_indexs.back().index == static_cast<uint32_t>(in_anchor->GetPeerOutAnchor()->GetIdx()))) { |
|
|
|
ReleaseMemory(block, reusable_memory, (node->GetOpDesc()->GetStreamId() == block->stream_id_)); |
|
|
|
if (block->ref_count_ == 0 && block->same_stream_) { |
|
|
|
SetLastUsedInputMemAttr(node, in_anchor->GetIdx()); |
|
|
|
} |
|
|
|
} |
|
|
@@ -1701,10 +1710,10 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, |
|
|
|
op_desc->SetWorkspace(workspace_list); |
|
|
|
} |
|
|
|
GELOGI("[IMAS]Set %s name[%s] %s[%u] offset to [%ld] streamid[%ld] size[%zu] realsize[%zu]" |
|
|
|
" noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d] isref[%d].", graph_name.c_str(), |
|
|
|
" noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d:%d] isref[%d].", graph_name.c_str(), |
|
|
|
op_desc->GetName().c_str(), node_type.GetMemType().c_str(), node_type.index, offset, op_desc->GetStreamId(), |
|
|
|
block->Size(), real_size, no_align_size, op_desc->GetId(), end, child_block, block->reuse_mem_, |
|
|
|
block->continuous_block_, block->deleted_block_, node_type.ref_input); |
|
|
|
block->continuous_block_, block->deleted_block_, block->same_stream_, node_type.ref_input); |
|
|
|
} |
|
|
|
|
|
|
|
void SetBlockOpMemOffset(MemoryBlock *block, bool child_block) { |
|
|
|