Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
34c95eaf
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
34c95eaf
编写于
6月 18, 2021
作者:
F
feng_shuai
提交者:
GitHub
6月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
batch_norm_act_fuse_pass_init (#33636)
* batch_norm_act_fuse_pass_init * repair the unittest of batch_norm_act
上级
6da6ff6a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
69 addition
and
0 deletion
+69
-0
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc
+59
-0
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.h
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.h
+1
-0
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc
...id/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc
+1
-0
paddle/fluid/operators/compat/batch_norm.pbtxt
paddle/fluid/operators/compat/batch_norm.pbtxt
+4
-0
paddle/fluid/operators/compat/relu.pbtxt
paddle/fluid/operators/compat/relu.pbtxt
+4
-0
未找到文件。
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc
浏览文件 @
34c95eaf
...
...
@@ -29,6 +29,55 @@ void FuseBatchNormActOneDNNPass::ApplyImpl(Graph *graph) const {
FuseBatchNormAct
(
graph
,
act_type
);
}
FuseBatchNormActOneDNNPass
::
FuseBatchNormActOneDNNPass
()
{
AddOpCompat
(
OpCompat
(
"batch_norm"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Scale"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Bias"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Mean"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Variance"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Y"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"MeanOut"
)
.
IsOptional
()
.
End
()
.
AddOutput
(
"VarianceOut"
)
.
IsOptional
()
.
End
()
.
AddOutput
(
"SavedMean"
)
.
IsOptional
()
.
End
()
.
AddOutput
(
"SavedVariance"
)
.
IsOptional
()
.
End
()
.
AddOutput
(
"ReserveSpace"
)
.
IsOptional
()
.
End
()
.
AddAttr
(
"epsilon"
)
.
IsNumGE
(
0.0
f
)
.
IsNumLE
(
0.001
f
)
.
End
();
AddOpCompat
(
OpCompat
(
"relu"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
();
}
void
FuseBatchNormActOneDNNPass
::
FuseBatchNormAct
(
Graph
*
graph
,
const
std
::
string
&
act_type
)
const
{
PADDLE_ENFORCE_NOT_NULL
(
...
...
@@ -45,6 +94,11 @@ void FuseBatchNormActOneDNNPass::FuseBatchNormAct(
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
g
)
{
VLOG
(
4
)
<<
"Fuse BatchNorm with ReLU activation op."
;
if
(
!
IsCompat
(
subgraph
,
g
))
{
LOG
(
WARNING
)
<<
"Pass in op compat failed."
;
return
;
}
// BN output
GET_IR_NODE_FROM_SUBGRAPH
(
bn_out
,
bn_out
,
bn_act_pattern
);
// ACT output
...
...
@@ -84,6 +138,11 @@ void FuseBatchNormActOneDNNPass::FuseBatchNormAct(
bn_op
->
SetAttr
(
"trainable_statistics"
,
false
);
bn_op
->
SetOutput
(
"Y"
,
{
act_out
->
Name
()});
if
(
!
IsCompat
(
*
bn_op
))
{
LOG
(
WARNING
)
<<
"Fc fuse pass in out fc op compat failed."
;
return
;
}
IR_OP_VAR_LINK
(
batch_norm
,
act_out
);
GraphSafeRemoveNodes
(
g
,
{
act
,
bn_out
});
found_bn_act_count
++
;
...
...
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.h
浏览文件 @
34c95eaf
...
...
@@ -31,6 +31,7 @@ namespace ir {
*/
class
FuseBatchNormActOneDNNPass
:
public
FusePassBase
{
public:
FuseBatchNormActOneDNNPass
();
virtual
~
FuseBatchNormActOneDNNPass
()
{}
protected:
...
...
paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc
浏览文件 @
34c95eaf
...
...
@@ -32,6 +32,7 @@ void SetBatchNormAttrs(OpDesc* bn_op, bool is_test = true,
bn_op
->
SetAttr
(
"is_test"
,
is_test
);
bn_op
->
SetAttr
(
"trainable_statistics"
,
trainable_stats
);
bn_op
->
SetAttr
(
"fuse_with_relu"
,
false
);
bn_op
->
SetAttr
(
"epsilon"
,
0.001
f
);
}
}
...
...
paddle/fluid/operators/compat/batch_norm.pbtxt
浏览文件 @
34c95eaf
...
...
@@ -42,6 +42,10 @@ extra {
inputs {
name: "MomentumTensor"
}
attrs {
name: "@ENABLE_CACHE_RUNTIME_CONTEXT@"
type: BOOLEAN
}
attrs {
name: "is_test"
type: BOOLEAN
...
...
paddle/fluid/operators/compat/relu.pbtxt
浏览文件 @
34c95eaf
...
...
@@ -8,6 +8,10 @@ def {
}
}
extra {
attrs {
name: "@ENABLE_CACHE_RUNTIME_CONTEXT@"
type: BOOLEAN
}
attrs {
name: "use_mkldnn"
type: BOOLEAN
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录