Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
c69584a6
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 1 年 前同步成功
通知
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看板
提交
c69584a6
编写于
8月 25, 2020
作者:
C
chenluyan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the code style problem. test=develop
上级
99b47985
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
15 deletion
+19
-15
paddleslim/prune/prune_walker.py
paddleslim/prune/prune_walker.py
+5
-2
tests/test_add_ops.py
tests/test_add_ops.py
+14
-13
未找到文件。
paddleslim/prune/prune_walker.py
浏览文件 @
c69584a6
...
@@ -23,7 +23,7 @@ _logger = get_logger(__name__, level=logging.INFO)
...
@@ -23,7 +23,7 @@ _logger = get_logger(__name__, level=logging.INFO)
PRUNE_WORKER
=
Registry
(
'prune_worker'
)
PRUNE_WORKER
=
Registry
(
'prune_worker'
)
SKIP_OPS
=
[
"conditional_block"
,
"shape"
,
"reshape2"
]
SKIP_OPS
=
[
"conditional_block"
,
"shape"
,
"reshape2"
]
class
PruneWorker
(
object
):
class
PruneWorker
(
object
):
...
@@ -643,6 +643,7 @@ class roi_align(PruneWorker):
...
@@ -643,6 +643,7 @@ class roi_align(PruneWorker):
for
op
in
next_ops
:
for
op
in
next_ops
:
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
@
PRUNE_WORKER
.
register
@
PRUNE_WORKER
.
register
class
lod_reset
(
PruneWorker
):
class
lod_reset
(
PruneWorker
):
def
__init__
(
self
,
op
,
pruned_params
,
visited
=
{}):
def
__init__
(
self
,
op
,
pruned_params
,
visited
=
{}):
...
@@ -661,10 +662,12 @@ class lod_reset(PruneWorker):
...
@@ -661,10 +662,12 @@ class lod_reset(PruneWorker):
for
op
in
next_ops
:
for
op
in
next_ops
:
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
@
PRUNE_WORKER
.
register
@
PRUNE_WORKER
.
register
class
gather
(
PruneWorker
):
class
gather
(
PruneWorker
):
def
__init__
(
self
,
op
,
pruned_params
,
visited
):
def
__init__
(
self
,
op
,
pruned_params
,
visited
):
super
(
gather
,
self
).
__init__
(
op
,
pruned_params
,
visited
)
super
(
gather
,
self
).
__init__
(
op
,
pruned_params
,
visited
)
def
_prune
(
self
,
var
,
pruned_axis
,
pruned_idx
):
def
_prune
(
self
,
var
,
pruned_axis
,
pruned_idx
):
if
var
in
self
.
op
.
outputs
(
"Out"
):
if
var
in
self
.
op
.
outputs
(
"Out"
):
in_var
=
self
.
op
.
inputs
(
"X"
)[
0
]
in_var
=
self
.
op
.
inputs
(
"X"
)[
0
]
...
@@ -676,4 +679,4 @@ class gather(PruneWorker):
...
@@ -676,4 +679,4 @@ class gather(PruneWorker):
self
.
_visit
(
out_var
,
pruned_axis
)
self
.
_visit
(
out_var
,
pruned_axis
)
next_ops
=
out_var
.
outputs
()
next_ops
=
out_var
.
outputs
()
for
op
in
next_ops
:
for
op
in
next_ops
:
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
self
.
_prune_op
(
op
,
out_var
,
pruned_axis
,
pruned_idx
)
\ No newline at end of file
tests/test_add_ops.py
浏览文件 @
c69584a6
...
@@ -42,21 +42,22 @@ class TestPrune(unittest.TestCase):
...
@@ -42,21 +42,22 @@ class TestPrune(unittest.TestCase):
conv3
=
conv_bn_layer
(
sum1
,
8
,
3
,
"conv3"
)
conv3
=
conv_bn_layer
(
sum1
,
8
,
3
,
"conv3"
)
conv4
=
conv_bn_layer
(
conv3
,
8
,
3
,
"conv4"
)
conv4
=
conv_bn_layer
(
conv3
,
8
,
3
,
"conv4"
)
sum2
=
conv4
+
sum1
sum2
=
conv4
+
sum1
#test roi_align
#
test roi_align
rois
=
fluid
.
data
(
rois
=
fluid
.
data
(
name
=
'rois'
,
shape
=
[
None
,
4
],
dtype
=
'float32'
)
name
=
'rois'
,
shape
=
[
None
,
4
],
dtype
=
'float32'
)
align_out
=
fluid
.
layers
.
roi_align
(
align_out
=
fluid
.
layers
.
roi_align
(
input
=
sum2
,
input
=
sum2
,
rois
=
rois
,
rois
=
rois
,
pooled_height
=
7
,
pooled_height
=
7
,
pooled_width
=
7
,
pooled_width
=
7
,
spatial_scale
=
0.5
,
spatial_scale
=
0.5
,
sampling_ratio
=-
1
)
sampling_ratio
=-
1
)
conv5
=
conv_bn_layer
(
align_out
,
8
,
3
,
"conv5"
)
conv5
=
conv_bn_layer
(
align_out
,
8
,
3
,
"conv5"
)
#test gather
# test gather
index
=
fluid
.
layers
.
data
(
name
=
'index'
,
shape
=
[
-
1
,
1
],
dtype
=
'int32'
)
index
=
fluid
.
layers
.
data
(
name
=
'index'
,
shape
=
[
-
1
,
1
],
dtype
=
'int32'
)
gather_out
=
fluid
.
layers
.
gather
(
sum2
,
index
)
gather_out
=
fluid
.
layers
.
gather
(
sum2
,
index
)
conv6
=
conv_bn_layer
(
gather_out
,
8
,
3
,
"conv6"
)
conv6
=
conv_bn_layer
(
gather_out
,
8
,
3
,
"conv6"
)
#test lod_reset
#
test lod_reset
y
=
fluid
.
layers
.
data
(
name
=
'y'
,
shape
=
[
6
],
lod_level
=
2
)
y
=
fluid
.
layers
.
data
(
name
=
'y'
,
shape
=
[
6
],
lod_level
=
2
)
lodset_out
=
fluid
.
layers
.
lod_reset
(
x
=
sum2
,
y
=
y
)
lodset_out
=
fluid
.
layers
.
lod_reset
(
x
=
sum2
,
y
=
y
)
conv7
=
conv_bn_layer
(
lodset_out
,
8
,
3
,
"conv7"
)
conv7
=
conv_bn_layer
(
lodset_out
,
8
,
3
,
"conv7"
)
...
@@ -79,4 +80,4 @@ class TestPrune(unittest.TestCase):
...
@@ -79,4 +80,4 @@ class TestPrune(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录