Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
42f569fd
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
42f569fd
编写于
9月 14, 2018
作者:
T
Tomasz Patejko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MKLDNN conv + elementwise_add fusion: use_mkldnn attribute added
上级
441d3a47
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
18 deletion
+19
-18
paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc
...uid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc
+19
-18
未找到文件。
paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.cc
浏览文件 @
42f569fd
...
@@ -39,25 +39,25 @@ struct Conv {
...
@@ -39,25 +39,25 @@ struct Conv {
std
::
function
<
PDNode
*
()
>
operator
()(
std
::
shared_ptr
<
Pattern
>
pattern
)
{
std
::
function
<
PDNode
*
()
>
operator
()(
std
::
shared_ptr
<
Pattern
>
pattern
)
{
return
[
&
]()
->
PDNode
*
{
return
[
&
]()
->
PDNode
*
{
auto
conv_op
=
pattern
->
new_node
(
op_name
())
auto
conv_op
=
pattern
->
new_node
(
op_name
())
->
assert_is_op
(
"conv2d"
);
->
assert_is_op
(
"conv2d"
);
auto
input_var
=
pattern
->
new_node
(
input_name
())
auto
input_var
=
pattern
->
new_node
(
input_name
())
->
assert_is_op_input
(
op_name
(),
->
assert_is_op_input
(
op_name
(),
input_name
());
input_name
());
auto
filter_var
=
pattern
->
new_node
(
filter_name
())
auto
filter_var
=
pattern
->
new_node
(
filter_name
())
->
assert_is_op_input
(
op_name
(),
->
assert_is_op_input
(
op_name
(),
filter_name
());
filter_name
());
auto
output_var
=
pattern
->
new_node
(
output_name
())
auto
output_var
=
pattern
->
new_node
(
output_name
())
->
assert_is_op_output
(
op_name
(),
->
assert_is_op_output
(
op_name
(),
output_name
());
output_name
());
conv_op
->
LinksFrom
({
input_var
,
filter_var
});
conv_op
->
LinksFrom
({
input_var
,
filter_var
});
conv_op
->
LinksTo
({
output_var
});
conv_op
->
LinksTo
({
output_var
});
return
output_var
;
return
output_var
;
};
};
}
}
};
};
...
@@ -139,7 +139,7 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
...
@@ -139,7 +139,7 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
conv_output
->
AsIntermediate
();
conv_output
->
AsIntermediate
();
auto
fuse_conv
=
[
&
](
Graph
*
g
,
Node
*
conv_input
,
Node
*
conv_filter
,
Node
*
y
)
{
auto
fuse_conv
=
[](
Graph
*
g
,
Node
*
conv_input
,
Node
*
conv_filter
,
Node
*
y
)
{
OpDesc
op_desc
;
OpDesc
op_desc
;
op_desc
.
SetType
(
"conv2d"
);
op_desc
.
SetType
(
"conv2d"
);
...
@@ -147,7 +147,8 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
...
@@ -147,7 +147,8 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
op_desc
.
SetInput
(
"Filter"
,
{
conv_filter
->
Name
()});
op_desc
.
SetInput
(
"Filter"
,
{
conv_filter
->
Name
()});
op_desc
.
SetOutput
(
"Output"
,
{
y
->
Name
()});
op_desc
.
SetOutput
(
"Output"
,
{
y
->
Name
()});
op_desc
.
SetAttr
(
"fuse_sum"
,
true
);
op_desc
.
SetAttr
(
"use_mkldnn"
,
true
);
op_desc
.
SetAttr
(
"fuse_eltwise"
,
true
);
auto
fused_conv_op
=
g
->
CreateOpNode
(
&
op_desc
);
auto
fused_conv_op
=
g
->
CreateOpNode
(
&
op_desc
);
...
@@ -175,7 +176,7 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
...
@@ -175,7 +176,7 @@ graph_ptr ConvElementwiseAddMKLDNNFusePass::ApplyImpl(graph_ptr graph) const {
fuse_conv
(
g
,
conv_input
,
conv_filter
,
elementwise_add_y
);
fuse_conv
(
g
,
conv_input
,
conv_filter
,
elementwise_add_y
);
patterns
::
CorrectGraphEdges
(
g
,
elementwise_add_out
,
elementwise_add_y
);
patterns
::
CorrectGraphEdges
(
g
,
elementwise_add_out
,
elementwise_add_y
);
patterns
::
GraphSafeRemoveNodes
(
g
,
{
conv_output
,
elementwise_add_out
,
conv_op
,
elementwise_add_op
});
GraphSafeRemoveNodes
(
g
,
{
conv_output
,
elementwise_add_out
,
conv_op
,
elementwise_add_op
});
};
};
gpd
(
graph
.
get
(),
handler
);
gpd
(
graph
.
get
(),
handler
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录