Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
cf0e264e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
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,发现更多精彩内容 >>
提交
cf0e264e
编写于
1月 17, 2020
作者:
Z
zhupengyang
提交者:
hong19860320
1月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
all cases use large shape and skip special cases (#22332)
上级
82bc814a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
117 addition
and
108 deletion
+117
-108
python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py
.../tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py
+19
-15
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+0
-1
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_add_op.py
+73
-61
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
+24
-22
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
...luid/tests/unittests/white_list/check_shape_white_list.py
+1
-9
未找到文件。
python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py
浏览文件 @
cf0e264e
...
...
@@ -16,7 +16,7 @@ from __future__ import print_function
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
paddle.fluid.tests.unittests.op_test
import
OpTest
from
paddle.fluid.tests.unittests.op_test
import
OpTest
,
skip_check_grad_ci
from
paddle.fluid.tests.unittests.test_elementwise_add_op
import
*
'''
Some tests differ from the tests defined in test_elementwise_add_op.py
...
...
@@ -35,6 +35,8 @@ class TestMKLDNNElementwiseAddOp(TestElementwiseAddOp):
self
.
use_mkldnn
=
True
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestMKLDNNElementwiseAddOp_scalar
(
TestElementwiseAddOp_scalar
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
...
...
@@ -45,6 +47,8 @@ class TestMKLDNNElementwiseAddOp_scalar(TestElementwiseAddOp_scalar):
self
.
use_mkldnn
=
True
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1,1) to test broadcast."
)
class
TestMKLDNNElementwiseAddOp_scalar2
(
TestElementwiseAddOp_scalar2
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
...
...
@@ -62,9 +66,9 @@ class TestMKLDNNElementwiseAddOp_Vector(TestElementwiseAddOp_Vector):
class
TesMKLDNNtElementwiseAddOp_broadcast_0
(
TestElementwiseAddOp_broadcast_0
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
2
,
1
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
100
,
1
,
1
,
1
)
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
...
...
@@ -72,9 +76,9 @@ class TesMKLDNNtElementwiseAddOp_broadcast_0(TestElementwiseAddOp_broadcast_0):
class
TestMKLDNNElementwiseAddOp_broadcast_1
(
TestElementwiseAddOp_broadcast_1
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
100
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
100
,
1
,
1
)
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
...
...
@@ -82,9 +86,9 @@ class TestMKLDNNElementwiseAddOp_broadcast_1(TestElementwiseAddOp_broadcast_1):
class
TestMKLDNNElementwiseAddOp_broadcast_2
(
TestElementwiseAddOp_broadcast_2
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
1
,
4
)
self
.
x
=
np
.
random
.
rand
(
2
,
2
,
3
,
100
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
1
,
100
)
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
...
...
@@ -103,9 +107,9 @@ class TestMKLDNNElementwiseAddOp_broadcast_4(TestElementwiseAddOp_broadcast_4):
class
TestMKLDNNElementwiseAddOp_rowwise_add_0
(
TestElementwiseAddOp_rowwise_add_0
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
4
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
10
,
12
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
10
,
12
,
1
)
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
...
...
@@ -120,8 +124,8 @@ class TestMKLDNNElementwiseAddOp_rowwise_add_1(
class
TestMKLDNNElementwiseAddOp_channelwise_add
(
TestElementwiseAddOp_channelwise_add
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
3
,
5
,
20
,
20
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
1
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
,
1
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_kernel_type
(
self
):
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
cf0e264e
...
...
@@ -232,7 +232,6 @@ class OpTest(unittest.TestCase):
cls
.
op_type
)
if
not
get_numeric_gradient
.
is_large_shape
\
and
cls
.
op_type
not
in
check_shape_white_list
.
NOT_CHECK_OP_LIST
\
and
cls
.
op_type
not
in
check_shape_white_list
.
NEED_TO_FIX_OP_LIST
:
raise
AssertionError
(
"Input's shape should be large than or equal to 100 for "
+
...
...
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
浏览文件 @
cf0e264e
...
...
@@ -16,7 +16,7 @@ from __future__ import print_function
import
unittest
import
numpy
as
np
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
from
paddle.fluid
import
compiler
,
Program
,
program_guard
...
...
@@ -99,6 +99,8 @@ class TestFP16ElementwiseAddOp(TestElementwiseAddOp):
place
,
atol
=
1e-3
,
check_dygraph
=
(
self
.
use_mkldnn
==
False
))
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestElementwiseAddOp_scalar
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
...
...
@@ -106,6 +108,8 @@ class TestElementwiseAddOp_scalar(TestElementwiseAddOp):
self
.
out
=
self
.
x
+
self
.
y
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestFP16ElementwiseAddOp_scalar
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
...
...
@@ -113,6 +117,8 @@ class TestFP16ElementwiseAddOp_scalar(TestFP16ElementwiseAddOp):
self
.
out
=
self
.
x
+
self
.
y
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1,1) to test broadcast."
)
class
TestElementwiseAddOp_scalar2
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
...
...
@@ -120,6 +126,8 @@ class TestElementwiseAddOp_scalar2(TestElementwiseAddOp):
self
.
out
=
self
.
x
+
self
.
y
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1,1) to test broadcast."
)
class
TestFP16ElementwiseAddOp_scalar2
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
...
...
@@ -129,23 +137,23 @@ class TestFP16ElementwiseAddOp_scalar2(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_Vector
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
random
((
32
,
)).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
((
32
,
)).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
random
((
100
,
)).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
((
100
,
)).
astype
(
self
.
dtype
)
self
.
out
=
np
.
add
(
self
.
x
,
self
.
y
)
class
TestFP16ElementwiseAddOp_Vector
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
random
((
32
,
)).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
((
32
,
)).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
random
((
100
,
)).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
random
((
100
,
)).
astype
(
self
.
dtype
)
self
.
out
=
np
.
add
(
self
.
x
,
self
.
y
)
class
TestElementwiseAddOp_broadcast_0
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
2
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
100
,
1
,
1
)
def
init_axis
(
self
):
self
.
axis
=
0
...
...
@@ -153,9 +161,9 @@ class TestElementwiseAddOp_broadcast_0(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_broadcast_0
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
2
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
100
,
1
,
1
)
def
init_axis
(
self
):
self
.
axis
=
0
...
...
@@ -163,9 +171,9 @@ class TestFP16ElementwiseAddOp_broadcast_0(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_broadcast_1
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
100
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
100
,
1
)
def
init_axis
(
self
):
self
.
axis
=
1
...
...
@@ -173,9 +181,9 @@ class TestElementwiseAddOp_broadcast_1(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_broadcast_1
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
100
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
100
,
1
)
def
init_axis
(
self
):
self
.
axis
=
1
...
...
@@ -183,23 +191,23 @@ class TestFP16ElementwiseAddOp_broadcast_1(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_broadcast_2
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
4
)
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
100
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
100
)
class
TestFP16ElementwiseAddOp_broadcast_2
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
4
)
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
100
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
,
100
)
class
TestElementwiseAddOp_broadcast_3
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
4
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
10
,
12
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
10
,
12
,
1
)
def
init_axis
(
self
):
self
.
axis
=
1
...
...
@@ -207,9 +215,9 @@ class TestElementwiseAddOp_broadcast_3(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_broadcast_3
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
4
,
1
)
self
.
x
=
np
.
random
.
rand
(
2
,
10
,
12
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
10
,
12
,
1
)
def
init_axis
(
self
):
self
.
axis
=
1
...
...
@@ -217,9 +225,9 @@ class TestFP16ElementwiseAddOp_broadcast_3(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_broadcast_4
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
2
,
1
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
100
,
1
,
1
,
1
)
def
init_axis
(
self
):
self
.
axis
=
0
...
...
@@ -227,9 +235,9 @@ class TestElementwiseAddOp_broadcast_4(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_broadcast_4
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
2
,
1
,
1
,
1
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
100
,
1
,
1
,
1
)
def
init_axis
(
self
):
self
.
axis
=
0
...
...
@@ -237,37 +245,37 @@ class TestFP16ElementwiseAddOp_broadcast_4(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_broadcast_5
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
1
,
4
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
10
,
3
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
1
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
class
TestFP16ElementwiseAddOp_broadcast_5
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
1
,
4
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
10
,
3
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
1
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
class
TestElementwiseAddOp_broadcast_6
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
2
,
12
,
3
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
12
,
1
,
5
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
class
TestFP16ElementwiseAddOp_broadcast_6
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
2
,
12
,
3
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
12
,
1
,
5
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
class
TestElementwiseAddOp_rowwise_add_0
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
4
)
self
.
x
=
np
.
random
.
rand
(
2
,
10
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
10
,
12
)
def
init_axis
(
self
):
self
.
axis
=
1
...
...
@@ -275,17 +283,19 @@ class TestElementwiseAddOp_rowwise_add_0(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_rowwise_add_0
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
4
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
3
,
4
)
self
.
x
=
np
.
random
.
rand
(
2
,
10
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
10
,
12
)
def
init_axis
(
self
):
self
.
axis
=
1
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestElementwiseAddOp_rowwise_add_1
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
100
,
1
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
)
...
...
@@ -293,9 +303,11 @@ class TestElementwiseAddOp_rowwise_add_1(TestElementwiseAddOp):
self
.
axis
=
1
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestFP16ElementwiseAddOp_rowwise_add_1
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
100
,
1
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
.
reshape
(
1
,
1
)
...
...
@@ -305,8 +317,8 @@ class TestFP16ElementwiseAddOp_rowwise_add_1(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_channelwise_add
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
3
,
20
,
20
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
...
...
@@ -315,8 +327,8 @@ class TestElementwiseAddOp_channelwise_add(TestElementwiseAddOp):
class
TestFP16ElementwiseAddOp_channelwise_add
(
TestFP16ElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
3
,
10
,
20
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
3
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
100
,
2
,
3
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
100
,
1
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
...
...
@@ -325,8 +337,8 @@ class TestFP16ElementwiseAddOp_channelwise_add(TestFP16ElementwiseAddOp):
class
TestElementwiseAddOp_commonuse_add1
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
1
,
1
,
4
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
100
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
1
,
1
,
100
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
...
...
@@ -335,8 +347,8 @@ class TestElementwiseAddOp_commonuse_add1(TestElementwiseAddOp):
class
TestElementwiseAddOp_commonuse_add2
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
1
,
4
,
1
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
10
,
3
,
1
,
4
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
1
,
12
,
1
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
...
...
@@ -345,8 +357,8 @@ class TestElementwiseAddOp_commonuse_add2(TestElementwiseAddOp):
class
TestElementwiseAddOp_xsize_lessthan_ysize_add
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
4
,
5
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
self
.
dtype
)
self
.
x
=
np
.
random
.
rand
(
10
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
2
,
3
,
10
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
浏览文件 @
cf0e264e
...
...
@@ -15,7 +15,7 @@
from
__future__
import
print_function
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
skip_check_grad_ci
class
TestElementwiseOp
(
OpTest
):
...
...
@@ -42,6 +42,8 @@ class TestElementwiseOp(OpTest):
[
'X'
],
'Out'
,
max_relative_error
=
0.005
,
no_grad_set
=
set
(
'Y'
))
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestElementwiseSubOp_scalar
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
...
...
@@ -66,13 +68,13 @@ class TestElementwiseSubOp_broadcast_0(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
13
,
4
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
100
,
3
,
2
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
100
).
astype
(
np
.
float64
)
}
self
.
attrs
=
{
'axis'
:
0
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
2
,
1
,
1
)
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
100
,
1
,
1
)
}
...
...
@@ -80,13 +82,13 @@ class TestElementwiseSubOp_broadcast_1(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
3
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
2
,
100
,
3
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
100
).
astype
(
np
.
float64
)
}
self
.
attrs
=
{
'axis'
:
1
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
3
,
1
)
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
100
,
1
)
}
...
...
@@ -94,12 +96,12 @@ class TestElementwiseSubOp_broadcast_2(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
4
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
100
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
100
).
astype
(
np
.
float64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
1
,
4
)
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
1
,
100
)
}
...
...
@@ -107,13 +109,13 @@ class TestElementwiseSubOp_broadcast_3(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
3
,
4
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
2
,
10
,
12
,
3
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
10
,
12
).
astype
(
np
.
float64
)
}
self
.
attrs
=
{
'axis'
:
1
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
3
,
4
,
1
)
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
].
reshape
(
1
,
10
,
12
,
1
)
}
...
...
@@ -121,8 +123,8 @@ class TestElementwiseSubOp_broadcast_4(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
2
,
5
,
3
,
12
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
,
5
,
1
,
12
).
astype
(
np
.
float64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -131,8 +133,8 @@ class TestElementwiseSubOp_commonuse_1(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
1
,
1
,
4
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
100
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
1
,
1
,
100
).
astype
(
np
.
float64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -141,8 +143,8 @@ class TestElementwiseSubOp_commonuse_2(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
,
1
,
4
,
1
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
10
,
3
,
1
,
4
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
10
,
1
,
12
,
1
).
astype
(
np
.
float64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -151,14 +153,14 @@ class TestElementwiseSubOp_xsize_lessthan_ysize(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
4
,
5
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float64
)
'X'
:
np
.
random
.
rand
(
10
,
12
).
astype
(
np
.
float64
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
10
,
12
).
astype
(
np
.
float64
)
}
self
.
attrs
=
{
'axis'
:
2
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
].
reshape
(
1
,
1
,
4
,
5
)
-
self
.
inputs
[
'Y'
]
'Out'
:
self
.
inputs
[
'X'
].
reshape
(
1
,
1
,
10
,
12
)
-
self
.
inputs
[
'Y'
]
}
...
...
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
浏览文件 @
cf0e264e
...
...
@@ -12,21 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
NOT_CHECK_OP_LIST
=
[
# The increment's input must be 1-d and only has one data
'increment'
,
# elementwise ops have cases(y_shape: (1) or (1,1)) to test broadcast
'elementwise_add'
,
'elementwise_sub'
,
NEED_TO_FIX_OP_LIST
=
[
'elementwise_mul'
,
'elementwise_div'
,
'elementwise_max'
,
'elementwise_min'
,
'elementwise_pow'
,
'fused_elemwise_activation'
,
]
NEED_TO_FIX_OP_LIST
=
[
'bilinear_tensor_product'
,
'conv2d_transpose'
,
'deformable_conv'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录