Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
4bafbf41
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4bafbf41
编写于
5月 23, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable groups for conv3d transpose op
上级
adbf97b4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
14 deletion
+59
-14
paddle/fluid/operators/conv_transpose_op.cc
paddle/fluid/operators/conv_transpose_op.cc
+5
-1
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
+54
-13
未找到文件。
paddle/fluid/operators/conv_transpose_op.cc
浏览文件 @
4bafbf41
...
...
@@ -50,7 +50,7 @@ void ConvTransposeOp::InferShape(framework::InferShapeContext* ctx) const {
"dimension should be the same."
);
PADDLE_ENFORCE_EQ
(
in_dims
[
1
],
filter_dims
[
0
],
"In ConvTransposeOp, The number of input channels should "
"be equal to the number of filter' channels."
);
"be equal to the number of filter'
s
channels."
);
std
::
vector
<
int64_t
>
output_shape
({
in_dims
[
0
],
filter_dims
[
1
]
*
groups
});
for
(
size_t
i
=
0
;
i
<
strides
.
size
();
++
i
)
{
...
...
@@ -208,6 +208,10 @@ void Conv3DTransposeOpMaker::Make() {
"(vector<int> default:{0, 0, 0}), paddings(d_pad, "
"h_pad, w_pad) of convolution transpose operator."
)
.
SetDefault
({
0
,
0
,
0
});
AddAttr
<
int
>
(
"groups"
,
"(int default:1), the groups number of the convolution3d "
"transpose operator. "
)
.
SetDefault
(
1
);
AddAttr
<
bool
>
(
"use_cudnn"
,
"(bool, default false) Only used in cudnn kernel, need install cudnn"
)
...
...
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
浏览文件 @
4bafbf41
...
...
@@ -21,8 +21,11 @@ from op_test import OpTest
def
conv3dtranspose_forward_naive
(
input_
,
filter_
,
attrs
):
in_n
,
in_c
,
in_d
,
in_h
,
in_w
=
input_
.
shape
f_c
,
out_c
,
f_d
,
f_h
,
f_w
=
filter_
.
shape
f_c
,
f_out_c
,
f_d
,
f_h
,
f_w
=
filter_
.
shape
groups
=
attrs
[
'groups'
]
assert
in_c
==
f_c
out_c
=
f_out_c
*
groups
sub_in_c
=
in_c
/
groups
stride
,
pad
,
dilations
=
attrs
[
'strides'
],
attrs
[
'paddings'
],
attrs
[
'dilations'
]
...
...
@@ -39,18 +42,23 @@ def conv3dtranspose_forward_naive(input_, filter_, attrs):
for
d
in
range
(
in_d
):
for
i
in
range
(
in_h
):
for
j
in
range
(
in_w
):
input_masked
=
input_
[
n
,
:,
d
,
i
,
j
]
# (c)
input_masked
=
np
.
reshape
(
input_masked
,
(
in_c
,
1
,
1
,
1
))
input_masked
=
np
.
tile
(
input_masked
,
(
1
,
f_d
,
f_h
,
f_w
))
for
k
in
range
(
out_c
):
tmp_out
=
np
.
sum
(
input_masked
*
filter_
[:,
k
,
:,
:,
:],
axis
=
0
)
d1
,
d2
=
d
*
stride
[
0
],
d
*
stride
[
0
]
+
d_bolck_d
i1
,
i2
=
i
*
stride
[
1
],
i
*
stride
[
1
]
+
d_bolck_h
j1
,
j2
=
j
*
stride
[
2
],
j
*
stride
[
2
]
+
d_bolck_w
out
[
n
,
k
,
d1
:
d2
:
dilations
[
0
],
i1
:
i2
:
dilations
[
1
],
j1
:
j2
:
dilations
[
2
]]
+=
tmp_out
for
g
in
range
(
groups
):
input_masked
=
input_
[
n
,
g
*
sub_in_c
:(
g
+
1
)
*
sub_in_c
,
d
,
i
,
j
]
# (c)
input_masked
=
np
.
reshape
(
input_masked
,
(
sub_in_c
,
1
,
1
,
1
))
input_masked
=
np
.
tile
(
input_masked
,
(
1
,
f_d
,
f_h
,
f_w
))
for
k
in
range
(
f_out_c
):
tmp_out
=
np
.
sum
(
input_masked
*
filter_
[
g
*
sub_in_c
:(
g
+
1
)
*
sub_in_c
,
k
,
:,
:,
:],
axis
=
0
)
d1
,
d2
=
d
*
stride
[
0
],
d
*
stride
[
0
]
+
d_bolck_d
i1
,
i2
=
i
*
stride
[
1
],
i
*
stride
[
1
]
+
d_bolck_h
j1
,
j2
=
j
*
stride
[
2
],
j
*
stride
[
2
]
+
d_bolck_w
out
[
n
,
g
*
f_out_c
+
k
,
d1
:
d2
:
dilations
[
0
],
i1
:
i2
:
dilations
[
1
],
j1
:
j2
:
dilations
[
2
]]
+=
tmp_out
out
=
out
[:,
:,
pad
[
0
]:
out_d
-
pad
[
0
],
pad
[
1
]:
out_h
-
pad
[
1
],
pad
[
2
]:
out_w
-
pad
[
2
]]
...
...
@@ -72,6 +80,7 @@ class TestConv3dTransposeOp(OpTest):
'strides'
:
self
.
stride
,
'paddings'
:
self
.
pad
,
'dilations'
:
self
.
dilations
,
'groups'
:
self
.
groups
,
'use_cudnn'
:
self
.
use_cudnn
,
'data_format'
:
'AnyLayout'
# TODO(dzhwinter) : should be fix latter
}
...
...
@@ -134,6 +143,7 @@ class TestConv3dTransposeOp(OpTest):
self
.
pad
=
[
0
,
0
,
0
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
...
...
@@ -147,16 +157,29 @@ class TestWithPad(TestConv3dTransposeOp):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
class
TestWithGroups
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
2
self
.
input_size
=
[
2
,
4
,
5
,
5
,
5
]
# NCHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
class
TestWithStride
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
2
,
2
,
2
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
...
...
@@ -167,6 +190,7 @@ class TestWithDilation(TestConv3dTransposeOp):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
2
,
2
,
2
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
...
...
@@ -184,6 +208,7 @@ class TestCUDNNWithPad(TestWithPad):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
...
...
@@ -198,6 +223,7 @@ class TestCUDNNWithStride(TestWithStride):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
2
,
2
,
2
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCDHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
...
...
@@ -207,6 +233,21 @@ class TestCUDNNWithStride(TestWithStride):
self
.
op_type
=
"conv3d_transpose"
class
TestCUDNNWithGroups
(
TestWithGroups
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
2
self
.
input_size
=
[
2
,
4
,
5
,
5
,
5
]
# NCHW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
def
init_op_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"conv3d_transpose"
# Please Don't remove the following code.
# Currently, CI use cudnn V5.0 which not support dilation conv.
# class TestCUDNNWithDilation(TestWithDilation):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录