From 8e67c970b839025d4d6292bb99fbf2eaa60b7aeb Mon Sep 17 00:00:00 2001 From: wjm Date: Sat, 14 Nov 2020 17:35:21 +0800 Subject: [PATCH 1/2] multi batch --- ge/graph/build/memory/block_mem_assigner.cc | 9 +++++++++ ge/graph/preprocess/multi_batch_copy_graph.cc | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 2d30c57e..f89a9c13 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -880,6 +880,15 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, GELOGI("Unreusable block."); continue; } + std::string batch_label; + if (reusable_block->IsSameLabel(batch_label)) { + std::string op_label; + (void)ge::AttrUtils::GerStr(node_op_desc, Attr_NAME_BATCH_LABEL, op_label); + if (batch_label != op_label) { + GELOGI("label diff, op name %s", node_op_desc->GetName().c_str()); + continue; + } + } // A node can reuse blocks of the same stream and preorder streams if (CanReuseBySize(reusable_block_counts_, *reusable_block, block_size, real_size, continuous)) { diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index c0ba89f4..1ea551bf 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -1025,6 +1025,13 @@ Status MultiBatchGraphCopyer::InsertIdentityAfterSwitchN() { } Status ProcessMultiBatch(ComputeGraphPtr &graph) { + const char *multi_batch_with_case = std::getenv("MULTI_BATCH_WITH_CASE"); + if (multi_batch_with_case != nullptr) { + PassManager pass_manager; + GE_CHK_STATUS_RET(pass_manager.AddPass("MultiBatchClonePass", new (std::nothrow) MultiBatchClonePass)); + return pass_manager.Run(graph); + } + std::vector> shapes; if (!InitDynamicParams(shapes)) { GELOGD("There is no multi-batch options, no need to process multi-batch copy"); From a8c720f8e8537018fd0cd78e929547b05e387022 Mon Sep 17 00:00:00 2001 From: wjm Date: Sat, 14 Nov 2020 17:46:08 +0800 Subject: [PATCH 2/2] multi batch --- ge/graph/build/memory/block_mem_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index f89a9c13..cdca7fb7 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -883,7 +883,7 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, std::string batch_label; if (reusable_block->IsSameLabel(batch_label)) { std::string op_label; - (void)ge::AttrUtils::GerStr(node_op_desc, Attr_NAME_BATCH_LABEL, op_label); + (void)ge::AttrUtils::GetStr(node_op_desc, ATTR_NAME_BATCH_LABEL, op_label); if (batch_label != op_label) { GELOGI("label diff, op name %s", node_op_desc->GetName().c_str()); continue;