diff --git a/paddle/phi/kernels/compare_kernel.h b/paddle/phi/kernels/compare_kernel.h index 958bb85e4ceae2cba95ec645247ab29162f44752..20fb6164f3811619a247f4f3d4730f77c08ab017 100644 --- a/paddle/phi/kernels/compare_kernel.h +++ b/paddle/phi/kernels/compare_kernel.h @@ -39,12 +39,12 @@ DECALRE_COMPARE_KERNEL(Equal) DECALRE_COMPARE_KERNEL(NotEqual) #undef DECALRE_COMPARE_KERNEL -#define DECALRE_COMPARE_ALL_KERNEL(compare_all_kernel) \ - template \ - void compare_all_kernel(const Context& ctx, \ - const DenseTensor& x, \ - const DenseTensor& y, \ - DenseTensor* out); +#define DECALRE_COMPARE_ALL_KERNEL(compare_all) \ + template \ + void compare_all##Kernel(const Context& ctx, \ + const DenseTensor& x, \ + const DenseTensor& y, \ + DenseTensor* out); DECALRE_COMPARE_ALL_KERNEL(EqualAll) #undef DECALRE_COMPARE_KERNEL diff --git a/paddle/phi/kernels/cpu/box_coder.cc b/paddle/phi/kernels/cpu/box_coder_kernel.cc similarity index 100% rename from paddle/phi/kernels/cpu/box_coder.cc rename to paddle/phi/kernels/cpu/box_coder_kernel.cc diff --git a/paddle/phi/kernels/eig_grad_kernel.h b/paddle/phi/kernels/eig_grad_kernel.h index 93ae707f6f95f3f3ae43c8a232edcda3d6b3c37b..539337eed14ed1eff636c384f6e375d002434dba 100644 --- a/paddle/phi/kernels/eig_grad_kernel.h +++ b/paddle/phi/kernels/eig_grad_kernel.h @@ -19,7 +19,7 @@ namespace phi { template -void EigGardKernel(const Context& dev_ctx, +void EigGradKernel(const Context& dev_ctx, const DenseTensor& out_w, const DenseTensor& out_v, const DenseTensor& dout_w, diff --git a/paddle/phi/kernels/eigh_grad_kernel.h b/paddle/phi/kernels/eigh_grad_kernel.h index 73df76e676a8b4a7eee570f466f9e94f619c5443..0fe323d2e453836febb030f3fd666e816404bb7b 100644 --- a/paddle/phi/kernels/eigh_grad_kernel.h +++ b/paddle/phi/kernels/eigh_grad_kernel.h @@ -19,7 +19,7 @@ namespace phi { template -void EighGardKernel(const Context& dev_ctx, +void EighGradKernel(const Context& dev_ctx, const DenseTensor& out_w, const DenseTensor& out_v, const DenseTensor& dout_w, diff --git a/paddle/phi/kernels/gather_nd_grad_kernel.h b/paddle/phi/kernels/gather_nd_grad_kernel.h index 050034714957fe749d6608243dfedc4d30d66e88..0aa7924c0aa336651ec8a9ecf395b2bf8bf0fa9f 100644 --- a/paddle/phi/kernels/gather_nd_grad_kernel.h +++ b/paddle/phi/kernels/gather_nd_grad_kernel.h @@ -19,7 +19,7 @@ namespace phi { template -void GatherGradNdKernel(const Context &ctx, +void GatherNdGradKernel(const Context &ctx, const DenseTensor &x, const DenseTensor &index, const DenseTensor &out_grad, diff --git a/paddle/phi/kernels/gpu/box_coder.cu b/paddle/phi/kernels/gpu/box_coder_kernel.cu similarity index 100% rename from paddle/phi/kernels/gpu/box_coder.cu rename to paddle/phi/kernels/gpu/box_coder_kernel.cu diff --git a/paddle/phi/kernels/interpolate_grad_kernel.h b/paddle/phi/kernels/interpolate_grad_kernel.h index b8eefad61a7689000f89f6e6433629a69861c232..32e902d9f77079daadd6d8a57f014916378fba5c 100644 --- a/paddle/phi/kernels/interpolate_grad_kernel.h +++ b/paddle/phi/kernels/interpolate_grad_kernel.h @@ -36,4 +36,76 @@ void BilinearInterpGradKernel( int align_mode, DenseTensor* x_grad); +template +void LinearInterpGradKernel( + const Context& dev_ctx, + const DenseTensor& x, + const paddle::optional& out_size, + const paddle::optional>& size_tensor, + const paddle::optional& scale_tensor, + const DenseTensor& out_grad, + const std::string& data_layout, + int out_d, + int out_h, + int out_w, + const std::vector& scale, + const std::string& interp_method, + bool align_corners, + int align_mode, + DenseTensor* x_grad); + +template +void TrilinearInterpGradKernel( + const Context& dev_ctx, + const DenseTensor& x, + const paddle::optional& out_size, + const paddle::optional>& size_tensor, + const paddle::optional& scale_tensor, + const DenseTensor& out_grad, + const std::string& data_layout, + int out_d, + int out_h, + int out_w, + const std::vector& scale, + const std::string& interp_method, + bool align_corners, + int align_mode, + DenseTensor* x_grad); + +template +void NearestInterpGradKernel( + const Context& dev_ctx, + const DenseTensor& x, + const paddle::optional& out_size, + const paddle::optional>& size_tensor, + const paddle::optional& scale_tensor, + const DenseTensor& out_grad, + const std::string& data_layout, + int out_d, + int out_h, + int out_w, + const std::vector& scale, + const std::string& interp_method, + bool align_corners, + int align_mode, + DenseTensor* x_grad); + +template +void BicubicInterpGradKernel( + const Context& dev_ctx, + const DenseTensor& x, + const paddle::optional& out_size, + const paddle::optional>& size_tensor, + const paddle::optional& scale_tensor, + const DenseTensor& out_grad, + const std::string& data_layout, + int out_d, + int out_h, + int out_w, + const std::vector& scale, + const std::string& interp_method, + bool align_corners, + int align_mode, + DenseTensor* x_grad); + } // namespace phi diff --git a/paddle/phi/kernels/sparse/unary_grad_kernel.h b/paddle/phi/kernels/sparse/unary_grad_kernel.h index b446e1b99ed411ff748f6cd5d2369f440d52c0f9..88bf0e9002501a2bb7af6fe669f2668f0ac674f6 100644 --- a/paddle/phi/kernels/sparse/unary_grad_kernel.h +++ b/paddle/phi/kernels/sparse/unary_grad_kernel.h @@ -61,7 +61,10 @@ DECLARE_SPARSE_UNARY_GRAD_KERNEL(Square) DECLARE_SPARSE_UNARY_GRAD_KERNEL(Sqrt) DECLARE_SPARSE_UNARY_GRAD_KERNEL(Log1p) DECLARE_SPARSE_UNARY_GRAD_KERNEL(Abs) +DECLARE_SPARSE_UNARY_GRAD_KERNEL(Expm1) DECLARE_SPARSE_UNARY_GRAD_KERNEL_WITH_ONE_ATTR(Pow, factor) +DECLARE_SPARSE_UNARY_GRAD_KERNEL_WITH_ONE_ATTR(LeakyRelu, alpha) +DECLARE_SPARSE_UNARY_GRAD_KERNEL_WITH_ONE_ATTR(Relu6, threshold) template void CastCooGradKernel(const Context& dev_ctx, diff --git a/paddle/phi/kernels/sparse/unary_kernel.h b/paddle/phi/kernels/sparse/unary_kernel.h index a7d54c1ffe19c5da119220ed7350da8662f609a4..90c52504ecb3ef188e2385363b7b38b581220a04 100644 --- a/paddle/phi/kernels/sparse/unary_kernel.h +++ b/paddle/phi/kernels/sparse/unary_kernel.h @@ -57,7 +57,20 @@ DECLARE_SPARSE_UNARY_KERNEL(Square) DECLARE_SPARSE_UNARY_KERNEL(Sqrt) DECLARE_SPARSE_UNARY_KERNEL(Log1p) DECLARE_SPARSE_UNARY_KERNEL(Abs) +DECLARE_SPARSE_UNARY_KERNEL(Expm1) DECLARE_SPARSE_UNARY_KERNEL_WITH_ONE_ATTR(Pow, factor) +DECLARE_SPARSE_UNARY_KERNEL_WITH_ONE_ATTR(Relu6Raw, threshold) +DECLARE_SPARSE_UNARY_KERNEL_WITH_ONE_ATTR(LeakyRelu, alpha) + +template +void Relu6CooKernel(const Context& dev_ctx, + const SparseCooTensor& x, + SparseCooTensor* out); + +template +void Relu6CsrKernel(const Context& dev_ctx, + const SparseCsrTensor& x, + SparseCsrTensor* out); template void ScaleCooKernel(const Context& dev_ctx, diff --git a/paddle/phi/kernels/spectral_norm_grad_kernel.h b/paddle/phi/kernels/spectral_norm_grad_kernel.h index 504cfba4b95e766fcc349b69637e00ade372e434..1333151facf353624867630bfa21a89638ca9f8e 100644 --- a/paddle/phi/kernels/spectral_norm_grad_kernel.h +++ b/paddle/phi/kernels/spectral_norm_grad_kernel.h @@ -16,7 +16,7 @@ limitations under the License. */ namespace phi { template -void SpectrumNormGradKernel(const Context& dev_ctx, +void SpectralNormGradKernel(const Context& dev_ctx, const DenseTensor& weight, const DenseTensor& u, const DenseTensor& v, diff --git a/paddle/phi/kernels/spectral_norm_kernel.h b/paddle/phi/kernels/spectral_norm_kernel.h index 26b1699898ea6e09bf1700617aebfc341daefa0d..e99c2993e9d5326d82ce6e27c42d644306c5fe98 100644 --- a/paddle/phi/kernels/spectral_norm_kernel.h +++ b/paddle/phi/kernels/spectral_norm_kernel.h @@ -16,7 +16,7 @@ limitations under the License. */ namespace phi { template -void SpectrumNormKernel(const Context& dev_ctx, +void SpectralNormKernel(const Context& dev_ctx, const DenseTensor& weight, const DenseTensor& u, const DenseTensor& v,