From 2e67c3d45ad82c71799dd1a52d91186de4c5d255 Mon Sep 17 00:00:00 2001 From: lianghao Date: Fri, 8 Jan 2021 17:14:04 +0800 Subject: [PATCH] _zero_copy_identity_reserved --- ge/graph/optimize/mem_rw_conflict_optimize.cc | 6 ++++++ ge/graph/passes/subgraph_pass.cc | 1 + 2 files changed, 7 insertions(+) diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index 3c3419ae..31e9683c 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -688,6 +688,12 @@ Status GraphOptimize::HandleMemoryRWConflict(ComputeGraphPtr &compute_graph) { if (node->GetType() == NETOUTPUT && AttrUtils::HasAttr(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX)) { continue; } + bool identity_reserved = false; + AttrUtils::GetBool(node->GetOpDesc(), "_zero_copy_identity_reserved", identity_reserved); + if (identity_reserved) { + GELOGD("Identity [%s] need to be reserved.", node->GetName().c_str()); + continue; + } if (node->GetType() == IDENTITY || node->GetType() == READVARIABLEOP) { // split identity ret = SplitIdentity(node); diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc index fd71e65b..31c83945 100644 --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -443,6 +443,7 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) .Build(); (void)AttrUtils::SetBool(op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false); + (void)AttrUtils::SetBool(op_desc, "_zero_copy_identity_reserved", true); if (GraphUtils::InsertNodeAfter(out_anchor, in_anchors, graph->AddNode(op_desc)) != GRAPH_SUCCESS) { GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str()); return FAILED;