Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7e964579
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看板
未验证
提交
7e964579
编写于
6月 30, 2021
作者:
W
Wangzheee
提交者:
GitHub
6月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pass_enhance] fc_lstm_fuse_pass; mul_lstm_fuse_pass (#33811)
上级
1db36584
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
152 addition
and
4 deletion
+152
-4
paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc
paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc
+147
-2
paddle/fluid/framework/ir/fc_lstm_fuse_pass.h
paddle/fluid/framework/ir/fc_lstm_fuse_pass.h
+5
-2
未找到文件。
paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc
浏览文件 @
7e964579
...
...
@@ -29,8 +29,149 @@ namespace ir {
class
Node
;
int
BuildFusion
(
Graph
*
graph
,
const
std
::
string
&
name_scope
,
Scope
*
scope
,
bool
with_fc_bias
)
{
MulLstmFusePass
::
MulLstmFusePass
()
{
AddOpCompat
(
OpCompat
(
"lstm"
))
.
AddInput
(
"Input"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"H0"
)
.
IsTensor
()
.
IsOptional
()
.
End
()
.
AddInput
(
"C0"
)
.
IsTensor
()
.
IsOptional
()
.
End
()
.
AddInput
(
"Weight"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Bias"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Hidden"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Cell"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"BatchGate"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"BatchCellPreAct"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"use_peepholes"
)
.
IsType
<
bool
>
()
.
End
()
.
AddAttr
(
"is_reverse"
)
.
IsType
<
bool
>
()
.
End
()
.
AddAttr
(
"gate_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
()
.
AddAttr
(
"cell_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
()
.
AddAttr
(
"candidate_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
();
AddOpCompat
(
OpCompat
(
"mul"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Y"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"x_num_col_dims"
)
.
IsNumEQ
(
1
)
.
End
()
.
AddAttr
(
"y_num_col_dims"
)
.
IsNumEQ
(
1
)
.
End
();
}
FCLstmFusePass
::
FCLstmFusePass
()
{
AddOpCompat
(
OpCompat
(
"lstm"
))
.
AddInput
(
"Input"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"H0"
)
.
IsTensor
()
.
IsOptional
()
.
End
()
.
AddInput
(
"C0"
)
.
IsTensor
()
.
IsOptional
()
.
End
()
.
AddInput
(
"Weight"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Bias"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Hidden"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Cell"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"BatchGate"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"BatchCellPreAct"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"use_peepholes"
)
.
IsType
<
bool
>
()
.
End
()
.
AddAttr
(
"is_reverse"
)
.
IsType
<
bool
>
()
.
End
()
.
AddAttr
(
"gate_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
()
.
AddAttr
(
"cell_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
()
.
AddAttr
(
"candidate_activation"
)
.
IsStringIn
({
"sigmoid"
,
"tanh"
,
"relu"
,
"identity"
})
.
End
();
AddOpCompat
(
OpCompat
(
"mul"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Y"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"x_num_col_dims"
)
.
IsNumEQ
(
1
)
.
End
()
.
AddAttr
(
"y_num_col_dims"
)
.
IsNumEQ
(
1
)
.
End
();
AddOpCompat
(
OpCompat
(
"elementwise_add"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Y"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"axis"
)
.
IsNumGE
(
-
1
)
.
End
();
}
int
FCLstmFusePass
::
BuildFusion
(
Graph
*
graph
,
const
std
::
string
&
name_scope
,
Scope
*
scope
,
bool
with_fc_bias
)
const
{
GraphPatternDetector
gpd
;
auto
*
pattern
=
gpd
.
mutable_pattern
();
...
...
@@ -140,6 +281,10 @@ int BuildFusion(Graph* graph, const std::string& name_scope, Scope* scope,
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
g
)
{
if
(
!
IsCompat
(
subgraph
,
g
))
{
LOG
(
WARNING
)
<<
"Pass in op compat failed."
;
return
;
}
GET_IR_NODE_FROM_SUBGRAPH
(
lstm
,
lstm
,
lstm_pattern
);
GET_IR_NODE_FROM_SUBGRAPH
(
Weight
,
Weight
,
lstm_pattern
);
GET_IR_NODE_FROM_SUBGRAPH
(
Bias
,
Bias
,
lstm_pattern
);
...
...
paddle/fluid/framework/ir/fc_lstm_fuse_pass.h
浏览文件 @
7e964579
...
...
@@ -31,16 +31,19 @@ class Graph;
class
FCLstmFusePass
:
public
FusePassBase
{
public:
FCLstmFusePass
();
virtual
~
FCLstmFusePass
()
{}
protected:
void
ApplyImpl
(
ir
::
Graph
*
graph
)
const
override
;
int
BuildFusion
(
Graph
*
graph
,
const
std
::
string
&
name_scope
,
Scope
*
scope
,
bool
with_fc_bias
)
const
;
const
std
::
string
name_scope_
{
"fc_lstm_fuse"
};
};
class
MulLstmFusePass
:
public
F
usePassBase
{
class
MulLstmFusePass
:
public
F
CLstmFusePass
{
public:
MulLstmFusePass
();
virtual
~
MulLstmFusePass
()
{}
protected:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录