Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c6b7b2ad
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
c6b7b2ad
编写于
6月 28, 2023
作者:
C
Charles-hit
提交者:
GitHub
6月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support some prim ops zero dim part2 (#54907)
上级
87f72107
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
130 addition
and
7 deletion
+130
-7
test/legacy_test/test_assign_op.py
test/legacy_test/test_assign_op.py
+10
-1
test/legacy_test/test_erf_op.py
test/legacy_test/test_erf_op.py
+9
-1
test/legacy_test/test_expand_as_v2_op.py
test/legacy_test/test_expand_as_v2_op.py
+25
-0
test/legacy_test/test_expand_v2_op.py
test/legacy_test/test_expand_v2_op.py
+25
-2
test/legacy_test/test_flatten2_op.py
test/legacy_test/test_flatten2_op.py
+7
-0
test/legacy_test/test_full_like_op.py
test/legacy_test/test_full_like_op.py
+7
-0
test/legacy_test/test_gather_nd_op.py
test/legacy_test/test_gather_nd_op.py
+27
-0
test/legacy_test/test_reduce_op.py
test/legacy_test/test_reduce_op.py
+20
-3
未找到文件。
test/legacy_test/test_assign_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -32,10 +32,14 @@ class TestAssignOp(eager_op_test.OpTest):
self
.
public_python_api
=
paddle
.
assign
self
.
op_type
=
"assign"
self
.
prim_op_type
=
"prim"
x
=
np
.
random
.
random
(
size
=
(
100
,
10
)).
astype
(
'float64'
)
self
.
init_input_configs
()
x
=
np
.
random
.
random
(
size
=
self
.
shape
).
astype
(
'float64'
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
x
}
def
init_input_configs
(
self
):
self
.
shape
=
(
100
,
10
)
def
test_forward
(
self
):
paddle
.
enable_static
()
self
.
check_output
()
...
...
@@ -47,6 +51,11 @@ class TestAssignOp(eager_op_test.OpTest):
paddle
.
disable_static
()
class
TestAssignOp_ZeroDim
(
TestAssignOp
):
def
init_input_configs
(
self
):
self
.
shape
=
()
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_cuda
(),
"FP16 test runs only on GPU"
)
...
...
test/legacy_test/test_erf_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -30,12 +30,15 @@ class TestErfOp(OpTest):
self
.
public_python_api
=
paddle
.
erf
self
.
python_api
=
paddle
.
erf
self
.
dtype
=
self
.
_init_dtype
()
self
.
x_shape
=
[
11
,
17
]
self
.
init_shape
()
x
=
np
.
random
.
uniform
(
-
1
,
1
,
size
=
self
.
x_shape
).
astype
(
self
.
dtype
)
y_ref
=
erf
(
x
).
astype
(
self
.
dtype
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
y_ref
}
def
init_shape
(
self
):
self
.
x_shape
=
[
11
,
17
]
def
_init_dtype
(
self
):
return
"float64"
...
...
@@ -46,6 +49,11 @@ class TestErfOp(OpTest):
self
.
check_grad
([
'X'
],
'Out'
,
check_prim
=
True
)
class
TestErfOp_ZeroDim
(
TestErfOp
):
def
init_shape
(
self
):
self
.
x_shape
=
[]
class
TestErfLayer
(
unittest
.
TestCase
):
def
_test_case
(
self
,
place
):
x
=
np
.
random
.
uniform
(
-
1
,
1
,
size
=
(
11
,
17
)).
astype
(
np
.
float64
)
...
...
test/legacy_test/test_expand_as_v2_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -54,6 +54,31 @@ class TestExpandAsBasic(OpTest):
self
.
check_grad
([
'X'
],
'Out'
,
check_prim
=
True
)
class
TestExpandAs_ZeroDim1
(
TestExpandAsBasic
):
def
init_inputs_and_outputs
(
self
):
x
=
np
.
random
.
random
(()).
astype
(
self
.
dtype
)
target_tensor
=
np
.
random
.
random
(
1
).
astype
(
self
.
dtype
)
self
.
inputs
=
{
'X'
:
x
,
"Y"
:
target_tensor
}
self
.
attrs
=
{
'target_shape'
:
target_tensor
.
shape
}
bcast_dims
=
[
1
]
output
=
np
.
tile
(
self
.
inputs
[
'X'
],
bcast_dims
)
self
.
outputs
=
{
'Out'
:
output
}
class
TestExpandAs_ZeroDim2
(
TestExpandAsBasic
):
def
init_inputs_and_outputs
(
self
):
x
=
np
.
random
.
random
(()).
astype
(
self
.
dtype
)
target_tensor
=
np
.
random
.
random
(()).
astype
(
self
.
dtype
)
self
.
inputs
=
{
'X'
:
x
,
"Y"
:
target_tensor
}
self
.
attrs
=
{
'target_shape'
:
target_tensor
.
shape
}
bcast_dims
=
[]
output
=
np
.
tile
(
self
.
inputs
[
'X'
],
bcast_dims
)
self
.
outputs
=
{
'Out'
:
output
}
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
...
...
test/legacy_test/test_expand_v2_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -36,20 +36,43 @@ class TestExpandV2OpRank1(OpTest):
self
.
attrs
=
{
'shape'
:
self
.
shape
}
output
=
np
.
tile
(
self
.
inputs
[
'X'
],
self
.
expand_times
)
self
.
outputs
=
{
'Out'
:
output
}
self
.
enable_cinn
=
True
self
.
if_enable_cinn
()
def
init_data
(
self
):
self
.
ori_shape
=
[
100
]
self
.
shape
=
[
100
]
self
.
expand_times
=
[
1
]
def
if_enable_cinn
(
self
):
pass
def
test_check_output
(
self
):
self
.
check_output
(
check_cinn
=
self
.
enable_cinn
)
self
.
check_output
(
check_cinn
=
True
)
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
check_prim
=
True
)
class
TestExpandV2OpRank1_ZeroDim1
(
TestExpandV2OpRank1
):
def
init_data
(
self
):
self
.
ori_shape
=
[]
self
.
shape
=
[
10
]
self
.
expand_times
=
[
10
]
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestExpandV2OpRank1_ZeroDim2
(
TestExpandV2OpRank1
):
def
init_data
(
self
):
self
.
ori_shape
=
[]
self
.
shape
=
[]
self
.
expand_times
=
[]
def
if_enable_cinn
(
self
):
pass
class
TestExpandV2OpRank2_DimExpanding
(
TestExpandV2OpRank1
):
def
init_data
(
self
):
self
.
ori_shape
=
[
120
]
...
...
test/legacy_test/test_flatten2_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -44,6 +44,13 @@ class TestFlattenOp(OpTest):
self
.
attrs
=
{
"axis"
:
self
.
axis
}
class
TestFlattenOp_ZeroDim
(
TestFlattenOp
):
def
init_test_case
(
self
):
self
.
in_shape
=
()
self
.
axis
=
0
self
.
new_shape
=
1
class
TestFlattenOp1
(
TestFlattenOp
):
def
init_test_case
(
self
):
self
.
in_shape
=
(
3
,
2
,
5
,
4
)
...
...
test/legacy_test/test_full_like_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -142,6 +142,13 @@ class TestFullLikeOp1(OpTest):
pass
class
TestFullLikeOp1_ZeroDim
(
TestFullLikeOp1
):
def
init_data
(
self
):
self
.
fill_value
=
5
self
.
shape
=
[]
self
.
dtype
=
np
.
float32
class
TestFullLikeOp2
(
TestFullLikeOp1
):
def
init_data
(
self
):
self
.
fill_value
=
1000
...
...
test/legacy_test/test_gather_nd_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -122,6 +122,33 @@ class TestGatherNdOpWithIndex1(OpTest):
self
.
check_grad
([
'X'
],
'Out'
,
check_prim
=
True
)
class
TestGatherNdOpWithIndex1_ZeroDim
(
TestGatherNdOpWithIndex1
):
def
setUp
(
self
):
self
.
op_type
=
"gather_nd"
self
.
prim_op_type
=
"prim"
self
.
python_api
=
paddle
.
gather_nd
self
.
public_python_api
=
paddle
.
gather_nd
self
.
config_dtype
()
self
.
if_enable_cinn
()
if
self
.
dtype
==
np
.
float64
:
target_dtype
=
"float64"
elif
self
.
dtype
==
np
.
float16
:
target_dtype
=
"float16"
else
:
target_dtype
=
"float32"
xnp
=
np
.
random
.
random
((
100
,)).
astype
(
target_dtype
)
index
=
np
.
array
([
1
]).
astype
(
"int32"
)
output
=
xnp
[
index
[
-
1
]]
if
self
.
dtype
==
np
.
uint16
:
xnp
=
convert_float_to_uint16
(
xnp
)
output
=
convert_float_to_uint16
(
output
)
self
.
inputs
=
{
'X'
:
xnp
,
'Index'
:
index
}
self
.
outputs
=
{
'Out'
:
output
}
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestGatherNdOpWithIndex1FP16
(
TestGatherNdOpWithIndex1
):
def
config_dtype
(
self
):
self
.
dtype
=
np
.
float16
...
...
test/legacy_test/test_reduce_op.py
浏览文件 @
c6b7b2ad
...
...
@@ -279,15 +279,18 @@ class TestMaxOp_ZeroDim(OpTest):
self
.
python_api
=
paddle
.
max
self
.
public_python_api
=
paddle
.
max
self
.
if_enable_cinn
()
self
.
init_inputs_and_outputs
()
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
def
init_inputs_and_outputs
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
random
([]).
astype
(
"float64"
)}
self
.
attrs
=
{
'dim'
:
[]}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
].
max
(
axis
=
tuple
(
self
.
attrs
[
'dim'
]))
}
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
def
test_check_output
(
self
):
self
.
check_output
()
...
...
@@ -301,6 +304,20 @@ class TestMaxOp_ZeroDim(OpTest):
)
class
TestMaxOp_ZeroDim1
(
TestMaxOp_ZeroDim
):
def
init_inputs_and_outputs
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
random
([
5
]).
astype
(
"float64"
)}
self
.
attrs
=
{
'dim'
:
[
0
]}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
].
max
(
axis
=
(
0
,))}
class
TestMaxOp_ZeroDim2
(
TestMaxOp_ZeroDim1
):
def
init_inputs_and_outputs
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
random
([
5
,
20
]).
astype
(
"float64"
)}
self
.
attrs
=
{
'dim'
:
[
0
,
1
]}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
].
max
(
axis
=
(
0
,
1
))}
class
TestMaxFP32Op
(
OpTest
):
"""Remove Max with subgradient from gradient check to confirm the success of CI."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录