From 693c7629eb948116f9cdf433175f52f7c8951713 Mon Sep 17 00:00:00 2001 From: Qi Li Date: Tue, 13 Apr 2021 12:09:41 +0800 Subject: [PATCH] [ROCM] fix depth conv2d in rocm, test=develop (#32170) --- paddle/fluid/operators/conv_cudnn_op.cu | 9 ++++++++- paddle/fluid/operators/math/depthwise_conv.cu | 3 +-- python/paddle/fluid/layers/nn.py | 4 ++++ python/paddle/fluid/tests/unittests/test_conv2d_op.py | 11 +++++++++++ python/paddle/nn/functional/conv.py | 9 ++++++++- python/paddle/nn/layer/conv.py | 11 +++++++---- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/operators/conv_cudnn_op.cu b/paddle/fluid/operators/conv_cudnn_op.cu index 39e9d37ddc6..ab535e341f7 100644 --- a/paddle/fluid/operators/conv_cudnn_op.cu +++ b/paddle/fluid/operators/conv_cudnn_op.cu @@ -1363,7 +1363,14 @@ REGISTER_OP_KERNEL( conv2d_grad_grad, CUDNN, plat::CUDAPlace, paddle::operators::CUDNNConvDoubleGradOpKernel, paddle::operators::CUDNNConvDoubleGradOpKernel); - +// ROCM has limit thread in depthwise_conv.cu and willl result in accuracy issue +// Use depthwise_conv2d in MIOPEN to resolve this issue +REGISTER_OP_KERNEL(depthwise_conv2d, CUDNN, plat::CUDAPlace, + paddle::operators::CUDNNConvOpKernel, + paddle::operators::CUDNNConvOpKernel); +REGISTER_OP_KERNEL(depthwise_conv2d_grad, CUDNN, plat::CUDAPlace, + paddle::operators::CUDNNConvGradOpKernel, + paddle::operators::CUDNNConvGradOpKernel); REGISTER_OP_CUDA_KERNEL( depthwise_conv2d_grad_grad, paddle::operators::CUDNNConvDoubleGradOpKernel, diff --git a/paddle/fluid/operators/math/depthwise_conv.cu b/paddle/fluid/operators/math/depthwise_conv.cu index 5fd543b5c6c..7c5f59fab0d 100644 --- a/paddle/fluid/operators/math/depthwise_conv.cu +++ b/paddle/fluid/operators/math/depthwise_conv.cu @@ -919,11 +919,10 @@ class DepthwiseConvFunctor