Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2f6c3315
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
2f6c3315
编写于
12月 06, 2022
作者:
J
Jacek Czaja
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- UT reshape onednn
- Fix test test2 - test4 - test5 - test6 test7 - test8 - Ut reinvented - cosmetic
上级
c2f15f05
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
46 deletion
+21
-46
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
...le/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
+19
-43
python/paddle/fluid/tests/unittests/test_reshape_op.py
python/paddle/fluid/tests/unittests/test_reshape_op.py
+2
-3
未找到文件。
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_mkldnn_op.py
浏览文件 @
2f6c3315
# Copyright (c) 202
1
PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 202
2
PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -23,51 +23,26 @@ from paddle.fluid.tests.unittests.op_test import (
OpTestTool
,
convert_float_to_uint16
,
)
from
paddle.fluid.tests.unittests.test_reshape_op
import
TestReshapeOp
paddle
.
enable_static
()
@
OpTestTool
.
skip_if
(
core
.
is_compiled_with_cuda
(),
"CUDA has to be skipped because it forces dygraph"
,
)
class
TestReshape2OneDNNOp
(
OpTest
):
class
TestReshapeOneDNNOp
(
TestReshapeOp
):
def
setUp
(
self
):
self
.
init_data
()
self
.
set_op_type
()
self
.
x
=
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
)
self
.
set_inputs
()
super
().
setUp
()
self
.
attrs
[
'use_mkldnn'
]
=
True
self
.
set_additional_inputs
()
self
.
set_attrs
()
self
.
set_outputs
()
def
set_op_type
(
self
):
self
.
op_type
=
"reshape2"
def
set_inputs
(
self
):
self
.
inputs
=
{
"X"
:
self
.
x
}
def
init_dtype
(
self
):
self
.
dtype
=
np
.
float32
def
set_additional_inputs
(
self
):
pass
def
set_attrs
(
self
):
self
.
attrs
=
{
"shape"
:
self
.
new_shape
,
'use_mkldnn'
:
True
}
pass
def
set_outputs
(
self
):
self
.
outputs
=
{
"Out"
:
self
.
inputs
[
"X"
].
reshape
(
self
.
infered_shape
),
'XShape'
:
np
.
random
.
random
(
self
.
ori_shape
).
astype
(
"float32"
),
}
def
init_data
(
self
):
self
.
ori_shape
=
(
2
,
60
)
self
.
new_shape
=
(
12
,
10
)
self
.
infered_shape
=
(
12
,
10
)
def
test_check_output
(
self
):
self
.
check_output
(
no_check_set
=
[
'XShape'
])
def
test_check_grad
(
self
):
self
.
check_grad
([
"X"
],
"Out"
)
pass
class
TestReshape2OneDNNOpDimInfer1
(
TestReshape2OneDNNOp
):
def
init_data
(
self
):
...
...
@@ -96,8 +71,6 @@ class TestReshape2OneDNNOp_attr_OnlyShape(TestReshape2OneDNNOp):
def
set_additional_inputs
(
self
):
self
.
inputs
[
"Shape"
]
=
np
.
array
(
self
.
new_shape
,
dtype
=
"int32"
)
def
set_attrs
(
self
):
self
.
attrs
=
{
'use_mkldnn'
:
True
}
def
set_outputs
(
self
):
self
.
outputs
=
{
...
...
@@ -153,7 +126,8 @@ class TestReshape2OneDNNOpDimInfer1_attr_ShapeTensorAndShape(
class
TestReshapeOneDNNOp
(
TestReshape2OneDNNOp
):
def
set_op_type
(
self
):
def
setUp
(
self
):
super
().
setUp
()
self
.
op_type
=
"reshape"
def
set_outputs
(
self
):
...
...
@@ -171,7 +145,8 @@ class TestReshapeOneDNNOpDimInfer1(TestReshapeOneDNNOp):
class
TestReshapeOneDNNOp_attr_OnlyShape
(
TestReshape2OneDNNOp_attr_OnlyShape
):
def
set_op_type
(
self
):
def
setUp
(
self
):
super
().
setUp
()
self
.
op_type
=
"reshape"
def
set_outputs
(
self
):
...
...
@@ -195,7 +170,8 @@ class TestReshapeOneDNNOpDimInfer1_attr_OnlyShape(
def
create_reshape_bf16_test_classes
(
parent
):
@
OpTestTool
.
skip_if_not_cpu_bf16
()
class
TestReshape2BF16OneDNNOp
(
parent
):
def
set_inputs
(
self
):
def
setUp
(
self
):
super
().
setUp
()
self
.
dtype
=
np
.
uint16
self
.
inputs
=
{
"X"
:
convert_float_to_uint16
(
self
.
x
)}
...
...
@@ -223,7 +199,8 @@ def create_reshape_bf16_test_classes(parent):
globals
()[
cls_name
]
=
TestReshape2BF16OneDNNOp
class
TestReshapeBF16OneDNNOp
(
TestReshape2BF16OneDNNOp
):
def
set_op_type
(
self
):
def
setUp
(
self
):
super
().
setUp
()
self
.
dtype
=
np
.
uint16
self
.
op_type
=
"reshape"
...
...
@@ -252,5 +229,4 @@ create_reshape_bf16_test_classes(TestReshape2OneDNNOp)
create_reshape_bf16_test_classes
(
TestReshape2OneDNNOpDimInfer1
)
if
__name__
==
"__main__"
:
paddle
.
enable_static
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_reshape_op.py
浏览文件 @
2f6c3315
#
Copyright (c) 2018
PaddlePaddle Authors. All Rights Reserved.
#
Copyright (c) 2022
PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -13,10 +13,9 @@
# limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
,
convert_float_to_uint16
from
op_test
import
OpTest
,
convert_float_to_uint16
import
paddle
import
paddle.fluid
as
fluid
from
paddle.static
import
Program
,
program_guard
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录