Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5bb9deb3
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5bb9deb3
编写于
12月 19, 2019
作者:
J
juncaipeng
提交者:
Tao Luo
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the precision of some op tests from fp32 to fp64 (#21774)
上级
a86f11b5
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
90 addition
and
83 deletion
+90
-83
python/paddle/fluid/tests/unittests/test_activation_op.py
python/paddle/fluid/tests/unittests/test_activation_op.py
+10
-3
python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py
...le/fluid/tests/unittests/test_add_position_encoding_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_assign_op.py
python/paddle/fluid/tests/unittests/test_assign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
...n/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py
.../fluid/tests/unittests/test_bilinear_tensor_product_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_center_loss.py
python/paddle/fluid/tests/unittests/test_center_loss.py
+5
-5
python/paddle/fluid/tests/unittests/test_concat_op.py
python/paddle/fluid/tests/unittests/test_concat_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_crop_op.py
python/paddle/fluid/tests/unittests/test_crop_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_crop_tensor_op.py
python/paddle/fluid/tests/unittests/test_crop_tensor_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py
...on/paddle/fluid/tests/unittests/test_cross_entropy2_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_add_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_div_op.py
+23
-23
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
+22
-22
未找到文件。
python/paddle/fluid/tests/unittests/test_activation_op.py
浏览文件 @
5bb9deb3
...
...
@@ -42,7 +42,6 @@ class TestSqrtOpError(unittest.TestCase):
class
TestActivation
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"exp"
self
.
dtype
=
np
.
float32
self
.
init_dtype
()
self
.
init_kernel_type
()
...
...
@@ -61,7 +60,7 @@ class TestActivation(OpTest):
self
.
check_grad
([
'X'
],
'Out'
)
def
init_dtype
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_kernel_type
(
self
):
pass
...
...
@@ -78,6 +77,9 @@ class TestSigmoid(TestActivation):
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
x
)}
self
.
outputs
=
{
'Out'
:
out
}
def
init_dtype
(
self
):
self
.
dtype
=
np
.
float32
def
test_check_grad
(
self
):
if
self
.
dtype
==
np
.
float16
:
return
...
...
@@ -105,7 +107,6 @@ class TestTanh(TestActivation):
def
setUp
(
self
):
self
.
op_type
=
"tanh"
self
.
init_dtype
()
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
11
,
17
]).
astype
(
self
.
dtype
)
out
=
np
.
tanh
(
x
)
...
...
@@ -117,6 +118,12 @@ class TestTanh(TestActivation):
return
self
.
check_grad
([
'X'
],
'Out'
)
def
init_dtype
(
self
):
#TODO If dtype is float64, the output (Out) has diff at CPUPlace
# when using and not using inplace. Therefore, set dtype as float32
# for now.
self
.
dtype
=
np
.
float32
class
TestAtan
(
TestActivation
):
def
setUp
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py
浏览文件 @
5bb9deb3
...
...
@@ -28,7 +28,7 @@ class TestAddPositionEncodingTensorOp(OpTest):
the prepared section for add position encoding op
"""
self
.
op_type
=
"add_position_encoding"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_input_output
()
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
self
.
x
),
}
...
...
@@ -82,7 +82,7 @@ class TestAddPositionEncodingLoDTensorOp(OpTest):
the prepared section for add position encoding LoDTensor op
"""
self
.
op_type
=
"add_position_encoding"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_input_output
()
self
.
inputs
=
{
'X'
:
(
self
.
x
,
self
.
lod
),
}
...
...
python/paddle/fluid/tests/unittests/test_assign_op.py
浏览文件 @
5bb9deb3
...
...
@@ -26,7 +26,7 @@ from paddle.fluid import compiler, Program, program_guard
class
TestAssignOp
(
op_test
.
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"assign"
x
=
np
.
random
.
random
(
size
=
(
100
,
10
))
x
=
np
.
random
.
random
(
size
=
(
100
,
10
))
.
astype
(
'float64'
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
x
}
...
...
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
浏览文件 @
5bb9deb3
...
...
@@ -100,7 +100,7 @@ class TestBilinearInterpOp(OpTest):
self
.
data_layout
=
'NCHW'
self
.
init_test_case
()
self
.
op_type
=
"bilinear_interp"
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
32
"
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
64
"
)
if
self
.
data_layout
==
"NCHW"
:
in_h
=
self
.
input_shape
[
2
]
...
...
@@ -402,7 +402,7 @@ class TestBilinearInterpOp_attr_tensor(OpTest):
'align_corners'
:
self
.
align_corners
,
}
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
32
"
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
input_np
}
if
self
.
scale_by_1Dtensor
:
...
...
python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py
浏览文件 @
5bb9deb3
...
...
@@ -26,11 +26,11 @@ class TestBilinearTensorProductOp(OpTest):
size0
=
5
size1
=
4
size2
=
5
a
=
np
.
random
.
random
((
batch_size
,
size0
)).
astype
(
"float
32
"
)
b
=
np
.
random
.
random
((
batch_size
,
size1
)).
astype
(
"float
32
"
)
w
=
np
.
random
.
random
((
size2
,
size0
,
size1
)).
astype
(
"float
32
"
)
bias
=
np
.
random
.
random
((
1
,
size2
)).
astype
(
"float
32
"
)
output
=
np
.
zeros
((
batch_size
,
size2
)).
astype
(
"float
32
"
)
a
=
np
.
random
.
random
((
batch_size
,
size0
)).
astype
(
"float
64
"
)
b
=
np
.
random
.
random
((
batch_size
,
size1
)).
astype
(
"float
64
"
)
w
=
np
.
random
.
random
((
size2
,
size0
,
size1
)).
astype
(
"float
64
"
)
bias
=
np
.
random
.
random
((
1
,
size2
)).
astype
(
"float
64
"
)
output
=
np
.
zeros
((
batch_size
,
size2
)).
astype
(
"float
64
"
)
for
i
in
range
(
size2
):
w_i
=
w
[
i
,
:,
:]
output
[:,
i
]
=
np
.
sum
(
np
.
matmul
(
a
,
w_i
)
*
b
,
axis
=
1
)
...
...
python/paddle/fluid/tests/unittests/test_center_loss.py
浏览文件 @
5bb9deb3
...
...
@@ -23,7 +23,7 @@ import paddle.fluid.core as core
class
TestCenterLossOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"center_loss"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_dtype_type
()
batch_size
=
12
feet_dim
=
10
...
...
@@ -34,9 +34,9 @@ class TestCenterLossOp(OpTest):
self
.
config
()
self
.
attrs
[
'need_update'
]
=
self
.
need_update
labels
=
np
.
random
.
randint
(
cluster_num
,
size
=
batch_size
,
dtype
=
'int64'
)
feat
=
np
.
random
.
random
((
batch_size
,
feet_dim
)).
astype
(
np
.
float
32
)
centers
=
np
.
random
.
random
((
cluster_num
,
feet_dim
)).
astype
(
np
.
float
32
)
var_sum
=
np
.
zeros
((
cluster_num
,
feet_dim
),
dtype
=
np
.
float
32
)
feat
=
np
.
random
.
random
((
batch_size
,
feet_dim
)).
astype
(
np
.
float
64
)
centers
=
np
.
random
.
random
((
cluster_num
,
feet_dim
)).
astype
(
np
.
float
64
)
var_sum
=
np
.
zeros
((
cluster_num
,
feet_dim
),
dtype
=
np
.
float
64
)
centers_select
=
centers
[
labels
]
output
=
feat
-
centers_select
diff_square
=
np
.
square
(
output
).
reshape
(
batch_size
,
feet_dim
)
...
...
@@ -51,7 +51,7 @@ class TestCenterLossOp(OpTest):
var_sum
[
i
]
/=
(
1
+
cout
[
i
])
var_sum
*=
0.1
result
=
centers
+
var_sum
rate
=
np
.
array
([
0.1
]).
astype
(
np
.
float
32
)
rate
=
np
.
array
([
0.1
]).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
feat
,
...
...
python/paddle/fluid/tests/unittests/test_concat_op.py
浏览文件 @
5bb9deb3
...
...
@@ -40,7 +40,7 @@ class TestConcatOp(OpTest):
}
def
get_dtype
(
self
):
return
"float
32
"
return
"float
64
"
def
test_check_output
(
self
):
self
.
check_output
()
...
...
python/paddle/fluid/tests/unittests/test_crop_op.py
浏览文件 @
5bb9deb3
...
...
@@ -49,13 +49,13 @@ class TestCropOp(OpTest):
self
.
initTestCase
()
if
self
.
crop_by_input
:
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
random
(
self
.
crop_shape
).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
random
(
self
.
crop_shape
).
astype
(
"float
64
"
)
}
else
:
self
.
attrs
[
'shape'
]
=
self
.
crop_shape
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
}
if
self
.
offset_by_input
:
self
.
inputs
[
'Offsets'
]
=
np
.
array
(
self
.
offsets
).
astype
(
'int32'
)
...
...
python/paddle/fluid/tests/unittests/test_crop_tensor_op.py
浏览文件 @
5bb9deb3
...
...
@@ -52,13 +52,13 @@ class TestCropTensorOp(OpTest):
if
self
.
shape_by_input
:
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
'Shape'
:
np
.
array
(
self
.
crop_shape
).
astype
(
"int32"
)
}
else
:
self
.
attrs
[
'shape'
]
=
self
.
crop_shape
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
}
if
self
.
offset_by_input
:
self
.
inputs
[
'Offsets'
]
=
np
.
array
(
self
.
offsets
).
astype
(
'int32'
)
...
...
@@ -144,7 +144,7 @@ class TestCropTensorOpTensorAttr(OpTest):
shape_tensor
.
append
((
"x"
+
str
(
index
),
np
.
ones
(
(
1
)).
astype
(
'int32'
)
*
ele
))
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
'ShapeTensor'
:
shape_tensor
}
self
.
attrs
[
'shape'
]
=
self
.
shape_attr
...
...
@@ -155,7 +155,7 @@ class TestCropTensorOpTensorAttr(OpTest):
offsets_tensor
.
append
((
"x"
+
str
(
index
),
np
.
ones
(
(
1
)).
astype
(
'int32'
)
*
ele
))
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
x_shape
).
astype
(
"float
64
"
),
'OffsetsTensor'
:
offsets_tensor
}
self
.
attrs
[
'offsets'
]
=
self
.
offsets_attr
...
...
python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py
浏览文件 @
5bb9deb3
...
...
@@ -20,7 +20,7 @@ import six
class
CrossEntropy2OpTestBase
(
OpTest
):
def
initParameters
(
self
):
return
[
32
,
64
],
'float
32
'
,
-
100
,
False
return
[
32
,
64
],
'float
64
'
,
-
100
,
False
def
calc_output
(
self
,
logits
,
label
,
ignore_index
):
ret
=
np
.
zeros
(
shape
=
label
.
shape
,
dtype
=
logits
.
dtype
)
...
...
@@ -78,17 +78,17 @@ class CrossEntropy2OpTest2RemoveLastDim(CrossEntropy2OpTestBase):
class
CrossEntropy2OpTest3
(
CrossEntropy2OpTestBase
):
def
initParameters
(
self
):
return
[
4
,
8
,
16
,
32
],
'float
32
'
,
-
100
,
False
return
[
4
,
8
,
16
,
32
],
'float
64
'
,
-
100
,
False
class
CrossEntropy2OpTest3RemoveLastDim
(
CrossEntropy2OpTestBase
):
def
initParameters
(
self
):
return
[
4
,
8
,
16
,
32
],
'float
32
'
,
-
100
,
True
return
[
4
,
8
,
16
,
32
],
'float
64
'
,
-
100
,
True
class
CrossEntropy2OpTest4
(
CrossEntropy2OpTestBase
):
def
initParameters
(
self
):
return
[
4
,
8
,
16
,
32
],
'float
32
'
,
3
,
False
return
[
4
,
8
,
16
,
32
],
'float
64
'
,
3
,
False
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
浏览文件 @
5bb9deb3
...
...
@@ -112,7 +112,7 @@ class TestCrossEntropyOp2(TestCrossEntropyOp):
self
.
soft_label
=
True
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_bs_class_num
(
self
):
self
.
batch_size
=
5
...
...
@@ -142,7 +142,7 @@ class TestCrossEntropyOp3(TestCrossEntropyOp):
self
.
soft_label
=
True
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_bs_class_num
(
self
):
self
.
batch_size
=
5
...
...
@@ -229,7 +229,7 @@ class TestCrossEntropyOp5(TestCrossEntropyOp):
self
.
soft_label
=
True
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_bs_class_num
(
self
):
self
.
class_num
=
37
...
...
@@ -269,7 +269,7 @@ class TestCrossEntropyOp6(TestCrossEntropyOp):
self
.
soft_label
=
True
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
def
init_bs_class_num
(
self
):
self
.
class_num
=
17
...
...
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
浏览文件 @
5bb9deb3
...
...
@@ -27,7 +27,7 @@ class TestElementwiseAddOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_add"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
axis
=
-
1
self
.
init_dtype
()
self
.
init_input_output
()
...
...
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
浏览文件 @
5bb9deb3
...
...
@@ -22,7 +22,7 @@ from op_test import OpTest
class
ElementwiseDivOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
init_dtype
()
""" Warning
CPU gradient check error!
...
...
@@ -57,8 +57,8 @@ class TestElementwiseDivOp_scalar(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
]).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
]).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
...
...
@@ -67,8 +67,8 @@ class TestElementwiseDivOp_Vector(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
32
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
32
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
32
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
32
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -77,8 +77,8 @@ class TestElementwiseDivOp_broadcast_0(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
]).
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'axis'
:
0
}
...
...
@@ -92,8 +92,8 @@ class TestElementwiseDivOp_broadcast_1(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
3
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
3
]).
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -107,8 +107,8 @@ class TestElementwiseDivOp_broadcast_2(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
4
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
4
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
...
...
@@ -121,8 +121,8 @@ class TestElementwiseDivOp_broadcast_3(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
4
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
4
]).
astype
(
"float
64
"
)
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -136,8 +136,8 @@ class TestElementwiseDivOp_broadcast_4(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
4
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
4
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -146,8 +146,8 @@ class TestElementwiseDivOp_broadcast_5(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
5
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
5
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -156,8 +156,8 @@ class TestElementwiseDivOp_commonuse_1(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
1
,
4
]).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
1
,
4
]).
astype
(
"float
64
"
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -166,8 +166,8 @@ class TestElementwiseDivOp_commonuse_2(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
5
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
4
,
1
]).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
5
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
4
,
1
]).
astype
(
"float
64
"
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -176,8 +176,8 @@ class TestElementwiseDivOp_xsize_lessthan_ysize(ElementwiseDivOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_div"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
5
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
4
,
5
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
64
"
),
}
self
.
attrs
=
{
'axis'
:
2
}
...
...
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
浏览文件 @
5bb9deb3
...
...
@@ -28,7 +28,7 @@ class ElementwiseMulOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_mul"
self
.
dtype
=
np
.
float
32
self
.
dtype
=
np
.
float
64
self
.
axis
=
-
1
self
.
init_dtype
()
self
.
init_input_output
()
...
...
@@ -83,8 +83,8 @@ class TestElementwiseMulOp_scalar(ElementwiseMulOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_mul"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
10
,
3
,
4
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
1
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
10
,
3
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
1
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
*
self
.
inputs
[
'Y'
]}
self
.
init_kernel_type
()
...
...
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
浏览文件 @
5bb9deb3
...
...
@@ -22,8 +22,8 @@ class TestElementwiseOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
5
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -46,8 +46,8 @@ class TestElementwiseSubOp_scalar(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
10
,
3
,
4
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
1
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
10
,
3
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
1
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -56,8 +56,8 @@ class TestElementwiseSubOp_Vector(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
100
,
)).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
random
((
100
,
)).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
random
((
100
,
)).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
random
((
100
,
)).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -66,8 +66,8 @@ class TestElementwiseSubOp_broadcast_0(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
13
,
4
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
2
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
13
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
2
).
astype
(
np
.
float
64
)
}
self
.
attrs
=
{
'axis'
:
0
}
...
...
@@ -80,8 +80,8 @@ class TestElementwiseSubOp_broadcast_1(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
3
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
3
).
astype
(
np
.
float
64
)
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -94,8 +94,8 @@ class TestElementwiseSubOp_broadcast_2(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
4
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
4
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
...
...
@@ -107,8 +107,8 @@ 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
.
float
32
),
'Y'
:
np
.
random
.
rand
(
3
,
4
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
3
,
4
).
astype
(
np
.
float
64
)
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -121,8 +121,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
.
float
32
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -131,8 +131,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
.
float
32
),
'Y'
:
np
.
random
.
rand
(
1
,
1
,
4
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
4
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
1
,
1
,
4
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -141,8 +141,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
.
float
32
),
'Y'
:
np
.
random
.
rand
(
2
,
1
,
4
,
1
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
2
,
3
,
1
,
5
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
2
,
1
,
4
,
1
).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
...
...
@@ -151,8 +151,8 @@ class TestElementwiseSubOp_xsize_lessthan_ysize(TestElementwiseOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_sub"
self
.
inputs
=
{
'X'
:
np
.
random
.
rand
(
4
,
5
).
astype
(
np
.
float
32
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float
32
)
'X'
:
np
.
random
.
rand
(
4
,
5
).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
rand
(
2
,
3
,
4
,
5
).
astype
(
np
.
float
64
)
}
self
.
attrs
=
{
'axis'
:
2
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录