Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1f24c84a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
1f24c84a
编写于
6月 24, 2020
作者:
F
FDInSky
提交者:
GitHub
6月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix conv3d_transpose_test timeout error (#25004)
* test=develop fix conv3d_transpose_test error
上级
bd0b38e6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
231 addition
and
198 deletion
+231
-198
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
+16
-198
python/paddle/fluid/tests/unittests/test_conv3d_transpose_part2_op.py
...e/fluid/tests/unittests/test_conv3d_transpose_part2_op.py
+215
-0
未找到文件。
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
浏览文件 @
1f24c84a
...
...
@@ -111,6 +111,8 @@ class TestConv3dTransposeOp(OpTest):
def
setUp
(
self
):
# init as conv transpose
self
.
use_cudnn
=
False
self
.
check_no_input
=
False
self
.
check_no_filter
=
False
self
.
data_format
=
'NCHW'
self
.
pad
=
[
0
,
0
,
0
]
self
.
padding_algorithm
=
"EXPLICIT"
...
...
@@ -163,7 +165,7 @@ class TestConv3dTransposeOp(OpTest):
'Output'
,
max_relative_error
=
0.03
,
no_grad_set
=
set
([
'Filter'
]))
el
se
:
el
if
self
.
check_no_filter
:
self
.
check_grad
(
[
'Input'
],
'Output'
,
...
...
@@ -178,7 +180,7 @@ class TestConv3dTransposeOp(OpTest):
'Output'
,
max_relative_error
=
0.03
,
no_grad_set
=
set
([
'Input'
]))
el
se
:
el
if
self
.
check_no_input
:
self
.
check_grad
(
[
'Filter'
],
'Output'
,
...
...
@@ -200,6 +202,7 @@ class TestConv3dTransposeOp(OpTest):
class
TestWithSymmetricPad
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
check_no_input
=
True
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
...
...
@@ -242,26 +245,27 @@ class TestWithVALIDPad(TestConv3dTransposeOp):
self
.
padding_algorithm
=
'VALID'
class
TestWith
Groups
(
TestConv3dTransposeOp
):
class
TestWith
Stride
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
check_no_filter
=
True
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
stride
=
[
2
,
2
,
2
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
2
self
.
input_size
=
[
2
,
4
,
5
,
5
,
5
]
# NC
HW
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCD
HW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
class
TestWith
Stride
(
TestConv3dTransposeOp
):
class
TestWith
Groups
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
2
,
2
,
2
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
3
,
5
,
5
,
5
]
# NCD
HW
self
.
groups
=
2
self
.
input_size
=
[
2
,
4
,
5
,
5
,
5
]
# NC
HW
f_c
=
self
.
input_size
[
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
class
TestWithDilation
(
TestConv3dTransposeOp
):
...
...
@@ -287,66 +291,6 @@ class Test_NHWC(TestConv3dTransposeOp):
self
.
data_format
=
'NHWC'
class
TestWithSymmetricPad_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithAsymmetricPad_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
0
,
1
,
0
,
1
,
2
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithGroups_NHWC
(
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
,
5
,
5
,
5
,
4
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithStride_NHWC
(
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
,
5
,
5
,
5
,
3
]
# NCDHW
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithDilation_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
2
,
2
,
2
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NCDHW
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
# ------------ test_cudnn ------------
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
"core is not compiled with CUDA"
)
...
...
@@ -563,131 +507,5 @@ class TestCUDNNWithGroups_NHWC(TestWithGroups):
self
.
op_type
=
"conv3d_transpose"
class
TestConv3dTransposeAPI
(
unittest
.
TestCase
):
def
test_case1
(
self
):
data1
=
fluid
.
layers
.
data
(
name
=
'data1'
,
shape
=
[
3
,
5
,
5
,
5
],
dtype
=
'float32'
)
data2
=
fluid
.
layers
.
data
(
name
=
'data2'
,
shape
=
[
5
,
5
,
5
,
3
],
dtype
=
'float32'
)
out1
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data1
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
'NCDHW'
)
out2
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
'NDHWC'
)
out3
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data1
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
0
,
0
],
[
0
,
0
],
[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
data_format
=
'NCDHW'
)
out4
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
3
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
0
,
0
],
[
0
,
0
],
[
1
,
1
],
[
1
,
2
],
[
0
,
0
]],
data_format
=
'NDHWC'
)
out5
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'SAME'
,
data_format
=
'NCDHW'
)
out6
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'VALID'
,
data_format
=
'NDHWC'
)
out7
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
output_size
=
[
7
,
7
,
7
],
padding
=
[
0
,
0
,
0
],
data_format
=
'NDHWC'
)
data1_np
=
np
.
random
.
random
((
2
,
3
,
5
,
5
,
5
)).
astype
(
"float32"
)
data2_np
=
np
.
random
.
random
((
2
,
5
,
5
,
5
,
3
)).
astype
(
"float32"
)
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
else
:
place
=
core
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
results
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"data1"
:
data1_np
,
"data2"
:
data2_np
},
fetch_list
=
[
out1
,
out2
,
out3
,
out4
,
out5
,
out6
,
out7
],
return_numpy
=
True
)
self
.
assertIsNotNone
(
results
[
0
])
self
.
assertIsNotNone
(
results
[
1
])
self
.
assertIsNotNone
(
results
[
2
])
self
.
assertIsNotNone
(
results
[
3
])
self
.
assertIsNotNone
(
results
[
4
])
self
.
assertIsNotNone
(
results
[
5
])
self
.
assertIsNotNone
(
results
[
6
])
class
TestConv3dTransposeOpException
(
unittest
.
TestCase
):
def
test_exception
(
self
):
data
=
fluid
.
layers
.
data
(
name
=
'data'
,
shape
=
[
3
,
5
,
5
,
5
],
dtype
=
"float32"
)
def
attr_data_format
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
"NCDW"
)
self
.
assertRaises
(
ValueError
,
attr_data_format
)
def
attr_padding_str
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'Vald'
)
self
.
assertRaises
(
ValueError
,
attr_padding_str
)
def
attr_padding_list
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
],
[
0
,
0
],
[
1
,
1
]])
self
.
assertRaises
(
ValueError
,
attr_padding_list
)
def
attr_padding_with_data_format
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
1
,
1
],
[
0
,
0
],
[
0
,
0
],
[
1
,
0
],
[
1
,
1
]],
data_format
=
'NDHWC'
)
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_conv3d_transpose_part2_op.py
0 → 100644
浏览文件 @
1f24c84a
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
print_function
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
from
op_test
import
OpTest
from
test_conv3d_transpose_op
import
conv3dtranspose_forward_naive
,
TestConv3dTransposeOp
class
TestWithSymmetricPad_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithAsymmetricPad_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
0
,
1
,
0
,
1
,
2
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithGroups_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
check_no_filter
=
True
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
1
,
1
,
1
]
self
.
groups
=
2
self
.
input_size
=
[
2
,
5
,
5
,
5
,
4
]
# NDHWC
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
3
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithStride_NHWC
(
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
,
5
,
5
,
5
,
3
]
# NCDHW
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestWithDilation_NHWC
(
TestConv3dTransposeOp
):
def
init_test_case
(
self
):
self
.
check_no_input
=
True
self
.
pad
=
[
1
,
1
,
1
]
self
.
stride
=
[
1
,
1
,
1
]
self
.
dilations
=
[
2
,
2
,
2
]
self
.
groups
=
1
self
.
input_size
=
[
2
,
5
,
5
,
5
,
3
]
# NCDHW
f_c
=
self
.
input_size
[
-
1
]
self
.
filter_size
=
[
f_c
,
6
,
3
,
3
,
3
]
self
.
data_format
=
'NHWC'
class
TestConv3dTransposeAPI
(
unittest
.
TestCase
):
def
test_case1
(
self
):
data1
=
fluid
.
layers
.
data
(
name
=
'data1'
,
shape
=
[
3
,
5
,
5
,
5
],
dtype
=
'float32'
)
data2
=
fluid
.
layers
.
data
(
name
=
'data2'
,
shape
=
[
5
,
5
,
5
,
3
],
dtype
=
'float32'
)
out1
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data1
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
'NCDHW'
)
out2
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
'NDHWC'
)
out3
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data1
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
0
,
0
],
[
0
,
0
],
[
1
,
1
],
[
0
,
0
],
[
1
,
1
]],
data_format
=
'NCDHW'
)
out4
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
3
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
0
,
0
],
[
0
,
0
],
[
1
,
1
],
[
1
,
2
],
[
0
,
0
]],
data_format
=
'NDHWC'
)
out5
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'SAME'
,
data_format
=
'NCDHW'
)
out6
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'VALID'
,
data_format
=
'NDHWC'
)
out7
=
fluid
.
layers
.
conv3d_transpose
(
input
=
data2
,
groups
=
1
,
num_filters
=
6
,
output_size
=
[
7
,
7
,
7
],
padding
=
[
0
,
0
,
0
],
data_format
=
'NDHWC'
)
data1_np
=
np
.
random
.
random
((
2
,
3
,
5
,
5
,
5
)).
astype
(
"float32"
)
data2_np
=
np
.
random
.
random
((
2
,
5
,
5
,
5
,
3
)).
astype
(
"float32"
)
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
else
:
place
=
core
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
results
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"data1"
:
data1_np
,
"data2"
:
data2_np
},
fetch_list
=
[
out1
,
out2
,
out3
,
out4
,
out5
,
out6
,
out7
],
return_numpy
=
True
)
self
.
assertIsNotNone
(
results
[
0
])
self
.
assertIsNotNone
(
results
[
1
])
self
.
assertIsNotNone
(
results
[
2
])
self
.
assertIsNotNone
(
results
[
3
])
self
.
assertIsNotNone
(
results
[
4
])
self
.
assertIsNotNone
(
results
[
5
])
self
.
assertIsNotNone
(
results
[
6
])
class
TestConv3dTransposeOpException
(
unittest
.
TestCase
):
def
test_exception
(
self
):
data
=
fluid
.
layers
.
data
(
name
=
'data'
,
shape
=
[
3
,
5
,
5
,
5
],
dtype
=
"float32"
)
def
attr_data_format
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
data_format
=
"NCDW"
)
self
.
assertRaises
(
ValueError
,
attr_data_format
)
def
attr_padding_str
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
'Vald'
)
self
.
assertRaises
(
ValueError
,
attr_padding_str
)
def
attr_padding_list
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
1
,
1
],
[
1
,
1
],
[
0
,
0
],
[
0
,
0
],
[
1
,
1
]])
self
.
assertRaises
(
ValueError
,
attr_padding_list
)
def
attr_padding_with_data_format
():
out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
groups
=
1
,
num_filters
=
6
,
filter_size
=
3
,
padding
=
[[
1
,
1
],
[
0
,
0
],
[
0
,
0
],
[
1
,
0
],
[
1
,
1
]],
data_format
=
'NDHWC'
)
self
.
assertRaises
(
ValueError
,
attr_padding_with_data_format
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录