From fa43d74a3a16ac696db5dc893c9a7b1c6913dc85 Mon Sep 17 00:00:00 2001 From: wangchaochaohu Date: Mon, 27 Apr 2020 14:25:25 +0800 Subject: [PATCH] fix the intermediate node of graph for fusion group test=develop (#24184) --- .../framework/ir/fusion_group/code_generator.cc | 13 +++++++++---- paddle/fluid/framework/ir/fusion_group/subgraph.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator.cc b/paddle/fluid/framework/ir/fusion_group/code_generator.cc index 438a06f0f9..6555a65c3b 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator.cc @@ -263,12 +263,17 @@ std::string CodeGenerator::EmitParameters( } size_t index = 0; + std::vector output_args; for (auto id : output_ids) { if (intermediate_ids.find(id) == intermediate_ids.end()) { - ret << dtypes.at(id) << "* " << ArgName(id); - if (index != output_ids.size() - 1) { - ret << ", "; - } + std::string args_str = dtypes.at(id) + "* " + ArgName(id); + output_args.push_back(args_str); + } + } + for (auto args : output_args) { + ret << args; + if (index != output_args.size() - 1) { + ret << ", "; } index++; } diff --git a/paddle/fluid/framework/ir/fusion_group/subgraph.h b/paddle/fluid/framework/ir/fusion_group/subgraph.h index 40707b7c8b..66b17e9f6f 100644 --- a/paddle/fluid/framework/ir/fusion_group/subgraph.h +++ b/paddle/fluid/framework/ir/fusion_group/subgraph.h @@ -155,7 +155,7 @@ class SubGraph { if (node->IsOp()) { auto inputs = node->inputs; for (auto* in : inputs) { - if (in == n) { + if (in && in->Name() == n->Name()) { if (!Has(node)) enable_remove = false; leaf_graph = false; } -- GitLab