Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6da6ff6a
P
Paddle
项目概览
BaiXuePrincess
/
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看板
未验证
提交
6da6ff6a
编写于
6月 18, 2021
作者:
W
wenbin
提交者:
GitHub
6月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SimplifyWithBasicOpsPass (#33637)
* simplify_with_basic * fix * scale factor
上级
478ea78b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
2 deletion
+30
-2
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.cc
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.cc
+25
-0
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.h
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.h
+5
-2
未找到文件。
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.cc
浏览文件 @
6da6ff6a
...
@@ -34,6 +34,26 @@ namespace ir {
...
@@ -34,6 +34,26 @@ namespace ir {
*/
*/
class
Graph
;
class
Graph
;
SimplifyWithBasicOpsPass
::
SimplifyWithBasicOpsPass
()
{
AddOpCompat
(
OpCompat
(
"scale"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"scale"
)
.
IsNumGE
(
0.
f
)
.
IsNumLE
(
1.
f
)
.
End
()
.
AddAttr
(
"bias"
)
.
IsNumEQ
(
0.
f
)
.
End
()
.
AddAttr
(
"bias_after_scale"
)
.
IsNumEQ
(
true
)
.
End
();
}
void
SimplifyWithBasicOpsPass
::
ApplyImpl
(
Graph
*
graph
)
const
{
void
SimplifyWithBasicOpsPass
::
ApplyImpl
(
Graph
*
graph
)
const
{
VLOG
(
3
)
<<
"Simplify the Graph with basic ops."
;
VLOG
(
3
)
<<
"Simplify the Graph with basic ops."
;
std
::
unordered_set
<
const
Node
*>
del_node_set
;
std
::
unordered_set
<
const
Node
*>
del_node_set
;
...
@@ -145,6 +165,11 @@ bool SimplifyWithBasicOpsPass::SimplifyDropout(
...
@@ -145,6 +165,11 @@ bool SimplifyWithBasicOpsPass::SimplifyDropout(
new_op_desc
.
SetAttr
(
"bias"
,
static_cast
<
float
>
(
0
));
new_op_desc
.
SetAttr
(
"bias"
,
static_cast
<
float
>
(
0
));
new_op_desc
.
SetAttr
(
"bias_after_scale"
,
true
);
new_op_desc
.
SetAttr
(
"bias_after_scale"
,
true
);
if
(
!
IsCompat
(
new_op_desc
))
{
LOG
(
WARNING
)
<<
"Basic ops pass in scale op compat failed."
;
return
false
;
}
auto
*
scale_op_node
=
graph
->
CreateOpNode
(
&
new_op_desc
);
auto
*
scale_op_node
=
graph
->
CreateOpNode
(
&
new_op_desc
);
IR_NODE_LINK_TO
(
dropout_x
,
scale_op_node
);
IR_NODE_LINK_TO
(
dropout_x
,
scale_op_node
);
IR_NODE_LINK_TO
(
scale_op_node
,
dropout_out
);
IR_NODE_LINK_TO
(
scale_op_node
,
dropout_out
);
...
...
paddle/fluid/framework/ir/simplify_with_basic_ops_pass.h
浏览文件 @
6da6ff6a
...
@@ -17,7 +17,7 @@ limitations under the License. */
...
@@ -17,7 +17,7 @@ limitations under the License. */
#include <string>
#include <string>
#include <unordered_set>
#include <unordered_set>
#include "paddle/fluid/framework/ir/pass.h"
#include "paddle/fluid/framework/ir/
op_compat_sensible_
pass.h"
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
...
@@ -26,7 +26,10 @@ namespace ir {
...
@@ -26,7 +26,10 @@ namespace ir {
class
Graph
;
class
Graph
;
class
Node
;
class
Node
;
class
SimplifyWithBasicOpsPass
:
public
Pass
{
class
SimplifyWithBasicOpsPass
:
public
OpCompatSensiblePass
{
public:
SimplifyWithBasicOpsPass
();
protected:
protected:
void
ApplyImpl
(
Graph
*
graph
)
const
override
;
void
ApplyImpl
(
Graph
*
graph
)
const
override
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录