From 263f43abe43cd845a0e83e0cee3559701e3f1aa6 Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Mon, 22 Feb 2021 16:16:31 +0800 Subject: [PATCH] modified: ge/graph/passes/no_use_reshape_remove_pass.cc --- ge/graph/passes/no_use_reshape_remove_pass.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index 66a798a5..44f520f0 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -83,10 +83,17 @@ Status NoUseReshapeRemovePass::Run(ge::NodePtr &node) { } if (to_be_deleted) { GELOGI("NoUseReshapeRemovePass remove useless node:%s", node->GetName().c_str()); - auto ret = PassUtils::UnlinkNodeWithControlCopy(node, kReshapeShapeIndex); - if (ret != SUCCESS) { - GELOGE(ret, "DimensionAdjustPass unlink node with control copy fail."); - return ret; + // if shape_input has no any input,which means a single const, it can be unlink from reshape + // op(x) const(shape) + // \ / + // reshape + auto shape_input_anchor = node->GetInDataAnchor(kReshapeShapeIndex); + if (shape_input_anchor != nullptr) { + auto shape_input = shape_input_anchor->GetOwnerNode(); + GE_CHECK_NOTNULL(shape_input); + if (shape_input->GetInAllNodes().empty()) { + shape_input_anchor->UnlinkAll(); + } } return IsolateAndDeleteNode(node, {kReshapeDataIndex}); }