Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
89f1cdab
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 2 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
89f1cdab
编写于
6月 16, 2022
作者:
C
ceci3
提交者:
GitHub
6月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update shortcut (#1173)
上级
3ae057ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
1 deletion
+11
-1
paddleslim/common/patterns_common.py
paddleslim/common/patterns_common.py
+11
-1
未找到文件。
paddleslim/common/patterns_common.py
浏览文件 @
89f1cdab
...
@@ -97,6 +97,12 @@ def _find_next_target_op(op, graph, target_op_idx, sc_path):
...
@@ -97,6 +97,12 @@ def _find_next_target_op(op, graph, target_op_idx, sc_path):
return
False
return
False
def
_is_identity_op
(
op
):
if
op
.
type
()
==
'scale'
and
op
.
attr
(
'scale'
)
==
1
:
return
True
return
False
def
is_shortcut
(
op
,
graph
,
sc_path
,
shortcut_start_op
):
def
is_shortcut
(
op
,
graph
,
sc_path
,
shortcut_start_op
):
"""
"""
op /```````````````````
\\
add
op /```````````````````
\\
add
...
@@ -105,12 +111,16 @@ def is_shortcut(op, graph, sc_path, shortcut_start_op):
...
@@ -105,12 +111,16 @@ def is_shortcut(op, graph, sc_path, shortcut_start_op):
inps
=
op
.
all_inputs
()
inps
=
op
.
all_inputs
()
pre_ops
=
graph
.
pre_ops
(
op
)
pre_ops
=
graph
.
pre_ops
(
op
)
for
p_op
in
pre_ops
:
for
p_op
in
pre_ops
:
if
_is_identity_op
(
p_op
):
p_op
=
graph
.
pre_ops
(
p_op
)[
0
]
n_ops
=
graph
.
next_ops
(
p_op
)
n_ops
=
graph
.
next_ops
(
p_op
)
if
len
(
n_ops
)
==
1
:
if
len
(
n_ops
)
==
1
:
continue
continue
### note: only support one branch donnot have op
### note: only support one branch donnot have op
or has one scale op
has_sc
=
False
has_sc
=
False
for
n_op
in
n_ops
:
for
n_op
in
n_ops
:
if
_is_identity_op
(
n_op
):
n_op
=
graph
.
next_ops
(
n_op
)[
0
]
if
n_op
.
idx
()
==
op
.
idx
():
if
n_op
.
idx
()
==
op
.
idx
():
shortcut_start_op
.
append
(
p_op
)
shortcut_start_op
.
append
(
p_op
)
has_sc
=
True
has_sc
=
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录