Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
693c7629
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
693c7629
编写于
4月 13, 2021
作者:
Q
Qi Li
提交者:
GitHub
4月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ROCM] fix depth conv2d in rocm, test=develop (#32170)
上级
fdf63b4e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
8 deletion
+39
-8
paddle/fluid/operators/conv_cudnn_op.cu
paddle/fluid/operators/conv_cudnn_op.cu
+8
-1
paddle/fluid/operators/math/depthwise_conv.cu
paddle/fluid/operators/math/depthwise_conv.cu
+1
-2
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+4
-0
python/paddle/fluid/tests/unittests/test_conv2d_op.py
python/paddle/fluid/tests/unittests/test_conv2d_op.py
+11
-0
python/paddle/nn/functional/conv.py
python/paddle/nn/functional/conv.py
+8
-1
python/paddle/nn/layer/conv.py
python/paddle/nn/layer/conv.py
+7
-4
未找到文件。
paddle/fluid/operators/conv_cudnn_op.cu
浏览文件 @
693c7629
...
...
@@ -1363,7 +1363,14 @@ REGISTER_OP_KERNEL(
conv2d_grad_grad
,
CUDNN
,
plat
::
CUDAPlace
,
paddle
::
operators
::
CUDNNConvDoubleGradOpKernel
<
float
>
,
paddle
::
operators
::
CUDNNConvDoubleGradOpKernel
<
plat
::
float16
>
);
// 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
<
float
>
,
paddle
::
operators
::
CUDNNConvOpKernel
<
plat
::
float16
>
);
REGISTER_OP_KERNEL
(
depthwise_conv2d_grad
,
CUDNN
,
plat
::
CUDAPlace
,
paddle
::
operators
::
CUDNNConvGradOpKernel
<
float
>
,
paddle
::
operators
::
CUDNNConvGradOpKernel
<
plat
::
float16
>
);
REGISTER_OP_CUDA_KERNEL
(
depthwise_conv2d_grad_grad
,
paddle
::
operators
::
CUDNNConvDoubleGradOpKernel
<
float
>
,
...
...
paddle/fluid/operators/math/depthwise_conv.cu
浏览文件 @
693c7629
...
...
@@ -919,11 +919,10 @@ class DepthwiseConvFunctor<platform::CUDADeviceContext, T,
batch_size
*
output_channels
*
output_height
*
output_width
;
#ifdef __HIPCC__
int
block_size
=
256
;
int
grid_size
=
std
::
min
((
nums_output
+
block_size
-
1
)
/
block_size
,
256
);
#else
int
block_size
=
512
;
int
grid_size
=
(
nums_output
+
block_size
-
1
)
/
block_size
;
#endif
int
grid_size
=
(
nums_output
+
block_size
-
1
)
/
block_size
;
#define check_case(c_filter_multiplier, c_stride, c_filter) \
if (c_filter_multiplier == 0 || \
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
693c7629
...
...
@@ -1524,6 +1524,10 @@ def conv2d(input,
not use_cudnn):
l_type = 'depthwise_conv2d'
if (num_channels == groups and num_filters % num_channels == 0 and
core.is_compiled_with_rocm()):
l_type = 'depthwise_conv2d'
helper = LayerHelper(l_type, **locals())
dtype = helper.input_dtype()
...
...
python/paddle/fluid/tests/unittests/test_conv2d_op.py
浏览文件 @
693c7629
...
...
@@ -1248,6 +1248,17 @@ create_test_cudnn_channel_last_class(TestWithStride_AsyPadding)
create_test_cudnn_channel_last_class
(
TestWithGroup_AsyPadding
)
create_test_cudnn_channel_last_class
(
TestWithDilation_AsyPadding
)
# ------------ depthwise conv2d in MIOPEN ---------
if
core
.
is_compiled_with_rocm
():
create_test_cudnn_padding_SAME_class
(
TestDepthwiseConv_AsyPadding
)
create_test_cudnn_padding_SAME_class
(
TestDepthwiseConvWithDilation_AsyPadding
)
create_test_padding_VALID_class
(
TestDepthwiseConv_AsyPadding
)
create_test_padding_VALID_class
(
TestDepthwiseConvWithDilation_AsyPadding
)
create_test_cudnn_channel_last_class
(
TestDepthwiseConv_AsyPadding
)
create_test_cudnn_channel_last_class
(
TestDepthwiseConvWithDilation2_AsyPadding
)
create_test_cudnn_channel_last_fp16_class
(
TestConv2DOp_AsyPadding
,
grad_check
=
False
)
create_test_cudnn_channel_last_fp16_class
(
...
...
python/paddle/nn/functional/conv.py
浏览文件 @
693c7629
...
...
@@ -25,7 +25,7 @@ __all__ = [
import
numpy
as
np
from
...device
import
get_cudnn_version
from
...fluid.framework
import
Variable
,
in_dygraph_mode
from
...fluid
import
core
,
dygraph_utils
from
...fluid
import
core
,
dygraph_utils
,
get_flags
from
...fluid.layers
import
nn
,
utils
from
...fluid.data_feeder
import
check_variable_and_dtype
from
...fluid.param_attr
import
ParamAttr
...
...
@@ -551,6 +551,13 @@ def conv2d(x,
if
(
num_channels
==
groups
and
num_channels
!=
1
and
num_filters
%
num_channels
==
0
):
l_type
=
'depthwise_conv2d'
if
core
.
is_compiled_with_rocm
():
use_cudnn
=
True
else
:
use_cudnn
=
False
if
(
core
.
is_compiled_with_cuda
()
and
get_flags
(
"FLAGS_conv2d_disable_cudnn"
)
[
"FLAGS_conv2d_disable_cudnn"
]):
use_cudnn
=
False
return
_conv_nd
(
x
,
weight
,
bias
,
stride
,
padding
,
padding_algorithm
,
...
...
python/paddle/nn/layer/conv.py
浏览文件 @
693c7629
...
...
@@ -153,6 +153,13 @@ class _ConvNd(layers.Layer):
in_channels
!=
1
and
out_channels
%
in_channels
==
0
):
self
.
_op_type
=
'depthwise_conv2d'
if
core
.
is_compiled_with_rocm
():
self
.
_use_cudnn
=
True
else
:
self
.
_use_cudnn
=
False
if
(
core
.
is_compiled_with_cuda
()
and
get_flags
(
"FLAGS_conv2d_disable_cudnn"
)[
"FLAGS_conv2d_disable_cudnn"
]):
self
.
_use_cudnn
=
False
def
extra_repr
(
self
):
...
...
@@ -645,10 +652,6 @@ class Conv2D(_ConvNd):
bias_attr
=
bias_attr
,
data_format
=
data_format
)
if
(
core
.
is_compiled_with_cuda
()
and
get_flags
(
"FLAGS_conv2d_disable_cudnn"
)[
"FLAGS_conv2d_disable_cudnn"
]):
self
.
_use_cudnn
=
False
def
forward
(
self
,
x
):
if
self
.
_padding_mode
!=
'zeros'
:
x
=
F
.
pad
(
x
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录