Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9bb1e3ea
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看板
提交
9bb1e3ea
编写于
12月 20, 2019
作者:
Z
zhupengyang
提交者:
Tao Luo
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add shape_check for op tests (#21391)
上级
63a5fb4c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
1 deletion
+38
-1
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+13
-1
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
...luid/tests/unittests/white_list/check_shape_white_list.py
+25
-0
未找到文件。
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
9bb1e3ea
...
...
@@ -33,7 +33,7 @@ from paddle.fluid.executor import Executor
from
paddle.fluid.framework
import
Program
,
OpProtoHolder
,
Variable
from
testsuite
import
create_op
,
set_input
,
append_input_output
,
append_loss_ops
from
paddle.fluid
import
unique_name
from
white_list
import
op_accuracy_white_list
,
op_check_grad_white_list
from
white_list
import
op_accuracy_white_list
,
op_check_grad_white_list
,
check_shape_white_list
def
_set_use_system_allocator
(
value
=
None
):
...
...
@@ -69,6 +69,10 @@ def get_numeric_gradient(place,
tensor_to_check
=
scope
.
find_var
(
input_to_check
).
get_tensor
()
tensor_size
=
product
(
tensor_to_check
.
shape
())
if
not
hasattr
(
get_numeric_gradient
,
'check_shape_time'
):
get_numeric_gradient
.
check_shape_time
=
0
if
tensor_size
>=
100
:
get_numeric_gradient
.
check_shape_time
+=
1
tensor_to_check_dtype
=
tensor_to_check
.
_dtype
()
if
tensor_to_check_dtype
==
core
.
VarDesc
.
VarType
.
FP32
:
tensor_to_check_dtype
=
np
.
float32
...
...
@@ -170,6 +174,13 @@ class OpTest(unittest.TestCase):
"This test do not have op_type in class attrs,"
" please set self.__class__.op_type=the_real_op_type manually."
)
if
hasattr
(
get_numeric_gradient
,
'check_shape_time'
)
and
get_numeric_gradient
.
check_shape_time
==
0
and
OpTest
.
op_type
not
in
check_shape_white_list
.
NOT_CHECK_OP_LIST
and
OpTest
.
op_type
not
in
check_shape_white_list
.
NEED_TO_FIX_OP_LIST
:
raise
AssertionError
(
"At least one input's shape should be large than or equal to 100 for "
+
OpTest
.
op_type
+
" Op."
)
# cases and ops do no need check_grad
if
cls
.
__name__
in
op_check_grad_white_list
.
NO_NEED_CHECK_GRAD_CASES
\
or
cls
.
op_type
in
op_check_grad_white_list
.
EMPTY_GRAD_OP_LIST
:
...
...
@@ -1141,6 +1152,7 @@ class OpTest(unittest.TestCase):
max_relative_error
=
0.005
,
user_defined_grads
=
None
,
check_dygraph
=
True
):
OpTest
.
op_type
=
self
.
op_type
self
.
scope
=
core
.
Scope
()
op_inputs
=
self
.
inputs
if
hasattr
(
self
,
"inputs"
)
else
dict
()
op_outputs
=
self
.
outputs
if
hasattr
(
self
,
"outputs"
)
else
dict
()
...
...
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
0 → 100644
浏览文件 @
9bb1e3ea
# Copyright (c) 2019 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.
NOT_CHECK_OP_LIST
=
[
# increment's input must be 1-d and only has one data
'increment'
]
NEED_TO_FIX_OP_LIST
=
[
'sequence_scatter'
,
'log_loss'
,
'sequence_topk_avg_pooling'
,
'matmul'
,
'add_position_encoding'
,
'margin_rank_loss'
,
'elementwise_pow'
,
'fused_elemwise_activation'
,
'tree_conv'
,
'mul'
,
'teacher_student_sigmoid_loss'
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录