Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
eec006d7
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
eec006d7
编写于
9月 03, 2020
作者:
J
jed
提交者:
GitHub
9月 03, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #117 from kaih70/master
fix test_op_conv cases for fast ut
上级
cee65c21
badef6ea
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
107 addition
and
79 deletion
+107
-79
python/paddle_fl/mpc/tests/unittests/test_op_conv.py
python/paddle_fl/mpc/tests/unittests/test_op_conv.py
+107
-79
未找到文件。
python/paddle_fl/mpc/tests/unittests/test_op_conv.py
浏览文件 @
eec006d7
...
...
@@ -156,17 +156,18 @@ def create_test_padding_VALID_class(parent):
self
.
pad
=
[
1
,
1
]
self
.
padding_algorithm
=
"VALID"
def
test_check_grad
(
self
):
error
=
0.09
if
parent
.
__name__
in
[
"TestConv2dOp_AsyPadding"
,
"TestWithStride_AsyPadding"
]:
error
=
0.14
elif
parent
.
__name__
in
[
"TestWithInput1x1Filter1x1_AsyPadding"
]:
error
=
0.66
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
{
'Input'
,
'Filter'
},
'Output'
,
max_relative_error
=
error
)
pass
# error = 0.09
# if parent.__name__ in ["TestConv2dOp_AsyPadding",
# "TestWithStride_AsyPadding"]:
# error = 0.14
# elif parent.__name__ in ["TestWithInput1x1Filter1x1_AsyPadding"]:
# error = 0.66
# place = core.CPUPlace()
# self.check_grad_with_place(
# place, {'Input', 'Filter'},
# 'Output',
# max_relative_error=error)
cls_name
=
"{0}_{1}"
.
format
(
parent
.
__name__
,
"PaddingVALIDOp"
)
TestPaddingVALIDCase
.
__name__
=
cls_name
...
...
@@ -224,21 +225,23 @@ class TestConv2dOp(OpTest):
'Output'
,
max_relative_error
=
0.07
)
def
test_check_grad_no_filter
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Input'
],
'Output'
,
max_relative_error
=
0.07
,
no_grad_set
=
set
([
'Filter'
]))
def
test_check_grad_no_input
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Filter'
],
'Output'
,
max_relative_error
=
0.06
,
no_grad_set
=
set
([
'Input'
]))
# skip cases for fast ut
# to test correctness, uncomment test cases
#def test_check_grad_no_filter(self):
# place = core.CPUPlace()
# self.check_grad_with_place(
# place, ['Input'],
# 'Output',
# max_relative_error=0.07,
# no_grad_set=set(['Filter']))
#def test_check_grad_no_input(self):
# place = core.CPUPlace()
# self.check_grad_with_place(
# place, ['Filter'],
# 'Output',
# max_relative_error=0.06,
# no_grad_set=set(['Input']))
def
init_test_case
(
self
):
self
.
pad
=
[
0
,
0
]
...
...
@@ -270,6 +273,9 @@ class TestWithPad(TestConv2dOp):
f_c
=
self
.
input_size
[
1
]
//
self
.
groups
self
.
filter_size
=
[
6
,
f_c
,
3
,
3
]
def
test_check_grad
(
self
):
pass
class
TestWithStride
(
TestConv2dOp
):
def
init_test_case
(
self
):
...
...
@@ -280,6 +286,9 @@ class TestWithStride(TestConv2dOp):
f_c
=
self
.
input_size
[
1
]
//
self
.
groups
self
.
filter_size
=
[
6
,
f_c
,
3
,
3
]
def
test_check_grad
(
self
):
pass
class
TestWithGroup
(
TestConv2dOp
):
def
init_test_case
(
self
):
...
...
@@ -291,6 +300,9 @@ class TestWithGroup(TestConv2dOp):
f_c
=
self
.
input_size
[
1
]
//
self
.
groups
self
.
filter_size
=
[
18
,
f_c
,
3
,
3
]
def
test_check_grad
(
self
):
pass
class
TestWith1x1
(
TestConv2dOp
):
def
init_test_case
(
self
):
...
...
@@ -305,19 +317,20 @@ class TestWith1x1(TestConv2dOp):
self
.
groups
=
3
def
test_check_grad
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
{
'Input'
,
'Filter'
},
'Output'
,
max_relative_error
=
0.6
)
def
test_check_grad_no_filter
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Input'
],
'Output'
,
max_relative_error
=
0.9
,
no_grad_set
=
set
([
'Filter'
]))
pass
# place = core.CPUPlace()
# self.check_grad_with_place(
# place, {'Input', 'Filter'},
# 'Output',
# max_relative_error=0.6)
#def test_check_grad_no_filter(self):
# place = core.CPUPlace()
# self.check_grad_with_place(
# place, ['Input'],
# 'Output',
# max_relative_error=0.9,
# no_grad_set=set(['Filter']))
class
TestWithDilation
(
TestConv2dOp
):
def
init_test_case
(
self
):
...
...
@@ -334,6 +347,9 @@ class TestWithDilation(TestConv2dOp):
def
init_group
(
self
):
self
.
groups
=
3
def
test_check_grad
(
self
):
pass
class
TestWithInput1x1Filter1x1
(
TestConv2dOp
):
def
init_test_case
(
self
):
...
...
@@ -348,11 +364,8 @@ class TestWithInput1x1Filter1x1(TestConv2dOp):
self
.
groups
=
3
def
test_check_grad
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
{
'Input'
,
'Filter'
},
'Output'
,
max_relative_error
=
0.75
)
pass
class
TestConv2dOp_v2
(
OpTest
):
def
setUp
(
self
):
...
...
@@ -403,28 +416,28 @@ class TestConv2dOp_v2(OpTest):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
def
test_check_grad
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
{
'Input'
,
'Filter'
},
'Output'
,
max_relative_error
=
0.14
)
def
test_check_grad_no_filter
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Input'
],
'Output'
,
max_relative_error
=
0.13
,
no_grad_set
=
set
([
'Filter'
]))
def
test_check_grad_no_input
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Filter'
],
'Output'
,
max_relative_error
=
0.7
,
no_grad_set
=
set
([
'Input'
]))
#
def test_check_grad(self):
#
place = core.CPUPlace()
#
self.check_grad_with_place(
#
place, {'Input', 'Filter'},
#
'Output',
#
max_relative_error=0.14)
#
def test_check_grad_no_filter(self):
#
place = core.CPUPlace()
#
self.check_grad_with_place(
#
place, ['Input'],
#
'Output',
#
max_relative_error=0.13,
#
no_grad_set=set(['Filter']))
#
def test_check_grad_no_input(self):
#
place = core.CPUPlace()
#
self.check_grad_with_place(
#
place, ['Filter'],
#
'Output',
#
max_relative_error=0.7,
#
no_grad_set=set(['Input']))
def
init_test_case
(
self
):
self
.
pad
=
[
0
,
0
]
...
...
@@ -465,6 +478,9 @@ class TestConv2dOp_AsyPadding(TestConv2dOp_v2):
'Output'
,
max_relative_error
=
0.09
)
def
test_check_grad
(
self
):
pass
class
TestWithPad_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -478,6 +494,9 @@ class TestWithPad_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
2
,
1
,
3
,
2
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithStride_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -491,6 +510,9 @@ class TestWithStride_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
2
,
1
,
3
,
2
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithGroup_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -502,6 +524,9 @@ class TestWithGroup_AsyPadding(TestConv2dOp_v2):
f_c
=
self
.
input_size
[
1
]
//
self
.
groups
self
.
filter_size
=
[
24
,
f_c
,
4
,
3
]
def
test_check_grad
(
self
):
pass
class
TestWith1x1_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -518,6 +543,9 @@ class TestWith1x1_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
2
,
2
,
4
,
0
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithDepthWise3x3_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -537,6 +565,9 @@ class TestWithDepthWise3x3_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
1
,
3
,
2
,
1
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithDepthWise5x5_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -553,6 +584,9 @@ class TestWithDepthWise5x5_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
0
,
1
,
1
,
0
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithDepthWise7x7_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -569,6 +603,9 @@ class TestWithDepthWise7x7_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
1
,
3
,
4
,
1
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithDilation_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -588,6 +625,9 @@ class TestWithDilation_AsyPadding(TestConv2dOp_v2):
self
.
pad
=
[
0
,
1
,
3
,
0
]
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
pass
class
TestWithInput1x1Filter1x1_AsyPadding
(
TestConv2dOp_v2
):
def
init_test_case
(
self
):
...
...
@@ -605,19 +645,7 @@ class TestWithInput1x1Filter1x1_AsyPadding(TestConv2dOp_v2):
self
.
padding_algorithm
=
"EXPLICIT"
def
test_check_grad
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
{
'Input'
,
'Filter'
},
'Output'
,
max_relative_error
=
0.7
)
def
test_check_grad_no_filter
(
self
):
place
=
core
.
CPUPlace
()
self
.
check_grad_with_place
(
place
,
[
'Input'
],
'Output'
,
max_relative_error
=
0.7
,
no_grad_set
=
set
([
'Filter'
]))
pass
#---------- test SAME VALID -----------
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录