Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
17c751be
P
Paddle
项目概览
PaddlePaddle
/
Paddle
12 个月 前同步成功
通知
2292
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
17c751be
编写于
7月 02, 2020
作者:
J
Jacek Czaja
提交者:
GitHub
7月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[oneDNN] Fix to
#25078
(#25256)
上级
3b8f0a64
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
11 deletion
+25
-11
paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc
paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc
+25
-11
未找到文件。
paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc
浏览文件 @
17c751be
...
...
@@ -66,17 +66,17 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
return
;
}
VLOG
(
3
)
<<
"
DNNL
Inplace op("
<<
current_op
->
id
()
<<
") "
VLOG
(
3
)
<<
"
oneDNN
Inplace op("
<<
current_op
->
id
()
<<
") "
<<
"Curr Node In: "
<<
current_op_in
->
Name
()
<<
" Curr Node out: "
<<
current_op_out
->
Name
();
VLOG
(
3
)
<<
"
DNNL
Inplace next op("
<<
next_op
->
id
()
<<
") "
VLOG
(
3
)
<<
"
oneDNN
Inplace next op("
<<
next_op
->
id
()
<<
") "
<<
" next Node out: "
<<
next_op_out
->
Name
();
auto
inputs
=
current_op
->
Op
()
->
Inputs
();
auto
outputs
=
current_op
->
Op
()
->
Outputs
();
auto
in_to_outs
=
infer_inplace
(
false
);
// strictly no CUDA for MKL-DNN
VLOG
(
3
)
<<
"
DNNL
InplaceInferer op("
<<
current_op
->
id
()
<<
") "
VLOG
(
3
)
<<
"
oneDNN
InplaceInferer op("
<<
current_op
->
id
()
<<
") "
<<
in_to_outs
.
begin
()
->
first
<<
": "
<<
inputs
[
in_to_outs
.
begin
()
->
first
][
0
]
<<
" "
<<
in_to_outs
.
begin
()
->
second
<<
": "
...
...
@@ -85,7 +85,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
auto
inplace_input_vec
=
inputs
[
in_to_outs
.
begin
()
->
first
];
if
(
std
::
find
(
inplace_input_vec
.
begin
(),
inplace_input_vec
.
end
(),
current_op_in
->
Name
())
==
inplace_input_vec
.
end
())
{
VLOG
(
3
)
<<
"
DNNL
in-place pass SKIP pattern "
;
VLOG
(
3
)
<<
"
oneDNN
in-place pass SKIP pattern "
;
return
;
}
...
...
@@ -93,7 +93,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
// is used anywhere else apart from inplaced op
auto
input_consumers
=
current_op_in
->
outputs
;
if
(
input_consumers
.
size
()
>
1
)
{
VLOG
(
3
)
<<
"
DNNL
in-place pass FAIL: in-place var cannot "
VLOG
(
3
)
<<
"
oneDNN
in-place pass FAIL: in-place var cannot "
"be an input to multiple operators"
;
return
;
}
else
{
...
...
@@ -106,7 +106,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
if
((
n
->
id
()
!=
current_op_in
->
id
())
&&
(
n
->
id
()
!=
next_op_out
->
id
())
&&
(
n
->
Name
()
==
current_op_in
->
Name
()))
{
VLOG
(
3
)
<<
"
DNNL
in-place pass FAIL var used in diffrent part of "
VLOG
(
3
)
<<
"
oneDNN
in-place pass FAIL var used in diffrent part of "
"graph "
;
return
;
}
...
...
@@ -122,7 +122,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
original_output_names
[
current_op
->
Name
()
+
current_op_in
->
Name
()]
=
current_op_out
->
Name
();
}
else
{
VLOG
(
3
)
<<
"
DNNL
Inplace: Current op already inplaced! "
;
VLOG
(
3
)
<<
"
oneDNN
Inplace: Current op already inplaced! "
;
}
// It may be that next op is reusing some of vars, we need to
...
...
@@ -133,7 +133,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
if
((
n_op_infer_inplace
==
nullptr
))
{
for
(
auto
&
m
:
n
->
outputs
)
{
if
(
m
->
Name
()
==
current_op_in
->
Name
())
{
VLOG
(
3
)
<<
"
DNNL
in-place pass FAIL: in-place var cannot "
VLOG
(
3
)
<<
"
oneDNN
in-place pass FAIL: in-place var cannot "
"be an output to non-inplaced next op"
;
return
;
}
...
...
@@ -173,7 +173,7 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
(
std
::
find
(
next_op_inplace_inputs
.
begin
(),
next_op_inplace_inputs
.
end
(),
original_name
)
!=
next_op_inplace_inputs
.
end
()))
{
VLOG
(
3
)
<<
"
DNNL
InPlace: Next Op is in-placed , updating its "
VLOG
(
3
)
<<
"
oneDNN
InPlace: Next Op is in-placed , updating its "
"input "
"and output var!"
;
next_op
->
Op
()
->
SetOutput
(
...
...
@@ -190,10 +190,24 @@ void MKLDNNInPlacePass::ApplyImpl(ir::Graph* graph) const {
next_op
->
Op
()
->
RenameInput
(
original_name
,
current_op_out
->
Name
());
found_inplace_count
++
;
VLOG
(
3
)
<<
"
DNNL
InPlace applied!"
;
VLOG
(
3
)
<<
"
oneDNN
InPlace applied!"
;
};
gpd
(
graph
,
handler
);
// TODO(jczaja): inplace pass does not influece ops inside block ops
auto
should_inplace
=
[
&
](
Graph
*
g
)
{
std
::
unordered_set
<
std
::
string
>
unwanted_ops
(
{
"conditional_block"
,
"While"
,
"while_loop"
});
for
(
auto
&
node
:
g
->
Nodes
())
{
if
(
node
->
IsOp
()
&&
unwanted_ops
.
find
(
node
->
Name
())
!=
unwanted_ops
.
end
())
{
VLOG
(
3
)
<<
"oneDNN InPlace FAILED: unsupported op: "
<<
node
->
Name
();
return
false
;
}
}
return
true
;
};
if
(
should_inplace
(
graph
))
gpd
(
graph
,
handler
);
}
}
// namespace ir
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录