From dff8d5f8d392855e34249e872a795ea223fd4d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=B6=9B?= Date: Thu, 1 Apr 2021 20:55:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!1427=20?= =?UTF-8?q?:=20add=20netoutput=20always'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ge/graph/passes/net_output_pass.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index 100e73cd..b203438e 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -40,7 +40,6 @@ static std::map output_type_str_to_datatype = { // the size of user defined output datatype or format string after split by ":". const size_t kUserDefinedElementCount = 2; -const size_t kNodesCount = 2; Status NetOutputPass::GetRetvalOutputInfo(const ge::NodePtr &node, std::map &retval_node_index_map) { @@ -425,13 +424,11 @@ Status NetOutputPass::AddCtrlEdgesBetweenLeafAndNetOutput(const ge::ComputeGraph GELOGI("No need to add ctrl edge to netoutput because user out nodes have been set."); return SUCCESS; } - bool graph_has_only_one_node_except_netoutput = (graph->GetDirectNodesSize() == kNodesCount); for (const auto &node : graph->GetDirectNode()) { if (node == nullptr || node->GetOpDesc() == nullptr || node->GetOpDesc()->GetType() == NETOUTPUT) { continue; } - if ((node->GetInControlNodes().size() != 0 || node->GetInDataNodes().size() != 0 || - graph_has_only_one_node_except_netoutput) && + if ((node->GetInControlNodes().size() != 0 || node->GetInDataNodes().size() != 0) && node->GetOutDataNodesSize() == 0 && node->GetOutControlNodes().size() == 0) { GE_CHK_STATUS_RET(GraphUtils::AddEdge(node->GetOutControlAnchor(), net_out_node->GetInControlAnchor()), "add edge failed"); @@ -496,13 +493,10 @@ Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph, } GELOGI("[NETOUTPUT PASS] OutNodesInfo size:%zu, Targets Size:%zu, is_include_special_node_:%d", graph->GetGraphOutNodesInfo().size(), graph->GetGraphTargetNodesInfo().size(), is_include_special_node_); - // If user does not set out nodes and targets and no retval node, also add netoutput node + // If user does not set out nodes and targets and no retval node, return false if ((graph->GetGraphOutNodesInfo().empty()) && (graph->GetGraphTargetNodesInfo().empty()) && !is_include_special_node_) { - GELOGI("[NETOUTPUT PASS] output_nodes and target_nodes and special nodes is empty!Add netoutput!"); - output_node = graph->AddNode(net_output_desc); - GE_CHK_STATUS_RET(AddCtrlEdgesBetweenLeafAndNetOutput(graph, output_node), - "add ctrl edge between leaf and netoutput failed"); + GELOGI("[NETOUTPUT PASS] output_nodes and target_nodes and special nodes is empty!It means no need netoutput!"); return SUCCESS; } GELOGI("[NETOUTPUT PASS] Output node size:%lu.", output_nodes_info.size());