From 676c960cee5b58629c404384e0b8f028ac1dba80 Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:53:07 +0800 Subject: [PATCH] add depthwise conv hip support (#41537) (#41603) --- paddle/phi/kernels/gpudnn/conv_grad_kernel.cu | 40 +++++++++++++++++++ paddle/phi/kernels/gpudnn/conv_kernel.cu | 37 +++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu b/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu index e09c33380b..16f9b64e5d 100644 --- a/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu +++ b/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu @@ -626,6 +626,39 @@ void Conv3DCudnnGradKernel(const Context& dev_ctx, filter_grad); } +template +void DepthwiseConvCudnnGradKernel(const Context& dev_ctx, + const DenseTensor& input, + const DenseTensor& filter, + const DenseTensor& out_grad, + const std::vector& strides, + const std::vector& paddings, + const std::string& paddding_algorithm, + int groups, + const std::vector& dilations, + const std::string& data_format, + bool use_addto, + int workspace_size_MB, + bool exhaustive_search, + DenseTensor* input_grad, + DenseTensor* filter_grad) { + ConvCudnnGradKernel(dev_ctx, + input, + filter, + out_grad, + strides, + paddings, + paddding_algorithm, + groups, + dilations, + data_format, + use_addto, + workspace_size_MB, + exhaustive_search, + input_grad, + filter_grad); +} + } // namespace phi #ifdef PADDLE_WITH_HIP @@ -642,6 +675,13 @@ PD_REGISTER_KERNEL(conv3d_grad, phi::Conv3DCudnnGradKernel, float, phi::dtype::float16) {} + +PD_REGISTER_KERNEL(depthwise_conv2d_grad, + GPUDNN, + ALL_LAYOUT, + phi::DepthwiseConvCudnnGradKernel, + float, + phi::dtype::float16) {} #else #if CUDNN_VERSION_MIN(8, 1, 0) PD_REGISTER_KERNEL(conv2d_grad, diff --git a/paddle/phi/kernels/gpudnn/conv_kernel.cu b/paddle/phi/kernels/gpudnn/conv_kernel.cu index c2970cc8cd..dc594c7a19 100644 --- a/paddle/phi/kernels/gpudnn/conv_kernel.cu +++ b/paddle/phi/kernels/gpudnn/conv_kernel.cu @@ -418,6 +418,35 @@ void Conv3DCudnnKernel(const Context& dev_ctx, out); } +template +void DepthwiseConvCudnnKernel(const Context& dev_ctx, + const DenseTensor& input, + const DenseTensor& filter, + const std::vector& strides, + const std::vector& paddings, + const std::string& padding_algorithm, + int groups, + const std::vector& dilations, + const std::string& data_format, + bool use_addto, + int workspace_size_MB, + bool exhaustive_search, + DenseTensor* out) { + ConvCudnnKernel(dev_ctx, + input, + filter, + strides, + paddings, + padding_algorithm, + groups, + dilations, + data_format, + use_addto, + workspace_size_MB, + exhaustive_search, + out); +} + } // namespace phi #ifdef PADDLE_WITH_HIP @@ -434,6 +463,14 @@ PD_REGISTER_KERNEL(conv3d, phi::Conv3DCudnnKernel, float, phi::dtype::float16) {} + +PD_REGISTER_KERNEL(depthwise_conv2d, + GPUDNN, + ALL_LAYOUT, + phi::DepthwiseConvCudnnKernel, + float, + phi::dtype::float16) {} + #else #if CUDNN_VERSION_MIN(8, 1, 0) PD_REGISTER_KERNEL(conv2d, -- GitLab