From 5c607787315b4b4ed8e4e6c4479e27037411b833 Mon Sep 17 00:00:00 2001 From: wangchaochaohu Date: Fri, 3 Apr 2020 15:07:29 +0800 Subject: [PATCH] polish the code of fusion group test=develop (#23370) --- paddle/fluid/framework/ir/fusion_group/code_generator.cc | 1 + .../framework/ir/fusion_group/code_generator_helper.cc | 8 +------- paddle/fluid/framework/ir/fusion_group/operation.cc | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator.cc b/paddle/fluid/framework/ir/fusion_group/code_generator.cc index 24c3f876b94..fd224de483b 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator.cc @@ -77,6 +77,7 @@ std::vector CodeGenerator::ConvertToExpressions( auto* op = node->Op(); AttributeMap attr = *(op->MutableAttrMap()); + // Input ids should be set in fixed order, like: // - X, Y in forward operations // - X, Y, Out, out@GRAD in backward operations std::vector input_ids; diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc b/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc index 1b8c6b2fdfe..62e226d891f 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc @@ -20,11 +20,6 @@ limitations under the License. */ #include "glog/logging.h" #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/ir/fusion_group/operation.h" -#include "paddle/fluid/framework/op_call_stack.h" -#include "paddle/fluid/framework/op_proto_maker.h" -#include "paddle/fluid/framework/operator.h" -#include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/framework/shape_inference.h" #include "paddle/fluid/framework/var_type_inference.h" namespace paddle { @@ -164,8 +159,7 @@ std::string OperationExpression::GetRHS(std::unordered_set* used, ">. Received %d.", index, op_type_, input_ids_[index])); // TODO(wangchaochaohu): Here fp16 convert to float to do comupte, we - // need - // to add general fp16 compute later. + // need to add general fp16 compute later. std::string var_name; if (rhs_type_ == "float16") { half2fp32_statement->append(OptimzeFP16RHS(used, index, input_ids_)); diff --git a/paddle/fluid/framework/ir/fusion_group/operation.cc b/paddle/fluid/framework/ir/fusion_group/operation.cc index 99ae8be37b9..6c4bb98e1b6 100644 --- a/paddle/fluid/framework/ir/fusion_group/operation.cc +++ b/paddle/fluid/framework/ir/fusion_group/operation.cc @@ -199,7 +199,7 @@ void OperationMap::InsertMultivariateElementwiseOperations() { auto insert_handler_without_input = [&](std::string op_type, std::string expr, std::vector grad_exprs) { int type = 0; - int num_oprands = -1; + int num_oprands = 0; Insert(type, num_oprands, op_type, expr, grad_exprs, {}, {"Out"}); }; // fill_constant: -- GitLab