Skip to content

Commit

Permalink
add depthwise conv hip support (#41537)
Browse files Browse the repository at this point in the history
  • Loading branch information
phlrain authored Apr 9, 2022
1 parent 96ced1a commit b3b8d34
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
40 changes: 40 additions & 0 deletions paddle/phi/kernels/gpudnn/conv_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,39 @@ void Conv3DCudnnGradKernel(const Context& dev_ctx,
filter_grad);
}

template <typename T, typename Context>
void DepthwiseConvCudnnGradKernel(const Context& dev_ctx,
const DenseTensor& input,
const DenseTensor& filter,
const DenseTensor& out_grad,
const std::vector<int>& strides,
const std::vector<int>& paddings,
const std::string& paddding_algorithm,
int groups,
const std::vector<int>& dilations,
const std::string& data_format,
bool use_addto,
int workspace_size_MB,
bool exhaustive_search,
DenseTensor* input_grad,
DenseTensor* filter_grad) {
ConvCudnnGradKernel<T>(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
Expand All @@ -643,6 +676,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,
Expand Down
37 changes: 37 additions & 0 deletions paddle/phi/kernels/gpudnn/conv_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,35 @@ void Conv3DCudnnKernel(const Context& dev_ctx,
out);
}

template <typename T, typename Context>
void DepthwiseConvCudnnKernel(const Context& dev_ctx,
const DenseTensor& input,
const DenseTensor& filter,
const std::vector<int>& strides,
const std::vector<int>& paddings,
const std::string& padding_algorithm,
int groups,
const std::vector<int>& dilations,
const std::string& data_format,
bool use_addto,
int workspace_size_MB,
bool exhaustive_search,
DenseTensor* out) {
ConvCudnnKernel<T>(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
Expand All @@ -432,6 +461,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,
Expand Down

0 comments on commit b3b8d34

Please sign in to comment.