Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
538c8489
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,发现更多精彩内容 >>
提交
538c8489
编写于
12月 20, 2019
作者:
Z
Zhang Ting
提交者:
Tao Luo
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add decorator skip_check_grad_ci (#21836)
上级
bf9c5de7
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
59 addition
and
59 deletion
+59
-59
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+25
-1
python/paddle/fluid/tests/unittests/test_dropout_op.py
python/paddle/fluid/tests/unittests/test_dropout_op.py
+7
-1
python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py
.../unittests/test_executor_return_tensor_not_overwriting.py
+2
-1
python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
...addle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
+3
-1
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
+9
-11
python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
...n/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
+9
-11
python/paddle/fluid/tests/unittests/test_seq_pool.py
python/paddle/fluid/tests/unittests/test_seq_pool.py
+4
-2
python/paddle/fluid/tests/unittests/white_list/op_check_grad_white_list.py
...id/tests/unittests/white_list/op_check_grad_white_list.py
+0
-31
未找到文件。
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
538c8489
...
@@ -146,6 +146,30 @@ def get_numeric_gradient(place,
...
@@ -146,6 +146,30 @@ def get_numeric_gradient(place,
return
gradient_flat
.
reshape
(
tensor_to_check
.
shape
())
return
gradient_flat
.
reshape
(
tensor_to_check
.
shape
())
def
skip_check_grad_ci
(
reason
=
None
):
"""Decorator to skip check_grad CI.
Check_grad is required for Op test cases. However, there are some special
cases that do not need to do check_grad. This decorator is used to skip the
check_grad of the above cases.
Note: the execution of unit test will not be skipped. It just avoids check_grad
checking in tearDownClass method by setting a `no_need_check_grad` flag.
Example:
@skip_check_grad_ci(reason="For inference, check_grad is not required.")
class TestInference(OpTest):
"""
if
not
isinstance
(
reason
,
str
):
raise
AssertionError
(
"The reason for skipping check_grad is required."
)
def
wrapper
(
cls
):
cls
.
no_need_check_grad
=
True
return
cls
return
wrapper
class
OpTest
(
unittest
.
TestCase
):
class
OpTest
(
unittest
.
TestCase
):
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
@@ -182,7 +206,7 @@ class OpTest(unittest.TestCase):
...
@@ -182,7 +206,7 @@ class OpTest(unittest.TestCase):
+
OpTest
.
op_type
+
" Op."
)
+
OpTest
.
op_type
+
" Op."
)
# cases and ops do no need check_grad
# cases and ops do no need check_grad
if
cls
.
__name__
in
op_check_grad_white_list
.
NO_NEED_CHECK_GRAD_CASES
\
if
hasattr
(
cls
,
"no_need_check_grad"
)
\
or
cls
.
op_type
in
op_check_grad_white_list
.
EMPTY_GRAD_OP_LIST
:
or
cls
.
op_type
in
op_check_grad_white_list
.
EMPTY_GRAD_OP_LIST
:
return
return
...
...
python/paddle/fluid/tests/unittests/test_dropout_op.py
浏览文件 @
538c8489
...
@@ -17,7 +17,7 @@ from __future__ import print_function
...
@@ -17,7 +17,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid
import
Program
,
program_guard
from
paddle.fluid
import
Program
,
program_guard
...
@@ -61,6 +61,7 @@ class TestDropoutOp3(TestDropoutOp):
...
@@ -61,6 +61,7 @@ class TestDropoutOp3(TestDropoutOp):
}
}
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestDropoutOp4
(
OpTest
):
class
TestDropoutOp4
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
op_type
=
"dropout"
...
@@ -74,6 +75,7 @@ class TestDropoutOp4(OpTest):
...
@@ -74,6 +75,7 @@ class TestDropoutOp4(OpTest):
self
.
check_output
()
self
.
check_output
()
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestDropoutOp5
(
OpTest
):
class
TestDropoutOp5
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
op_type
=
"dropout"
...
@@ -119,6 +121,7 @@ class TestDropoutOp7(TestDropoutOp):
...
@@ -119,6 +121,7 @@ class TestDropoutOp7(TestDropoutOp):
}
}
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestDropoutOp8
(
OpTest
):
class
TestDropoutOp8
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
op_type
=
"dropout"
...
@@ -135,6 +138,7 @@ class TestDropoutOp8(OpTest):
...
@@ -135,6 +138,7 @@ class TestDropoutOp8(OpTest):
self
.
check_output
()
self
.
check_output
()
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestDropoutOp9
(
OpTest
):
class
TestDropoutOp9
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
op_type
=
"dropout"
...
@@ -174,6 +178,7 @@ class TestDropoutOpWithSeed(OpTest):
...
@@ -174,6 +178,7 @@ class TestDropoutOpWithSeed(OpTest):
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
op_support_gpu
(
"dropout"
),
not
core
.
is_compiled_with_cuda
()
or
not
core
.
op_support_gpu
(
"dropout"
),
"core is not compiled with CUDA or core is not support dropout"
)
"core is not compiled with CUDA or core is not support dropout"
)
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestFP16DropoutOp
(
OpTest
):
class
TestFP16DropoutOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
op_type
=
"dropout"
...
@@ -201,6 +206,7 @@ class TestFP16DropoutOp(OpTest):
...
@@ -201,6 +206,7 @@ class TestFP16DropoutOp(OpTest):
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
op_support_gpu
(
"dropout"
),
not
core
.
is_compiled_with_cuda
()
or
not
core
.
op_support_gpu
(
"dropout"
),
"core is not compiled with CUDA or core is not support dropout"
)
"core is not compiled with CUDA or core is not support dropout"
)
@
skip_check_grad_ci
(
reason
=
"For inference, check_grad is not required."
)
class
TestFP16DropoutOp2
(
TestFP16DropoutOp
):
class
TestFP16DropoutOp2
(
TestFP16DropoutOp
):
def
init_test_case
(
self
):
def
init_test_case
(
self
):
self
.
input_size
=
[
32
,
64
,
3
]
self
.
input_size
=
[
32
,
64
,
3
]
...
...
python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py
浏览文件 @
538c8489
...
@@ -17,9 +17,10 @@ import unittest
...
@@ -17,9 +17,10 @@ import unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
@
skip_check_grad_ci
(
reason
=
"Not op test but call the method of class OpTest."
)
class
TestExecutorReturnTensorNotOverwritingWithOptest
(
OpTest
):
class
TestExecutorReturnTensorNotOverwritingWithOptest
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
pass
pass
...
...
python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
浏览文件 @
538c8489
...
@@ -17,7 +17,7 @@ from __future__ import print_function
...
@@ -17,7 +17,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
platform
import
platform
import
numpy
as
np
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid.op
import
Operator
from
paddle.fluid.op
import
Operator
...
@@ -25,6 +25,8 @@ import paddle.compat as cpt
...
@@ -25,6 +25,8 @@ import paddle.compat as cpt
import
paddle.version
as
ver
import
paddle.version
as
ver
@
skip_check_grad_ci
(
reason
=
"check_grad is called when ver.mkl() == ON"
"and 'Linux' in platform.platform()."
)
class
TestFusedEmbeddingSeqPoolOp
(
OpTest
):
class
TestFusedEmbeddingSeqPoolOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"fused_embedding_seq_pool"
self
.
op_type
=
"fused_embedding_seq_pool"
...
...
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
浏览文件 @
538c8489
...
@@ -16,7 +16,7 @@ from __future__ import print_function
...
@@ -16,7 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
from
paddle.fluid.op
import
Operator
import
paddle.compat
as
cpt
import
paddle.compat
as
cpt
...
@@ -56,6 +56,10 @@ class TestLookupTableOpWithTensorIds(OpTest):
...
@@ -56,6 +56,10 @@ class TestLookupTableOpWithTensorIds(OpTest):
self
.
check_grad
([
'W'
],
'Out'
,
no_grad_set
=
set
(
'Ids'
))
self
.
check_grad
([
'W'
],
'Out'
,
no_grad_set
=
set
(
'Ids'
))
@
skip_check_grad_ci
(
reason
=
"Since paddings are not trainable and fixed in forward,"
"the gradient of paddings makes no sense and we don't "
"test the gradient here."
)
class
TestLookupTableOpWithPadding
(
TestLookupTableOp
):
class
TestLookupTableOpWithPadding
(
TestLookupTableOp
):
def
test_check_output
(
self
):
def
test_check_output
(
self
):
ids
=
np
.
squeeze
(
self
.
inputs
[
'Ids'
])
ids
=
np
.
squeeze
(
self
.
inputs
[
'Ids'
])
...
@@ -64,12 +68,11 @@ class TestLookupTableOpWithPadding(TestLookupTableOp):
...
@@ -64,12 +68,11 @@ class TestLookupTableOpWithPadding(TestLookupTableOp):
self
.
attrs
=
{
'padding_idx'
:
int
(
padding_idx
)}
self
.
attrs
=
{
'padding_idx'
:
int
(
padding_idx
)}
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
# Since paddings are not trainable and fixed in forward, the gradient of
# paddings makes no sense and we don't test the gradient here.
pass
@
skip_check_grad_ci
(
reason
=
"Since paddings are not trainable and fixed in forward,"
"the gradient of paddings makes no sense and we don't "
"test the gradient here."
)
class
TestLookupTableOpWithTensorIdsAndPadding
(
TestLookupTableOpWithTensorIds
):
class
TestLookupTableOpWithTensorIdsAndPadding
(
TestLookupTableOpWithTensorIds
):
def
test_check_output
(
self
):
def
test_check_output
(
self
):
ids
=
self
.
inputs
[
'Ids'
]
ids
=
self
.
inputs
[
'Ids'
]
...
@@ -79,11 +82,6 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
...
@@ -79,11 +82,6 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
self
.
attrs
=
{
'padding_idx'
:
cpt
.
long_type
(
padding_idx
)}
self
.
attrs
=
{
'padding_idx'
:
cpt
.
long_type
(
padding_idx
)}
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
# Since paddings are not trainable and fixed in forward, the gradient of
# paddings makes no sense and we don't test the gradient here.
pass
class
TestLookupTableWIsSelectedRows
(
unittest
.
TestCase
):
class
TestLookupTableWIsSelectedRows
(
unittest
.
TestCase
):
def
prepare_ids
(
self
,
scope
,
place
):
def
prepare_ids
(
self
,
scope
,
place
):
...
...
python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
浏览文件 @
538c8489
...
@@ -16,7 +16,7 @@ from __future__ import print_function
...
@@ -16,7 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid.op
import
Operator
from
paddle.fluid.op
import
Operator
...
@@ -55,6 +55,10 @@ class TestLookupTableOpWithTensorIds(OpTest):
...
@@ -55,6 +55,10 @@ class TestLookupTableOpWithTensorIds(OpTest):
self
.
check_grad
([
'W'
],
'Out'
,
no_grad_set
=
set
(
'Ids'
))
self
.
check_grad
([
'W'
],
'Out'
,
no_grad_set
=
set
(
'Ids'
))
@
skip_check_grad_ci
(
reason
=
"Since paddings are not trainable and fixed in forward,"
"the gradient of paddings makes no sense and we don't "
"test the gradient here."
)
class
TestLookupTableOpWithPadding
(
TestLookupTableOp
):
class
TestLookupTableOpWithPadding
(
TestLookupTableOp
):
def
test_check_output
(
self
):
def
test_check_output
(
self
):
ids
=
np
.
squeeze
(
self
.
inputs
[
'Ids'
])
ids
=
np
.
squeeze
(
self
.
inputs
[
'Ids'
])
...
@@ -63,12 +67,11 @@ class TestLookupTableOpWithPadding(TestLookupTableOp):
...
@@ -63,12 +67,11 @@ class TestLookupTableOpWithPadding(TestLookupTableOp):
self
.
attrs
=
{
'padding_idx'
:
int
(
padding_idx
)}
self
.
attrs
=
{
'padding_idx'
:
int
(
padding_idx
)}
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
# Since paddings are not trainable and fixed in forward, the gradient of
# paddings makes no sense and we don't test the gradient here.
pass
@
skip_check_grad_ci
(
reason
=
"Since paddings are not trainable and fixed in forward,"
"the gradient of paddings makes no sense and we don't "
"test the gradient here."
)
class
TestLookupTableOpWithTensorIdsAndPadding
(
TestLookupTableOpWithTensorIds
):
class
TestLookupTableOpWithTensorIdsAndPadding
(
TestLookupTableOpWithTensorIds
):
def
test_check_output
(
self
):
def
test_check_output
(
self
):
ids
=
self
.
inputs
[
'Ids'
]
ids
=
self
.
inputs
[
'Ids'
]
...
@@ -78,11 +81,6 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
...
@@ -78,11 +81,6 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
self
.
attrs
=
{
'padding_idx'
:
cpt
.
long_type
(
padding_idx
)}
self
.
attrs
=
{
'padding_idx'
:
cpt
.
long_type
(
padding_idx
)}
self
.
check_output
()
self
.
check_output
()
def
test_check_grad
(
self
):
# Since paddings are not trainable and fixed in forward, the gradient of
# paddings makes no sense and we don't test the gradient here.
pass
class
TestLookupTableWIsSelectedRows
(
unittest
.
TestCase
):
class
TestLookupTableWIsSelectedRows
(
unittest
.
TestCase
):
def
prepare_ids
(
self
,
scope
,
place
):
def
prepare_ids
(
self
,
scope
,
place
):
...
...
python/paddle/fluid/tests/unittests/test_seq_pool.py
浏览文件 @
538c8489
...
@@ -16,7 +16,7 @@ from __future__ import print_function
...
@@ -16,7 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
from
test_reorder_lod_tensor
import
convert_to_offset
from
test_reorder_lod_tensor
import
convert_to_offset
...
@@ -355,6 +355,8 @@ class TestSeqMaxPool2DLen0LoDLevel2(TestSeqMaxPool2D):
...
@@ -355,6 +355,8 @@ class TestSeqMaxPool2DLen0LoDLevel2(TestSeqMaxPool2D):
return
[[
1
,
0
,
2
,
2
],
[
0
,
3
,
0
,
10
,
0
]]
return
[[
1
,
0
,
2
,
2
],
[
0
,
3
,
0
,
10
,
0
]]
@
skip_check_grad_ci
(
reason
=
"Grad computation does not apply to Sequence MAX "
"Pool executed when is_test is true."
)
class
TestSeqMaxPool2DInference
(
TestSeqMaxPool2D
):
class
TestSeqMaxPool2DInference
(
TestSeqMaxPool2D
):
def
compute
(
self
,
x
,
offset
,
out
):
def
compute
(
self
,
x
,
offset
,
out
):
self
.
attrs
=
{
"pad_value"
:
1.0
,
'pooltype'
:
"MAX"
,
'is_test'
:
True
}
self
.
attrs
=
{
"pad_value"
:
1.0
,
'pooltype'
:
"MAX"
,
'is_test'
:
True
}
...
...
python/paddle/fluid/tests/unittests/white_list/op_check_grad_white_list.py
浏览文件 @
538c8489
...
@@ -53,34 +53,3 @@ EMPTY_GRAD_OP_LIST = [
...
@@ -53,34 +53,3 @@ EMPTY_GRAD_OP_LIST = [
'hash'
,
'less_than'
,
'not_equal'
,
'eye'
,
'chunk_eval'
,
'is_empty'
,
'hash'
,
'less_than'
,
'not_equal'
,
'eye'
,
'chunk_eval'
,
'is_empty'
,
'proximal_gd'
,
'collect_fpn_proposals'
,
'unique_with_counts'
'proximal_gd'
,
'collect_fpn_proposals'
,
'unique_with_counts'
]
]
# Special cases do not need to check grad
NO_NEED_CHECK_GRAD_CASES
=
[
'TestLookupTableOpWithPadding'
,
'TestLookupTableOpWithTensorIdsAndPadding'
,
'TestLookupTableOpWithPadding'
,
'TestLookupTableOpWithTensorIdsAndPadding'
,
'TestSeqMaxPool2DInference'
,
'TestSeqMaxPool2DInferenceLen0'
,
'TestSeqMaxPool2DInferenceLen0LoDLevel2'
,
'TestDropoutOp4'
,
'TestDropoutOp5'
,
'TestDropoutOp8'
,
'TestDropoutOp9'
,
'TestFP16DropoutOp'
,
'TestFP16DropoutOp2'
,
'TestExpandOpBoolean'
,
'TestFusedEmbeddingSeqPoolOp'
,
'TestMKLDNNConcatOp'
,
'TestMKLDNNConcatOp'
,
'TestMKLDNNConcatOp3'
,
'TestElementwiseMulMKLDNNOp_Integrated_With_Convs'
,
'TestConv2dTransposeMKLDNNOp'
,
'TestMKLDNNFuseBias'
,
'TestMKLDNNWithPad'
,
'TestMKLDNNWithStride'
,
'TestMKLDNNWithAsymPad'
,
'TestMKLDNNWithSamePad'
,
'TestMKLDNNWithValidPad'
,
'TestMKLDNNWithValidPad_NHWC'
,
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录