From 04c29558bce3dddaa660f1acefec08b5d5964df1 Mon Sep 17 00:00:00 2001 From: huangjiyi <43315610+huangjiyi@users.noreply.github.com> Date: Tue, 15 Nov 2022 10:11:52 +0800 Subject: [PATCH] [PHI decoupling] remove dependency on "paddle/fluid/operators/elementwise/xxx.h" in phi (#47870) * rm "paddle/fluid/operators/elementwise/xxx.h" in phi * fix bugs * add LaunchElementwiseCudaKernel in phi * Revert "add LaunchElementwiseCudaKernel in phi" This reverts commit 588f45bbdad2372ec7bff0c567a29bff675d22e1. * rm indirect dependence to "elementwise_op_impl.cu.h" rm indirect dependence to "elementwise_op_impl.cu.h" Revert "add LaunchElementwiseCudaKernel in phi" This reverts commit 588f45bbdad2372ec7bff0c567a29bff675d22e1. add LaunchElementwiseCudaKernel in phi fix bugs * rm LaunchSameDimsElementwiseCudaKernel and LaunchElementwiseCudaKernel in phi --- paddle/phi/kernels/gpu/label_smooth_grad_kernel.cu | 5 ++--- paddle/phi/kernels/gpu/label_smooth_kernel.cu | 5 ++--- paddle/phi/kernels/gpu/p_norm_kernel.cu | 2 +- paddle/phi/kernels/gpu/viterbi_decode_kernel.cu | 10 +++++----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/paddle/phi/kernels/gpu/label_smooth_grad_kernel.cu b/paddle/phi/kernels/gpu/label_smooth_grad_kernel.cu index ddf7657fe52..2ac6442967b 100644 --- a/paddle/phi/kernels/gpu/label_smooth_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/label_smooth_grad_kernel.cu @@ -14,9 +14,9 @@ #include "paddle/phi/kernels/label_smooth_grad_kernel.h" -#include "paddle/fluid/operators/elementwise/elementwise_op_impl.cu.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/funcs/elementwise_base.h" namespace phi { template @@ -42,8 +42,7 @@ void LabelSmoothGradKernel(const Context& ctx, std::vector ins = {&out_grad}; std::vector outs = {label_grad}; auto functor = LabelSmoothGradFunctor(epsilon); - paddle::operators::LaunchSameDimsElementwiseCudaKernel( - ctx, ins, &outs, functor); + phi::funcs::ElementwiseKernel(ctx, ins, &outs, functor); } } // namespace phi diff --git a/paddle/phi/kernels/gpu/label_smooth_kernel.cu b/paddle/phi/kernels/gpu/label_smooth_kernel.cu index 4a2f27d3018..ff2fff44451 100644 --- a/paddle/phi/kernels/gpu/label_smooth_kernel.cu +++ b/paddle/phi/kernels/gpu/label_smooth_kernel.cu @@ -16,9 +16,9 @@ #include -#include "paddle/fluid/operators/elementwise/elementwise_op_impl.cu.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/funcs/elementwise_base.h" namespace phi { @@ -77,8 +77,7 @@ void LabelSmoothKernel(const Context& ctx, std::vector ins = {&label}; std::vector outs = {out}; auto functor = LabelSmoothFunctor(epsilon, label_dim); - paddle::operators::LaunchSameDimsElementwiseCudaKernel( - ctx, ins, &outs, functor); + phi::funcs::ElementwiseKernel(ctx, ins, &outs, functor); } } diff --git a/paddle/phi/kernels/gpu/p_norm_kernel.cu b/paddle/phi/kernels/gpu/p_norm_kernel.cu index 80ef97d9cf8..c7a6261ce38 100644 --- a/paddle/phi/kernels/gpu/p_norm_kernel.cu +++ b/paddle/phi/kernels/gpu/p_norm_kernel.cu @@ -14,9 +14,9 @@ #include "paddle/phi/kernels/p_norm_kernel.h" -#include "paddle/fluid/operators/elementwise/elementwise_op_impl.cu.h" #include "paddle/phi/common/amp_type_traits.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/funcs/elementwise_base.h" #include "paddle/phi/kernels/funcs/reduce_function.h" #include "paddle/phi/kernels/gpu/reduce.h" diff --git a/paddle/phi/kernels/gpu/viterbi_decode_kernel.cu b/paddle/phi/kernels/gpu/viterbi_decode_kernel.cu index 31227e59433..b80e9253128 100644 --- a/paddle/phi/kernels/gpu/viterbi_decode_kernel.cu +++ b/paddle/phi/kernels/gpu/viterbi_decode_kernel.cu @@ -30,13 +30,14 @@ namespace cub = hipcub; #include #include -#include "paddle/fluid/operators/elementwise/elementwise_op_function.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/tensor_utils.h" #include "paddle/phi/kernels/empty_kernel.h" +#include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/funcs/compare_functors.h" #include "paddle/phi/kernels/funcs/concat_and_split_functor.h" +#include "paddle/phi/kernels/funcs/elementwise_base.h" #include "paddle/phi/kernels/funcs/elementwise_functor.h" #include "paddle/phi/kernels/funcs/gather.cu.h" #include "paddle/phi/kernels/funcs/viterbi_decode_functor.h" @@ -90,9 +91,8 @@ struct BinaryOperation { DenseTensor* output) { std::vector ins{&lhs, &rhs}; std::vector outs{output}; - paddle::operators:: - LaunchElementwiseCudaKernel( - dev_ctx, ins, &outs, 0, BinaryFunctor()); + phi::funcs::BroadcastKernel( + dev_ctx, ins, &outs, 0, BinaryFunctor()); } }; @@ -107,7 +107,7 @@ struct GetMask { DenseTensor* mask) { std::vector ins = {&lhs, &rhs}; std::vector outs = {mask}; - paddle::operators::LaunchSameDimsElementwiseCudaKernel( + phi::funcs::ElementwiseKernel( dev_ctx, ins, &outs, CompareFunctor()); } }; -- GitLab