Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
9894a4fb
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9894a4fb
编写于
12月 18, 2019
作者:
J
juncaipeng
提交者:
Tao Luo
12月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test precision from fp32 to fp64, test=develop (#21783)
上级
c96f06f2
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
80 addition
and
80 deletion
+80
-80
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_min_op.py
+23
-23
python/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
+16
-16
python/paddle/fluid/tests/unittests/test_expand_op.py
python/paddle/fluid/tests/unittests/test_expand_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_flatten2_op.py
python/paddle/fluid/tests/unittests/test_flatten2_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_flatten_op.py
python/paddle/fluid/tests/unittests/test_flatten_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
...addle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gather_nd_op.py
python/paddle/fluid/tests/unittests/test_gather_nd_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_gather_op.py
python/paddle/fluid/tests/unittests/test_gather_op.py
+6
-6
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
+7
-7
python/paddle/fluid/tests/unittests/test_gru_op.py
python/paddle/fluid/tests/unittests/test_gru_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_kldiv_loss_op.py
python/paddle/fluid/tests/unittests/test_kldiv_loss_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
+6
-6
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
...n/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
+2
-2
未找到文件。
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
浏览文件 @
9894a4fb
...
...
@@ -25,9 +25,9 @@ class TestElementwiseOp(OpTest):
# If x and y have the same value, the min() is not differentiable.
# So we generate test data by the following method
# to avoid them being too close to each other.
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
"float
32
"
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
[
13
,
17
]).
astype
(
"float
32
"
)
y
=
x
+
sgn
*
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
"float
32
"
)
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
"float
64
"
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
[
13
,
17
]).
astype
(
"float
64
"
)
y
=
x
+
sgn
*
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
outputs
=
{
'Out'
:
np
.
minimum
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -49,8 +49,8 @@ class TestElementwiseOp(OpTest):
class
TestElementwiseMinOp_scalar
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
random_integers
(
-
5
,
5
,
[
10
,
3
,
4
]).
astype
(
"float
32
"
)
y
=
np
.
array
([
0.5
]).
astype
(
"float
32
"
)
x
=
np
.
random
.
random_integers
(
-
5
,
5
,
[
10
,
3
,
4
]).
astype
(
"float
64
"
)
y
=
np
.
array
([
0.5
]).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
outputs
=
{
'Out'
:
np
.
minimum
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -58,9 +58,9 @@ class TestElementwiseMinOp_scalar(TestElementwiseOp):
class
TestElementwiseMinOp_Vector
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
random
((
100
,
)).
astype
(
"float
32
"
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
100
,
)).
astype
(
"float
32
"
)
y
=
x
+
sgn
*
np
.
random
.
uniform
(
0.1
,
1
,
(
100
,
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
100
,
)).
astype
(
"float
64
"
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
100
,
)).
astype
(
"float
64
"
)
y
=
x
+
sgn
*
np
.
random
.
uniform
(
0.1
,
1
,
(
100
,
)).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
outputs
=
{
'Out'
:
np
.
minimum
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -68,10 +68,10 @@ class TestElementwiseMinOp_Vector(TestElementwiseOp):
class
TestElementwiseMinOp_broadcast_0
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
32
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
2
,
)).
astype
(
np
.
float
32
)
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
64
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
2
,
)).
astype
(
np
.
float
64
)
y
=
x
[:,
0
,
0
]
+
sgn
*
\
np
.
random
.
uniform
(
1
,
2
,
(
2
,
)).
astype
(
np
.
float
32
)
np
.
random
.
uniform
(
1
,
2
,
(
2
,
)).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
attrs
=
{
'axis'
:
0
}
...
...
@@ -84,10 +84,10 @@ class TestElementwiseMinOp_broadcast_0(TestElementwiseOp):
class
TestElementwiseMinOp_broadcast_1
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
32
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
3
,
)).
astype
(
np
.
float
32
)
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
64
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
3
,
)).
astype
(
np
.
float
64
)
y
=
x
[
0
,
:,
0
]
+
sgn
*
\
np
.
random
.
uniform
(
1
,
2
,
(
3
,
)).
astype
(
np
.
float
32
)
np
.
random
.
uniform
(
1
,
2
,
(
3
,
)).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -100,10 +100,10 @@ class TestElementwiseMinOp_broadcast_1(TestElementwiseOp):
class
TestElementwiseMinOp_broadcast_2
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
32
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
4
,
)).
astype
(
np
.
float
32
)
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
)).
astype
(
np
.
float
64
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
4
,
)).
astype
(
np
.
float
64
)
y
=
x
[
0
,
0
,
:]
+
sgn
*
\
np
.
random
.
uniform
(
1
,
2
,
(
4
,
)).
astype
(
np
.
float
32
)
np
.
random
.
uniform
(
1
,
2
,
(
4
,
)).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
outputs
=
{
...
...
@@ -115,10 +115,10 @@ class TestElementwiseMinOp_broadcast_2(TestElementwiseOp):
class
TestElementwiseMinOp_broadcast_3
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
,
5
)).
astype
(
np
.
float
32
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
3
,
4
)).
astype
(
np
.
float
32
)
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
,
5
)).
astype
(
np
.
float
64
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
3
,
4
)).
astype
(
np
.
float
64
)
y
=
x
[
0
,
:,
:,
0
]
+
sgn
*
\
np
.
random
.
uniform
(
1
,
2
,
(
3
,
4
)).
astype
(
np
.
float
32
)
np
.
random
.
uniform
(
1
,
2
,
(
3
,
4
)).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
attrs
=
{
'axis'
:
1
}
...
...
@@ -131,10 +131,10 @@ class TestElementwiseMinOp_broadcast_3(TestElementwiseOp):
class
TestElementwiseMinOp_broadcast_4
(
TestElementwiseOp
):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_min"
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
,
5
)).
astype
(
np
.
float
32
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
2
,
3
,
1
,
5
)).
astype
(
np
.
float
32
)
x
=
np
.
random
.
uniform
(
0.5
,
1
,
(
2
,
3
,
4
,
5
)).
astype
(
np
.
float
64
)
sgn
=
np
.
random
.
choice
([
-
1
,
1
],
(
2
,
3
,
1
,
5
)).
astype
(
np
.
float
64
)
y
=
x
+
sgn
*
\
np
.
random
.
uniform
(
1
,
2
,
(
2
,
3
,
1
,
5
)).
astype
(
np
.
float
32
)
np
.
random
.
uniform
(
1
,
2
,
(
2
,
3
,
1
,
5
)).
astype
(
np
.
float
64
)
self
.
inputs
=
{
'X'
:
x
,
'Y'
:
y
}
self
.
outputs
=
{
'Out'
:
np
.
minimum
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
python/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
浏览文件 @
9894a4fb
...
...
@@ -23,8 +23,8 @@ class TestElementwisePowOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
]).
astype
(
"float
32
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
]).
astype
(
"float
32
"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
]).
astype
(
"float
64
"
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
]).
astype
(
"float
64
"
)
}
self
.
outputs
=
{
'Out'
:
np
.
power
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -39,8 +39,8 @@ class TestElementwisePowOp_scalar(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
3
,
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
,
[
3
,
3
,
4
]).
astype
(
np
.
float
64
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
]).
astype
(
np
.
float
64
)
}
self
.
outputs
=
{
'Out'
:
np
.
power
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -49,8 +49,8 @@ class TestElementwisePowOp_tensor(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
.
power
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -59,8 +59,8 @@ class TestElementwisePowOp_broadcast_0(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
=
{
'Out'
:
np
.
power
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
@@ -69,8 +69,8 @@ class TestElementwisePowOp_broadcast_1(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
}
self
.
outputs
=
{
...
...
@@ -82,8 +82,8 @@ class TestElementwisePowOp_broadcast_2(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
}
self
.
outputs
=
{
...
...
@@ -95,8 +95,8 @@ class TestElementwisePowOp_broadcast_3(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
}
self
.
outputs
=
{
...
...
@@ -109,8 +109,8 @@ class TestElementwisePowOp_broadcast_4(TestElementwisePowOp):
def
setUp
(
self
):
self
.
op_type
=
"elementwise_pow"
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
.
power
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])}
...
...
python/paddle/fluid/tests/unittests/test_expand_op.py
浏览文件 @
9894a4fb
...
...
@@ -27,7 +27,7 @@ class TestExpandOpRank1(OpTest):
self
.
op_type
=
"expand"
self
.
init_data
()
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
)}
self
.
attrs
=
{
'expand_times'
:
self
.
expand_times
}
output
=
np
.
tile
(
self
.
inputs
[
'X'
],
self
.
expand_times
)
self
.
outputs
=
{
'Out'
:
output
}
...
...
@@ -84,7 +84,7 @@ class TestExpandOpRank1_tensor_attr(OpTest):
(
1
)).
astype
(
'int32'
)
*
ele
))
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
),
'expand_times_tensor'
:
expand_times_tensor
,
}
self
.
attrs
=
{
"expand_times"
:
self
.
infer_expand_times
}
...
...
@@ -124,7 +124,7 @@ class TestExpandOpRank1_tensor(OpTest):
self
.
init_data
()
self
.
inputs
=
{
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
32
"
),
'X'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float
64
"
),
'ExpandTimes'
:
np
.
array
(
self
.
expand_times
).
astype
(
"int32"
),
}
self
.
attrs
=
{}
...
...
python/paddle/fluid/tests/unittests/test_flatten2_op.py
浏览文件 @
9894a4fb
...
...
@@ -24,7 +24,7 @@ class TestFlattenOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"flatten2"
self
.
init_test_case
()
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
in_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
in_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
),
...
...
python/paddle/fluid/tests/unittests/test_flatten_op.py
浏览文件 @
9894a4fb
...
...
@@ -24,7 +24,7 @@ class TestFlattenOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"flatten"
self
.
init_test_case
()
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
in_shape
).
astype
(
"float
32
"
)}
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
in_shape
).
astype
(
"float
64
"
)}
self
.
init_attrs
()
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
new_shape
)}
...
...
python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py
浏览文件 @
9894a4fb
...
...
@@ -29,7 +29,7 @@ class TestFusedEmbeddingSeqPoolOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"fused_embedding_seq_pool"
self
.
emb_size
=
6
self
.
table
=
np
.
random
.
random
((
17
,
self
.
emb_size
)).
astype
(
"float
32
"
)
self
.
table
=
np
.
random
.
random
((
17
,
self
.
emb_size
)).
astype
(
"float
64
"
)
self
.
ids
=
np
.
array
([[[
4
],
[
3
]],
[[
4
],
[
3
]],
[[
2
],
[
1
]],
[[
16
],
[
1
]]]).
astype
(
"int64"
)
ids_expand
=
np
.
expand_dims
(
self
.
ids
,
axis
=
1
)
...
...
python/paddle/fluid/tests/unittests/test_gather_nd_op.py
浏览文件 @
9894a4fb
...
...
@@ -27,7 +27,7 @@ class TestGatherNdOpWithEmptyIndex(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"gather_nd"
xnp
=
np
.
random
.
random
((
5
,
20
)).
astype
(
"float
32
"
)
xnp
=
np
.
random
.
random
((
5
,
20
)).
astype
(
"float
64
"
)
self
.
inputs
=
{
'X'
:
xnp
,
'Index'
:
np
.
array
([[],
[]]).
astype
(
"int32"
)}
self
.
outputs
=
{
'Out'
:
np
.
vstack
((
xnp
[
np
.
newaxis
,
:],
xnp
[
np
.
newaxis
,
:]))
...
...
@@ -48,7 +48,7 @@ class TestGatherNdOpWithLowIndex(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"gather_nd"
xnp
=
np
.
array
(
[[
65
,
17
,
2
],
[
14
,
25
,
1
],
[
76
,
22
,
3
]]).
astype
(
"float
32
"
)
[[
65
,
17
,
2
],
[
14
,
25
,
1
],
[
76
,
22
,
3
]]).
astype
(
"float
64
"
)
index
=
np
.
array
([[
1
],
[
2
]]).
astype
(
"int64"
)
self
.
inputs
=
{
'X'
:
xnp
,
'Index'
:
index
}
...
...
@@ -91,7 +91,7 @@ class TestGatherNdOpWithHighRankSame(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"gather_nd"
shape
=
(
20
,
9
,
8
,
1
,
31
)
xnp
=
np
.
random
.
rand
(
*
shape
)
xnp
=
np
.
random
.
rand
(
*
shape
)
.
astype
(
"float64"
)
index
=
np
.
vstack
([
np
.
random
.
randint
(
0
,
s
,
size
=
150
)
for
s
in
shape
]).
T
self
.
inputs
=
{
'X'
:
xnp
,
'Index'
:
index
.
astype
(
"int32"
)}
...
...
@@ -112,7 +112,7 @@ class TestGatherNdOpWithHighRankDiff(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"gather_nd"
shape
=
(
20
,
9
,
8
,
1
,
31
)
xnp
=
np
.
random
.
rand
(
*
shape
).
astype
(
"
double
"
)
xnp
=
np
.
random
.
rand
(
*
shape
).
astype
(
"
float64
"
)
index
=
np
.
vstack
([
np
.
random
.
randint
(
0
,
s
,
size
=
1000
)
for
s
in
shape
]).
T
index_re
=
index
.
reshape
([
10
,
5
,
20
,
5
])
...
...
python/paddle/fluid/tests/unittests/test_gather_op.py
浏览文件 @
9894a4fb
...
...
@@ -41,7 +41,7 @@ class TestGatherOp(OpTest):
For multi-dimension input
"""
self
.
x_shape
=
(
10
,
20
)
self
.
x_type
=
"float
32
"
self
.
x_type
=
"float
64
"
self
.
index
=
[
1
,
3
,
5
]
self
.
index_type
=
"int32"
...
...
@@ -52,7 +52,7 @@ class TestCase1(TestGatherOp):
For one dimension input
"""
self
.
x_shape
=
(
100
)
self
.
x_type
=
"float
32
"
self
.
x_type
=
"float
64
"
self
.
index
=
[
1
,
3
,
5
]
self
.
index_type
=
"int32"
...
...
@@ -63,7 +63,7 @@ class TestCase2(TestGatherOp):
For int64_t index type
"""
self
.
x_shape
=
(
10
)
self
.
x_type
=
"float
32
"
self
.
x_type
=
"float
64
"
self
.
index
=
[
1
,
3
,
5
]
self
.
index_type
=
"int64"
...
...
@@ -74,7 +74,7 @@ class TestCase3(TestGatherOp):
For other input type
"""
self
.
x_shape
=
(
10
,
20
)
self
.
x_type
=
"
double
"
self
.
x_type
=
"
float64
"
self
.
index
=
[
1
,
3
,
5
]
self
.
index_type
=
"int64"
...
...
@@ -92,7 +92,7 @@ class TestCase5(TestGatherOp):
def
config
(
self
):
self
.
x_shape
=
(
10
,
20
)
self
.
attrs
=
{
'overwrite'
:
False
}
self
.
x_type
=
"float"
self
.
x_type
=
"float
64
"
self
.
index
=
[
1
,
1
,
3
]
self
.
index_type
=
"int32"
...
...
@@ -101,7 +101,7 @@ class TestCase6(TestGatherOp):
def
config
(
self
):
self
.
x_shape
=
(
10
,
20
)
self
.
attrs
=
{
'overwrite'
:
True
}
self
.
x_type
=
"float"
self
.
x_type
=
"float
64
"
self
.
index
=
[
1
,
3
]
self
.
index_type
=
"int32"
...
...
python/paddle/fluid/tests/unittests/test_grid_sampler_op.py
浏览文件 @
9894a4fb
...
...
@@ -34,7 +34,7 @@ def AffineGrid(theta, size):
for
i
in
range
(
len
(
theta
)):
ret
[
i
]
=
np
.
dot
(
grid
[
i
].
reshape
([
h
*
w
,
3
]),
theta
[
i
])
return
ret
.
reshape
([
n
,
h
,
w
,
2
]).
astype
(
"float
32
"
)
return
ret
.
reshape
([
n
,
h
,
w
,
2
]).
astype
(
"float
64
"
)
def
getGridPointValue
(
data
,
x
,
y
):
...
...
@@ -43,7 +43,7 @@ def getGridPointValue(data, x, y):
H
=
data_shape
[
2
]
W
=
data_shape
[
3
]
out
=
np
.
zeros
(
data_shape
,
dtype
=
'float'
)
out
=
np
.
zeros
(
data_shape
,
dtype
=
'float
64
'
)
for
i
in
range
(
N
):
for
j
in
range
(
H
):
for
k
in
range
(
W
):
...
...
@@ -68,8 +68,8 @@ def GridSampler(data, grid):
y_max
=
H
-
1
x_max
=
W
-
1
x
=
0.5
*
((
x
.
astype
(
'float
32
'
)
+
1.0
)
*
x_max
)
y
=
0.5
*
((
y
.
astype
(
'float
32
'
)
+
1.0
)
*
y_max
)
x
=
0.5
*
((
x
.
astype
(
'float
64
'
)
+
1.0
)
*
x_max
)
y
=
0.5
*
((
y
.
astype
(
'float
64
'
)
+
1.0
)
*
y_max
)
x0
=
np
.
floor
(
x
).
astype
(
'int32'
)
x1
=
x0
+
1
...
...
@@ -86,7 +86,7 @@ def GridSampler(data, grid):
vc
=
getGridPointValue
(
data
,
x1
,
y0
)
vd
=
getGridPointValue
(
data
,
x1
,
y1
)
out
=
(
wa
*
va
+
wb
*
vb
+
wc
*
vc
+
wd
*
vd
).
astype
(
'float
32
'
)
out
=
(
wa
*
va
+
wb
*
vb
+
wc
*
vc
+
wd
*
vd
).
astype
(
'float
64
'
)
return
out
...
...
@@ -94,9 +94,9 @@ class TestGridSamplerOp(OpTest):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
op_type
=
'grid_sampler'
x
=
np
.
random
.
randint
(
0
,
255
,
self
.
x_shape
).
astype
(
'float
32
'
)
x
=
np
.
random
.
randint
(
0
,
255
,
self
.
x_shape
).
astype
(
'float
64
'
)
theta
=
np
.
zeros
(
self
.
theta_shape
).
astype
(
'float
32
'
)
theta
=
np
.
zeros
(
self
.
theta_shape
).
astype
(
'float
64
'
)
for
i
in
range
(
self
.
theta_shape
[
0
]):
for
j
in
range
(
2
):
for
k
in
range
(
3
):
...
...
python/paddle/fluid/tests/unittests/test_gru_op.py
浏览文件 @
9894a4fb
...
...
@@ -170,20 +170,20 @@ class TestGRUOriginMode(TestGRUOp):
class
TestGRUOp2
(
TestGRUOp
):
def
set_confs
(
self
):
self
.
D
=
19
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestGRUOp2Len0
(
TestGRUOp
):
def
set_confs
(
self
):
self
.
D
=
19
self
.
lod
=
[[
2
,
0
,
4
]]
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
class
TestGRUOp2OriginMode
(
TestGRUOp
):
def
set_confs
(
self
):
self
.
D
=
19
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
self
.
origin_mode
=
True
...
...
@@ -191,7 +191,7 @@ class TestGRUOp2OriginModeLen0(TestGRUOp):
def
set_confs
(
self
):
self
.
D
=
19
self
.
lod
=
[[
0
,
3
,
4
]]
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
self
.
origin_mode
=
True
...
...
@@ -199,7 +199,7 @@ class TestGRUOp2OriginModeLastLen0(TestGRUOp):
def
set_confs
(
self
):
self
.
D
=
19
self
.
lod
=
[[
0
,
3
,
0
]]
self
.
dtype
=
'float
32
'
self
.
dtype
=
'float
64
'
self
.
origin_mode
=
True
...
...
python/paddle/fluid/tests/unittests/test_kldiv_loss_op.py
浏览文件 @
9894a4fb
...
...
@@ -36,8 +36,8 @@ class TestKLDivLossOp(OpTest):
def
setUp
(
self
):
self
.
initTestCase
()
self
.
op_type
=
'kldiv_loss'
x
=
np
.
random
.
uniform
(
-
10
,
10
,
self
.
x_shape
).
astype
(
'float
32
'
)
target
=
np
.
random
.
uniform
(
-
10
,
10
,
self
.
x_shape
).
astype
(
'float
32
'
)
x
=
np
.
random
.
uniform
(
-
10
,
10
,
self
.
x_shape
).
astype
(
'float
64
'
)
target
=
np
.
random
.
uniform
(
-
10
,
10
,
self
.
x_shape
).
astype
(
'float
64
'
)
self
.
attrs
=
{
"reduction"
:
self
.
reduction
}
...
...
@@ -46,7 +46,7 @@ class TestKLDivLossOp(OpTest):
'Target'
:
target
,
}
loss
=
kldiv_loss
(
x
,
target
,
self
.
reduction
)
self
.
outputs
=
{
'Loss'
:
loss
.
astype
(
'float
32
'
)}
self
.
outputs
=
{
'Loss'
:
loss
.
astype
(
'float
64
'
)}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
浏览文件 @
9894a4fb
...
...
@@ -22,7 +22,7 @@ from op_test import OpTest
class
TestLodResetOpByAttr
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lod_reset"
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
64
"
)
lod
=
[[
3
,
2
,
5
]]
# target_offset_lod and target_lod are the same lod info represented
# in offset-based format and length-based format, respectively.
...
...
@@ -45,7 +45,7 @@ class TestLodResetOpByAttr(OpTest):
class
TestLodResetOpByInput
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lod_reset"
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
64
"
)
lod
=
[[
3
,
2
,
5
]]
# target_offset_lod and target_lod are the same lod info represented
# in offset-based format and length-based format, respectively.
...
...
@@ -69,7 +69,7 @@ class TestLodResetOpByInput(OpTest):
class
TestLodResetOpBoth
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lod_reset"
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
64
"
)
lod
=
[[
3
,
2
,
5
]]
target_offset_lod_attr
=
[
0
,
7
,
10
]
target_offset_lod_in
=
[
0
,
4
,
7
,
10
]
...
...
@@ -93,9 +93,9 @@ class TestLodResetOpBoth(OpTest):
class
TestLodResetOpYIsLoDTensor
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lod_reset"
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
64
"
)
lod
=
[[
3
,
2
,
5
]]
y
=
np
.
random
.
random
((
10
,
10
)).
astype
(
"float
32
"
)
y
=
np
.
random
.
random
((
10
,
10
)).
astype
(
"float
64
"
)
target_lod
=
[[
4
,
3
,
3
]]
self
.
inputs
=
{
'X'
:
(
x
,
lod
),
'Y'
:
(
y
,
target_lod
)}
self
.
outputs
=
{
'Out'
:
(
x
,
target_lod
)}
...
...
@@ -112,7 +112,7 @@ class TestLodResetOpYIsLoDTensor(OpTest):
class
TestLodAppendOpByAttr
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lod_reset"
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
32
"
)
x
=
np
.
random
.
random
((
10
,
20
)).
astype
(
"float
64
"
)
lod
=
[[
3
,
2
,
5
]]
# target_offset_lod and target_lod are the same lod info represented
# in offset-based format and length-based format, respectively.
...
...
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
浏览文件 @
9894a4fb
...
...
@@ -27,7 +27,7 @@ from paddle.fluid import Program, program_guard
class
TestLookupTableOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lookup_table"
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
32
"
)
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
64
"
)
ids
=
np
.
random
.
randint
(
0
,
17
,
4
).
astype
(
"int64"
)
ids_expand
=
np
.
expand_dims
(
ids
,
axis
=
1
)
self
.
inputs
=
{
'W'
:
table
,
'Ids'
:
ids_expand
}
...
...
@@ -43,7 +43,7 @@ class TestLookupTableOp(OpTest):
class
TestLookupTableOpWithTensorIds
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lookup_table"
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
32
"
)
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
64
"
)
ids
=
np
.
random
.
randint
(
low
=
0
,
high
=
17
,
size
=
(
2
,
4
,
5
,
1
)).
astype
(
"int64"
)
self
.
inputs
=
{
'W'
:
table
,
'Ids'
:
ids
}
...
...
python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py
浏览文件 @
9894a4fb
...
...
@@ -28,7 +28,7 @@ from paddle.fluid import Program, program_guard
class
TestLookupTableOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lookup_table_v2"
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
32
"
)
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
64
"
)
ids
=
np
.
random
.
randint
(
0
,
17
,
4
).
astype
(
"int64"
)
self
.
inputs
=
{
'W'
:
table
,
'Ids'
:
ids
}
self
.
outputs
=
{
'Out'
:
table
[
ids
]}
...
...
@@ -43,7 +43,7 @@ class TestLookupTableOp(OpTest):
class
TestLookupTableOpWithTensorIds
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"lookup_table_v2"
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
32
"
)
table
=
np
.
random
.
random
((
17
,
31
)).
astype
(
"float
64
"
)
ids
=
np
.
random
.
randint
(
low
=
0
,
high
=
17
,
size
=
(
2
,
4
,
5
)).
astype
(
"int64"
)
self
.
inputs
=
{
'W'
:
table
,
'Ids'
:
ids
}
self
.
outputs
=
{
'Out'
:
table
[
ids
.
flatten
()].
reshape
((
2
,
4
,
5
,
31
))}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录