Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞不过沧海
Paddle
提交
cd84e1bf
P
Paddle
项目概览
飞不过沧海
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cd84e1bf
编写于
9月 06, 2022
作者:
N
niuliling123
提交者:
GitHub
9月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix layout autotune in windows ci (#45751)
上级
98a5af1a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
29 deletion
+64
-29
paddle/fluid/eager/api/manual/eager_manual/forwards/conv2d_fwd_function.cc
...r/api/manual/eager_manual/forwards/conv2d_fwd_function.cc
+5
-2
python/paddle/fluid/tests/unittests/test_layout_autotune.py
python/paddle/fluid/tests/unittests/test_layout_autotune.py
+59
-27
未找到文件。
paddle/fluid/eager/api/manual/eager_manual/forwards/conv2d_fwd_function.cc
浏览文件 @
cd84e1bf
...
...
@@ -86,7 +86,8 @@ paddle::experimental::Tensor conv2d_dygraph_function(
auto
transformer
=
egr
::
EagerLayoutAutotune
<
std
::
string
>
(
op_name
,
tensors_vector
,
&
data_format
);
auto
NEW_input
=
transformer
->
TransInTensor
(
"input"
,
input
);
bool
is_enable_tune
=
paddle
::
imperative
::
LayoutAutoTune
::
Instance
().
UseLayoutAutoTune
();
paddle
::
imperative
::
LayoutAutoTune
::
Instance
().
DisableLayoutAutoTune
();
auto
out
=
conv2d_dygraph_function
(
NEW_input
,
filter
,
...
...
@@ -100,7 +101,9 @@ paddle::experimental::Tensor conv2d_dygraph_function(
workspace_size_MB
,
exhaustive_search
);
transformer
->
SetOutTensorLayout
(
&
out
);
paddle
::
imperative
::
LayoutAutoTune
::
Instance
().
EnableLayoutAutoTune
();
if
(
is_enable_tune
)
{
paddle
::
imperative
::
LayoutAutoTune
::
Instance
().
EnableLayoutAutoTune
();
}
// Returns
return
out
;
}
...
...
python/paddle/fluid/tests/unittests/test_layout_autotune.py
浏览文件 @
cd84e1bf
...
...
@@ -46,6 +46,9 @@ class SimpleNet(paddle.nn.Layer):
class
LayoutAutoTune
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
use_autoune
()
def
use_autoune
(
self
):
if
paddle
.
is_compiled_with_cuda
():
paddle
.
incubate
.
autotune
.
set_config
(
...
...
@@ -85,16 +88,18 @@ class LayoutAutoTune(unittest.TestCase):
def
test_enable_autotune
(
self
):
if
self
.
use_autoune
():
conv_out
,
predict
=
self
.
train
(
data_format
=
"NCHW"
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
14
,
8
])
self
.
assertEqual
(
predict
.
shape
,
[
1
,
2
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
14
,
8
])
self
.
assertEqual
(
predict
.
shape
,
[
1
,
2
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
14
])
self
.
assertEqual
(
predict
.
shape
,
[
1
,
2
])
else
:
conv_out
,
predict
=
self
.
train
(
data_format
=
"NCHW"
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
14
])
self
.
assertEqual
(
predict
.
shape
,
[
1
,
2
])
def
test_transpose_op_transposer
(
self
):
if
not
self
.
use_autoune
():
return
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
label_data
=
paddle
.
randint
(
0
,
1
,
shape
=
[
1
,
1
],
dtype
=
"int64"
)
...
...
@@ -112,12 +117,14 @@ class LayoutAutoTune(unittest.TestCase):
scaled
.
backward
()
scaler
.
minimize
(
optimizer
,
scaled
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
12
,
8
,
14
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
12
,
8
,
14
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
12
,
8
,
14
])
def
test_flatten_op_transposer
(
self
):
if
not
self
.
use_autoune
():
return
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
flatten
=
paddle
.
nn
.
Flatten
(
start_axis
=
1
,
stop_axis
=
2
)
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
...
...
@@ -129,25 +136,42 @@ class LayoutAutoTune(unittest.TestCase):
# because it flatten the C and H dimensions.
out
=
flatten
(
conv_out
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
112
,
12
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
112
,
12
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
112
,
12
])
def
test_argmax_op_transposer_keep_dims
(
self
):
if
not
self
.
use_autoune
():
return
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
with
paddle
.
amp
.
auto_cast
(
level
=
"O2"
):
conv_out
=
conv
(
data
)
# conv_out.shape = [1, 14, 12, 8] with NHWC
out
=
paddle
.
argmax
(
conv_out
,
axis
=
1
,
keepdim
=
True
)
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
14
,
12
,
1
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
1
,
14
,
12
])
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
,
14
,
12
,
1
])
def
test_argmax_op_transposer_ff
(
self
):
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
with
paddle
.
amp
.
auto_cast
(
level
=
"O2"
):
conv_out
=
conv
(
data
)
# conv_out.shape = [1, 14, 12, 8] with NHWC
out
=
paddle
.
argmax
(
conv_out
)
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
1
])
def
test_argmax_op_transposer
(
self
):
if
not
self
.
use_autoune
():
return
def
test_argmax_op_transposer_t
(
self
):
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
with
paddle
.
amp
.
auto_cast
(
level
=
"O2"
):
...
...
@@ -155,12 +179,14 @@ class LayoutAutoTune(unittest.TestCase):
# conv_out.shape = [1, 14, 12, 8] with NHWC
out
=
paddle
.
argmax
(
conv_out
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
1
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
1
])
def
test_concat_op_transposer
(
self
):
if
not
self
.
use_autoune
():
return
in1
=
paddle
.
rand
([
1
,
8
,
14
,
12
])
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
...
...
@@ -169,12 +195,14 @@ class LayoutAutoTune(unittest.TestCase):
# conv_out.shape = [1, 14, 12, 8] with NHWC
out
=
paddle
.
concat
(
x
=
[
conv_out
,
in1
],
axis
=
0
)
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
8
,
14
,
12
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
8
,
14
,
12
])
else
:
self
.
assertEqual
(
conv_out
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
8
,
14
,
12
])
def
test_concat_op_no_transposer
(
self
):
if
not
self
.
use_autoune
():
return
conv
=
paddle
.
nn
.
Conv2D
(
3
,
8
,
(
3
,
3
))
data1
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
data2
=
paddle
.
rand
([
1
,
3
,
16
,
14
])
...
...
@@ -184,8 +212,12 @@ class LayoutAutoTune(unittest.TestCase):
# conv_out.shape = [1, 14, 12, 8] with NHWC
out
=
paddle
.
concat
(
x
=
[
conv_out1
,
conv_out2
],
axis
=
0
)
self
.
assertEqual
(
conv_out1
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
14
,
12
,
8
])
if
paddle
.
fluid
.
core
.
use_layout_autotune
():
self
.
assertEqual
(
conv_out1
.
shape
,
[
1
,
14
,
12
,
8
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
14
,
12
,
8
])
else
:
self
.
assertEqual
(
conv_out1
.
shape
,
[
1
,
8
,
14
,
12
])
self
.
assertEqual
(
out
.
shape
,
[
2
,
8
,
14
,
12
])
class
TestAutoTuneAPI
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录