diff --git a/paddle/fluid/framework/new_executor/instruction/legacy_kernel_instruction.cc b/paddle/fluid/framework/new_executor/instruction/legacy_kernel_instruction.cc index 8b937ed322efa449319e1da2152054a55828e030..88037b15193d89a86ba2aa9c79df9385687fe127 100644 --- a/paddle/fluid/framework/new_executor/instruction/legacy_kernel_instruction.cc +++ b/paddle/fluid/framework/new_executor/instruction/legacy_kernel_instruction.cc @@ -123,7 +123,7 @@ LegacyKernelInstruction::LegacyKernelInstruction( phi_kernel_ = new phi::Kernel(kernel_result.kernel); PADDLE_ENFORCE_EQ( phi_kernel_->IsValid(), true, "not found kernel for [%s]", kernel_name); - VLOG(6) << "finish process select kernel"; + VLOG(6) << "finish process select kernel: " << kernel_name; Scope* inner_scope = local_scope == nullptr ? scope : local_scope; diff --git a/paddle/fluid/ir/dialect/op_generator/op_gen.py b/paddle/fluid/ir/dialect/op_generator/op_gen.py index 75a025b5fb79eed66977e8aac0a0e6fa5f20d819..87459d7486f3626adff7b9c3a5e957b7b89ee3a6 100644 --- a/paddle/fluid/ir/dialect/op_generator/op_gen.py +++ b/paddle/fluid/ir/dialect/op_generator/op_gen.py @@ -134,7 +134,7 @@ OpInfoTuple {op_name}::GetOpInfo() {{ std::vector outputs = {{ {outputs} }}; paddle::dialect::OpRunTimeInfo run_time_info = paddle::dialect::OpRunTimeInfo("{infer_meta_func}", {{"{infer_meta_param}"}}, {{"{kernel_func}"}}, {{"{kernel_param}"}}, {{"{kernel_key_dtype}"}}, {{{inplace}}}, {{{view}}}); - return std::make_tuple(inputs, attributes, outputs, run_time_info); + return std::make_tuple(inputs, attributes, outputs, run_time_info, "{origin_op_name}"); }} """ CONSTRUCT_INPUT_INFO_TEMPLATE = """paddle::dialect::OpInputInfo("{name}", "{typename}", {optional}, {no_need_buffer}, {is_mutable_attribute})""" @@ -1024,6 +1024,7 @@ def OpGenerator( kernel_key_dtype=kernel_key_dtype, inplace=inplace_str, view=view_str, + origin_op_name=op_info.op_yaml_item['name'], ) # generate op verify function str diff --git a/paddle/fluid/ir/dialect/paddle_dialect/interface/op_yaml_info.h b/paddle/fluid/ir/dialect/paddle_dialect/interface/op_yaml_info.h index 2069d19dd3202543ddbec15d0f6598d8a90b9682..7663fb2029a43bc872a81357c8fa8687c8e318ae 100644 --- a/paddle/fluid/ir/dialect/paddle_dialect/interface/op_yaml_info.h +++ b/paddle/fluid/ir/dialect/paddle_dialect/interface/op_yaml_info.h @@ -20,7 +20,8 @@ using OpInfoTuple = std::tuple, std::vector, std::vector, - paddle::dialect::OpRunTimeInfo>; + paddle::dialect::OpRunTimeInfo, + std::string>; namespace paddle { namespace dialect { diff --git a/paddle/fluid/ir/dialect/paddle_dialect/ir/pd_manual_op.cc b/paddle/fluid/ir/dialect/paddle_dialect/ir/pd_manual_op.cc index 2bcc9045e893b48dcfb35fa790b8b3ce6e9048f3..0c51b98d42fd11497e347bb6419884f6da6a36fc 100644 --- a/paddle/fluid/ir/dialect/paddle_dialect/ir/pd_manual_op.cc +++ b/paddle/fluid/ir/dialect/paddle_dialect/ir/pd_manual_op.cc @@ -41,7 +41,7 @@ OpInfoTuple AddNOp::GetOpInfo() { paddle::dialect::OpRunTimeInfo run_time_info = OpRunTimeInfo("", {""}, {""}, {""}, {""}, {}, {}); - return std::make_tuple(inputs, attributes, outputs, run_time_info); + return std::make_tuple(inputs, attributes, outputs, run_time_info, "add_n"); } void AddNOp::Verify() { diff --git a/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.cc b/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.cc index 4df7140452a8964861fbfdfe752a26b7a609da1b..ebed61bf25484634bd749f10974aa67cc9c475af 100644 --- a/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.cc +++ b/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.cc @@ -187,5 +187,9 @@ void OpYamlInfoParser::parse() { } } +const std::string& OpYamlInfoParser::GetOriginOpName() const { + return std::get<4>(op_info_tuple_); +} + } // namespace dialect } // namespace paddle diff --git a/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.h b/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.h index 939f3f9d0275e806b5176b3e751ee55013fd154e..29d10ecd8cd66048f8252e94958e771f466138e0 100644 --- a/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.h +++ b/paddle/fluid/ir/dialect/paddle_dialect/utils/op_yaml_info_parser.h @@ -57,6 +57,8 @@ class OpYamlInfoParser { const std::string& ViewName(const std::string& out_name) const; + const std::string& GetOriginOpName() const; + private: void parse(); inline const std::vector& InputInfo() const { diff --git a/paddle/fluid/ir/dialect/paddle_dialect/utils/utils.cc b/paddle/fluid/ir/dialect/paddle_dialect/utils/utils.cc index 6b1b16ce36c9a3b05595761db95b2c7eedef4a0c..ab153446fb48140f4a98e2be8c567d7ac4e9678c 100644 --- a/paddle/fluid/ir/dialect/paddle_dialect/utils/utils.cc +++ b/paddle/fluid/ir/dialect/paddle_dialect/utils/utils.cc @@ -18,11 +18,7 @@ namespace paddle { namespace dialect { const std::unordered_set LegacyOpList = { - "pd.fused_softmax_mask_upper_triangle", - "pd.fused_softmax_mask_upper_triangle_grad", - "pd.load_combine", - "pd.c_concat", - "pd.load_combine"}; + "pd.load_combine", "pd.c_concat", "pd.c_broadcast_"}; enum class AttrType { UNDEFINED = 0, diff --git a/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc b/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc index 5cc29e7c38767346c5cbf4dfa4456b15262048e2..456aeae14688500de9843400020b49b7dcaa8a4d 100644 --- a/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc +++ b/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc @@ -80,6 +80,12 @@ void RenameData(ir::Value value, std::map* var_name_2_id) { (*value_2_var_name)[value] = new_name; + for (auto kv : (*value_2_var_name)) { + if (kv.second == orig_name) { + (*value_2_var_name)[kv.first] = new_name; + } + } + for (auto kv : (*variable_2_var_name)) { if (kv.second == orig_name) { (*variable_2_var_name)[kv.first] = new_name; @@ -588,9 +594,7 @@ void BuildRuntimeContext( auto& name2id = op_yaml_info.InputName2Id(); - auto pd_op_name = - op->attributes().at("op_name").dyn_cast().AsString(); - auto fluid_op_name = pd_op_name.substr(3); // pd_op_name start with "pd.xxx" + std::string fluid_op_name = op_yaml_info.GetOriginOpName(); auto& op_normalizer = paddle::translator::OpNameNormalizer::instance(); @@ -621,7 +625,7 @@ void BuildRuntimeContext( ir::Value ptr = op->result(i); auto in_var_name = name_map.at(ptr); - VLOG(6) << "ctx->EmplaceBackInput: " << name << "\t" << in_var_name; + VLOG(6) << "ctx->EmplaceBackOutput: " << name << "\t" << in_var_name; PADDLE_ENFORCE_NOT_NULL(inner_scope->FindVar(in_var_name), phi::errors::PreconditionNotMet( @@ -664,9 +668,7 @@ std::shared_ptr BuildOperatorBase( auto& name2id = op_yaml_info.InputName2Id(); - auto pd_op_name = - op->attributes().at("op_name").dyn_cast().AsString(); - auto fluid_op_name = pd_op_name.substr(3); // pd_op_name start with "pd.xxx" + std::string fluid_op_name = op_yaml_info.GetOriginOpName(); auto& op_normalizer = paddle::translator::OpNameNormalizer::instance(); diff --git a/paddle/fluid/ir_adaptor/translator/op_translator.cc b/paddle/fluid/ir_adaptor/translator/op_translator.cc index 27a06849a0648de9b94fb379fa68323179ab652a..51ca6380634b3ca67e000114a305b49d696c8e76 100644 --- a/paddle/fluid/ir_adaptor/translator/op_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/op_translator.cc @@ -653,7 +653,7 @@ ir::Operation* OpTranscriber::operator()(ir::IrContext* ctx, OpInputInfoList input_infos; OpAttributeInfoList attr_infos; OpOutputInfoList output_infos; - std::tie(input_infos, attr_infos, output_infos, std::ignore) = + std::tie(input_infos, attr_infos, output_infos, std::ignore, std::ignore) = op_info_concept->get_op_info_(); this->InsertSliceOperationForInput( @@ -769,7 +769,7 @@ struct AssignValueOpTranscriber : public OpTranscriber { OpInputInfoList input_infos; OpAttributeInfoList attr_infos; OpOutputInfoList output_infos; - std::tie(input_infos, attr_infos, output_infos, std::ignore) = + std::tie(input_infos, attr_infos, output_infos, std::ignore, std::ignore) = op_info_concept->get_op_info_(); std::unordered_map attr_info_maps; for (auto info : attr_infos) { @@ -1092,7 +1092,7 @@ struct FetchOpTranscriber : public OpTranscriber { OpInputInfoList input_infos; OpAttributeInfoList attr_infos; OpOutputInfoList output_infos; - std::tie(input_infos, attr_infos, output_infos, std::ignore) = + std::tie(input_infos, attr_infos, output_infos, std::ignore, std::ignore) = op_info_concept->get_op_info_(); this->InsertSliceOperationForInput( diff --git a/test/cpp/ir/pattern_rewrite/pattern_rewrite_test.cc b/test/cpp/ir/pattern_rewrite/pattern_rewrite_test.cc index 9d92892053d2b77d7c51bb80b75e1204dac71ebb..9f5e97deda93e4dd86c72aee84495474694184d4 100644 --- a/test/cpp/ir/pattern_rewrite/pattern_rewrite_test.cc +++ b/test/cpp/ir/pattern_rewrite/pattern_rewrite_test.cc @@ -490,7 +490,8 @@ OpInfoTuple Conv2dFusionOpTest::GetOpInfo() { {}, {}); - return std::make_tuple(inputs, attributes, outputs, run_time_info); + return std::make_tuple( + inputs, attributes, outputs, run_time_info, "conv2d_fusion_test"); } void Conv2dFusionOpTest::Build(ir::Builder &builder,