From 2265d63c606d3652386b9521179dbf5ab5ef46d5 Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Mon, 31 Jul 2023 18:16:26 +0800 Subject: [PATCH] [NewIR]fix new ir shadow typo (#55706) * fix new ir shadow typo * update --- paddle/fluid/framework/executor_cache.cc | 4 ++-- .../interpreter/interpreter_util.cc | 2 +- paddle/fluid/ir/dialect/pd_op.yaml | 4 ++-- .../ir/phi_kernel_adaptor/phi_kernel_util.cc | 6 ++--- .../ir/transforms/pd_op_to_kernel_pass.cc | 22 +++++++++---------- .../ir_adaptor/translator/op_translator.cc | 4 ++-- paddle/phi/api/yaml/op_compat.yaml | 4 ++++ paddle/phi/api/yaml/ops.yaml | 4 ++-- .../phi/kernels/cpu/feed_with_place_kernel.cc | 13 ++++++----- paddle/phi/kernels/feed_with_place_kernel.h | 12 +++++----- .../phi/kernels/gpu/feed_with_place_kernel.cu | 4 ++-- .../phi/kernels/impl/feed_with_place_impl.h | 6 ++--- 12 files changed, 45 insertions(+), 40 deletions(-) diff --git a/paddle/fluid/framework/executor_cache.cc b/paddle/fluid/framework/executor_cache.cc index 506ce36e472..bb079937329 100644 --- a/paddle/fluid/framework/executor_cache.cc +++ b/paddle/fluid/framework/executor_cache.cc @@ -402,7 +402,7 @@ std::unique_ptr<::ir::Program> ConstructFowardIrProgram( } auto op_desc = local_program.MutableBlock(0)->AppendOp(); - op_desc->SetType("shaddow_output"); + op_desc->SetType("shadow_output"); op_desc->SetAttr("name", name); op_desc->SetInput("x", {name}); op_desc->SetOutput("out", {"@EMPTY@"}); @@ -458,7 +458,7 @@ std::unique_ptr<::ir::Program> ConstructBackwardIrProgram( continue; } auto op_desc = local_program.MutableBlock(0)->AppendOp(); - op_desc->SetType("shaddow_output"); + op_desc->SetType("shadow_output"); op_desc->SetAttr("name", name); op_desc->SetInput("x", {name}); op_desc->SetOutput("out", {"@EMPTY@"}); diff --git a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc index 66c09760fff..c03d57c5f39 100644 --- a/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc +++ b/paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc @@ -980,7 +980,7 @@ void BuildOpFuncList( if (op_name == "builtin.combine" || op_name == "pd.feed" || op_name == "builtin.set_parameter" || op_name == "builtin.get_parameter" || op_name == "builtin.slice" || - op_name == "pd.feed_with_place" || op_name == "pd.shaddow_output") { + op_name == "pd.feed_with_place" || op_name == "pd.shadow_output") { VLOG(6) << "skip process " << op_name; continue; } diff --git a/paddle/fluid/ir/dialect/pd_op.yaml b/paddle/fluid/ir/dialect/pd_op.yaml index 9b113c02cf9..5796cea48b1 100644 --- a/paddle/fluid/ir/dialect/pd_op.yaml +++ b/paddle/fluid/ir/dialect/pd_op.yaml @@ -277,7 +277,7 @@ backward: null -- name: shaddow_feed +- name: shadow_feed inputs: - typename: Tensor name: x @@ -293,7 +293,7 @@ func: UnchangedInferMeta param: [x] kernel: - func: [shaddow_feed] + func: [shadow_feed] param: [x] backend: null layout: null 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 0388ee9791a..d78a1291b15 100644 --- a/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc +++ b/paddle/fluid/ir/phi_kernel_adaptor/phi_kernel_util.cc @@ -278,8 +278,8 @@ void HandleForSpecialOp( (*value_2_var_name)[value] = param_name; } - if (op_name == "pd.shaddow_output") { - VLOG(6) << "Handle for pd.shaddow_ouptut"; + if (op_name == "pd.shadow_output") { + VLOG(6) << "Handle for pd.shadow_ouptut"; auto var_name = op->attributes().at("name").dyn_cast().AsString(); @@ -408,7 +408,7 @@ void BuildScope(const ir::Block& block, if (op_name == "pd.feed" || op_name == "pd.fetch" || op_name == "builtin.combine" || op_name == "builtin.set_parameter" || op_name == "builtin.get_parameter" || op_name == "builtin.slice" || - op_name == "pd.feed_with_place" || op_name == "pd.shaddow_output") { + op_name == "pd.feed_with_place" || op_name == "pd.shadow_output") { HandleForSpecialOp(op, inner_scope, var_name_prefix, diff --git a/paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc b/paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc index 15bc6d7c3d0..f85192bada6 100644 --- a/paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc +++ b/paddle/fluid/ir/transforms/pd_op_to_kernel_pass.cc @@ -437,30 +437,30 @@ std::unique_ptr PdOpLowerToKernelPass(ir::Program* prog, program->block()->push_back(op); if ((*it)->name() == "pd.feed" && platform::is_gpu_place(place)) { - // add shaddow feed op - phi::KernelKey shaddow_key{ + // add shadow feed op + phi::KernelKey shadow_key{ phi::Backend::GPU, phi::DataLayout::ANY, TransToPhiDataType( (*it)->result(0).type().dyn_cast().dtype())}; std::unordered_map attr_map{ - {"op_name", ir::StrAttribute::get(ctx, "pd.shaddow_feed")}, - {"kernel_name", ir::StrAttribute::get(ctx, "shaddow_feed")}, - {"kernel_key", dialect::KernelAttribute::get(ctx, shaddow_key)}}; + {"op_name", ir::StrAttribute::get(ctx, "pd.shadow_feed")}, + {"kernel_name", ir::StrAttribute::get(ctx, "shadow_feed")}, + {"kernel_key", dialect::KernelAttribute::get(ctx, shadow_key)}}; auto out_type = paddle::dialect::AllocatedDenseTensorType::get( ctx, - phi::TransToPhiPlace(shaddow_key.backend()), + phi::TransToPhiPlace(shadow_key.backend()), (*it)->result(0).type().dyn_cast()); - ir::Operation* shaddow_op = + ir::Operation* shadow_op = ir::Operation::Create({op->result(0)}, attr_map, {out_type}, op_info); - map_op_pair[*it] = shaddow_op; - program->block()->push_back(shaddow_op); + map_op_pair[*it] = shadow_op; + program->block()->push_back(shadow_op); if ((*it)->num_results() > 0) { - for (size_t i = 0; i < shaddow_op->num_results(); ++i) { - map_value_pair[(*it)->result(i)] = shaddow_op->result(i); + for (size_t i = 0; i < shadow_op->num_results(); ++i) { + map_value_pair[(*it)->result(i)] = shadow_op->result(i); } } } diff --git a/paddle/fluid/ir_adaptor/translator/op_translator.cc b/paddle/fluid/ir_adaptor/translator/op_translator.cc index 497b002f41e..5b03badf25f 100644 --- a/paddle/fluid/ir_adaptor/translator/op_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/op_translator.cc @@ -1136,7 +1136,7 @@ struct FetchOpTranscriber : public OpTranscriber { } }; -struct ShaddowOutputOpTranscriber : public OpTranscriber { +struct ShadowOutputOpTranscriber : public OpTranscriber { ir::Operation* operator()(ir::IrContext* ctx, TranslationContext* param_map, const OpDesc& op_desc, @@ -1463,7 +1463,7 @@ OpTranslator::OpTranslator() { special_handlers["reduce_all"] = ReduceOpTranscriber(); special_handlers["reduce_any"] = ReduceOpTranscriber(); special_handlers["rnn"] = RnnOpTranscriber(); - special_handlers["shaddow_output"] = ShaddowOutputOpTranscriber(); + special_handlers["shadow_output"] = ShadowOutputOpTranscriber(); special_handlers["split"] = SplitOpTranscriber(); special_handlers["sum"] = AddNOpTranscriber(); diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index 2a4cb3e5259..c566a371957 100755 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -2412,6 +2412,10 @@ extra : attrs : [bool use_mkldnn=false] +- op : shadow_output + inputs: {x: x} + outputs: {out: out} + - op : shape inputs : input : Input diff --git a/paddle/phi/api/yaml/ops.yaml b/paddle/phi/api/yaml/ops.yaml index 167e19a0fb9..78cbd7c6518 100644 --- a/paddle/phi/api/yaml/ops.yaml +++ b/paddle/phi/api/yaml/ops.yaml @@ -2256,14 +2256,14 @@ optional : master_param, master_param_out inplace : (param -> param_out), (master_param -> master_param_out) -- op : shaddow_output +- op : shadow_output args : (Tensor x, str name) output : Tensor(out) infer_meta : func : UnchangedInferMeta param : [x] kernel: - func : shaddow_output + func : shadow_output param : [x] - op : shape diff --git a/paddle/phi/kernels/cpu/feed_with_place_kernel.cc b/paddle/phi/kernels/cpu/feed_with_place_kernel.cc index ce346472821..aaafeb00d0f 100644 --- a/paddle/phi/kernels/cpu/feed_with_place_kernel.cc +++ b/paddle/phi/kernels/cpu/feed_with_place_kernel.cc @@ -27,18 +27,19 @@ void FeedWithPlaceKernel(const Context& ctx, DenseTensor* out) {} template -void ShaddowOutputKernel(const Context& ctx, - const DenseTensor& x, - DenseTensor* out) {} +void ShadowOutputKernel(const Context& ctx, + const DenseTensor& x, + DenseTensor* out) {} + } // namespace phi PD_REGISTER_KERNEL( feed_with_place, CPU, ALL_LAYOUT, phi::FeedWithPlaceKernel, float) {} -PD_REGISTER_KERNEL(shaddow_feed, +PD_REGISTER_KERNEL(shadow_feed, CPU, ALL_LAYOUT, - phi::ShaddowFeedKernel, + phi::ShadowFeedKernel, bool, float, int32_t, @@ -50,4 +51,4 @@ PD_REGISTER_KERNEL(shaddow_feed, phi::complex128) {} PD_REGISTER_KERNEL( - shaddow_output, CPU, ALL_LAYOUT, phi::ShaddowOutputKernel, float) {} + shadow_output, CPU, ALL_LAYOUT, phi::ShadowOutputKernel, float) {} diff --git a/paddle/phi/kernels/feed_with_place_kernel.h b/paddle/phi/kernels/feed_with_place_kernel.h index 725ec0c508a..1d173797fd8 100644 --- a/paddle/phi/kernels/feed_with_place_kernel.h +++ b/paddle/phi/kernels/feed_with_place_kernel.h @@ -26,13 +26,13 @@ void FeedWithPlaceKernel(const Context& ctx, DenseTensor* out); template -void ShaddowOutputKernel(const Context& ctx, - const DenseTensor& x, - DenseTensor* out); +void ShadowOutputKernel(const Context& ctx, + const DenseTensor& x, + DenseTensor* out); template -void ShaddowFeedKernel(const Context& ctx, - const DenseTensor& x, - DenseTensor* out); +void ShadowFeedKernel(const Context& ctx, + const DenseTensor& x, + DenseTensor* out); } // namespace phi diff --git a/paddle/phi/kernels/gpu/feed_with_place_kernel.cu b/paddle/phi/kernels/gpu/feed_with_place_kernel.cu index 07d4c8719da..f848ff0c2b1 100644 --- a/paddle/phi/kernels/gpu/feed_with_place_kernel.cu +++ b/paddle/phi/kernels/gpu/feed_with_place_kernel.cu @@ -18,10 +18,10 @@ #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/feed_with_place_impl.h" -PD_REGISTER_KERNEL(shaddow_feed, +PD_REGISTER_KERNEL(shadow_feed, GPU, ALL_LAYOUT, - phi::ShaddowFeedKernel, + phi::ShadowFeedKernel, bool, float, int32_t, diff --git a/paddle/phi/kernels/impl/feed_with_place_impl.h b/paddle/phi/kernels/impl/feed_with_place_impl.h index a7602c2d379..269c4c886df 100644 --- a/paddle/phi/kernels/impl/feed_with_place_impl.h +++ b/paddle/phi/kernels/impl/feed_with_place_impl.h @@ -20,9 +20,9 @@ namespace phi { template -void ShaddowFeedKernel(const Context& ctx, - const DenseTensor& x, - DenseTensor* out) { +void ShadowFeedKernel(const Context& ctx, + const DenseTensor& x, + DenseTensor* out) { ctx.template Alloc(out); if (x.place() == out->place()) { out->ShareDataWith(x); -- GitLab