Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix depthwise conv bug #41537

Merged
merged 2 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -626,6 +626,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 @@ -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,
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 @@ -418,6 +418,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 @@ -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,
Expand Down