Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ccfe7681
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
ccfe7681
编写于
3月 09, 2023
作者:
W
Weilong Wu
提交者:
GitHub
3月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support reshape test on prim and cinn (#51276)
* support reshape test on prim and cinn * fix mkldnn test * polish test case
上级
782454bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
8 deletion
+47
-8
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+2
-1
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
...le/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
+23
-3
python/paddle/fluid/tests/unittests/test_reshape_op.py
python/paddle/fluid/tests/unittests/test_reshape_op.py
+21
-4
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
...luid/tests/unittests/white_list/check_shape_white_list.py
+1
-0
未找到文件。
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
ccfe7681
...
...
@@ -1219,7 +1219,8 @@ set(TEST_CINN_OPS
test_elementwise_mul_op
test_gather_nd_op
test_elementwise_pow_op
test_transpose_op
)
test_transpose_op
test_reshape_op
)
foreach
(
TEST_CINN_OPS
${
TEST_CINN_OPS
}
)
if
(
WITH_CINN
)
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
浏览文件 @
ccfe7681
...
...
@@ -19,22 +19,36 @@ import numpy as np
import
paddle
import
paddle.fluid.core
as
core
from
paddle.fluid.tests.unittests.op_test
import
(
OpTest
,
OpTestTool
,
convert_float_to_uint16
,
)
from
paddle.fluid.tests.unittests.test_reshape_op
import
TestReshapeOp
paddle
.
enable_static
()
class
TestReshape2OneDNNOp
(
TestReshapeOp
):
class
TestReshape2OneDNNOp
(
OpTest
):
def
setUp
(
self
):
super
().
setUp
()
self
.
init_data
()
self
.
op_type
=
"reshape2"
self
.
python_api
=
paddle
.
tensor
.
reshape
self
.
python_out_sig
=
[
'Out'
]
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"shape"
:
self
.
new_shape
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
infered_shape
),
'XShape'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
),
}
self
.
x
=
self
.
inputs
[
"X"
]
self
.
attrs
[
'use_mkldnn'
]
=
True
self
.
set_additional_inputs
()
self
.
set_outputs
()
def
init_data
(
self
):
self
.
ori_shape
=
(
2
,
60
)
self
.
new_shape
=
(
12
,
10
)
self
.
infered_shape
=
(
12
,
10
)
def
init_dtype
(
self
):
self
.
dtype
=
np
.
float32
...
...
@@ -44,6 +58,12 @@ class TestReshape2OneDNNOp(TestReshapeOp):
def
set_outputs
(
self
):
pass
def
test_check_output
(
self
):
self
.
check_output
(
no_check_set
=
[
'XShape'
])
def
test_check_grad
(
self
):
self
.
check_grad
([
"X"
],
"Out"
)
class
TestReshape2OneDNNOpDimInfer1
(
TestReshape2OneDNNOp
):
def
init_data
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_reshape_op.py
浏览文件 @
ccfe7681
...
...
@@ -27,6 +27,7 @@ class TestReshapeOp(OpTest):
def
setUp
(
self
):
self
.
init_data
()
self
.
op_type
=
"reshape2"
self
.
prim_op_type
=
"prim"
self
.
python_api
=
paddle
.
tensor
.
reshape
self
.
python_out_sig
=
[
'Out'
]
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
)}
...
...
@@ -45,17 +46,31 @@ class TestReshapeOp(OpTest):
self
.
check_output
(
no_check_set
=
[
'XShape'
])
def
test_check_grad
(
self
):
self
.
check_grad
([
"X"
],
"Out"
)
self
.
check_grad
([
"X"
],
"Out"
,
check_prim
=
True
)
class
TestReshapeOp_ZeroDim1
(
TestReshapeOp
):
def
setUp
(
self
):
self
.
init_data
()
self
.
op_type
=
"reshape2"
self
.
prim_op_type
=
"prim"
self
.
enable_cinn
=
False
self
.
python_api
=
paddle
.
tensor
.
reshape
self
.
python_out_sig
=
[
'Out'
]
self
.
inputs
=
{
"X"
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
)}
self
.
attrs
=
{
"shape"
:
self
.
new_shape
}
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
infered_shape
),
'XShape'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
),
}
class
TestReshapeOp_ZeroDim1
(
OpTest
):
def
init_data
(
self
):
self
.
ori_shape
=
()
self
.
new_shape
=
(
1
,)
self
.
infered_shape
=
(
1
,)
class
TestReshapeOp_ZeroDim2
(
OpTest
):
class
TestReshapeOp_ZeroDim2
(
TestReshapeOp_ZeroDim1
):
def
init_data
(
self
):
self
.
ori_shape
=
()
self
.
new_shape
=
(
-
1
,)
...
...
@@ -73,6 +88,8 @@ class TestReshapeBF16Op(OpTest):
def
setUp
(
self
):
self
.
init_data
()
self
.
op_type
=
"reshape2"
self
.
prim_op_type
=
"prim"
self
.
enable_cinn
=
False
self
.
python_api
=
paddle
.
tensor
.
reshape
self
.
python_out_sig
=
[
'Out'
]
self
.
dtype
=
np
.
uint16
...
...
@@ -96,7 +113,7 @@ class TestReshapeBF16Op(OpTest):
self
.
check_output
(
no_check_set
=
[
'XShape'
])
def
test_check_grad
(
self
):
self
.
check_grad
([
"X"
],
"Out"
)
self
.
check_grad
([
"X"
],
"Out"
,
check_prim
=
True
)
class
TestReshapeOpDimInfer1
(
TestReshapeOp
):
...
...
python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py
浏览文件 @
ccfe7681
...
...
@@ -30,4 +30,5 @@ NEED_TO_FIX_OP_LIST = [
'rnn'
,
'multi_dot'
,
'index_add'
,
'reshape2'
,
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录