Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
76f0d7e2
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看板
提交
76f0d7e2
编写于
1月 16, 2020
作者:
C
ceci3
提交者:
whs
1月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Conv only for latency (#37)
上级
50d69ece
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
12 deletion
+10
-12
paddleslim/analysis/flops.py
paddleslim/analysis/flops.py
+0
-1
paddleslim/analysis/latency.py
paddleslim/analysis/latency.py
+10
-11
未找到文件。
paddleslim/analysis/flops.py
浏览文件 @
76f0d7e2
...
...
@@ -66,7 +66,6 @@ def _graph_flops(graph, only_conv=True, detail=False):
y_shape
=
op
.
inputs
(
"Y"
)[
0
].
shape
()
if
x_shape
[
0
]
==
-
1
:
x_shape
[
0
]
=
1
flops
+=
x_shape
[
0
]
*
x_shape
[
1
]
*
y_shape
[
1
]
op_flops
=
x_shape
[
0
]
*
x_shape
[
1
]
*
y_shape
[
1
]
flops
+=
op_flops
...
...
paddleslim/analysis/latency.py
浏览文件 @
76f0d7e2
...
...
@@ -24,7 +24,7 @@ class LatencyEvaluator(object):
def
latency
(
self
,
graph
):
pass
def
_get_ops_from_graph
(
self
,
graph
):
def
_get_ops_from_graph
(
self
,
graph
,
only_conv
):
assert
isinstance
(
graph
,
GraphWrapper
)
ops
=
[]
i
=
0
...
...
@@ -33,22 +33,20 @@ class LatencyEvaluator(object):
tmp
=
self
.
_conv_op_args
(
op
)
elif
op
.
type
()
in
[
'elementwise_add'
,
'elementwise_mul'
,
'elementwise_max'
]:
]
and
only_conv
==
False
:
tmp
=
self
.
_eltwise_op_args
(
op
)
elif
op
.
type
()
in
[
'relu'
,
'prelu'
,
'sigmoid'
,
'relu6'
,
'elu'
,
'brelu'
,
'leaky_relu'
]:
]
and
only_conv
==
False
:
tmp
=
self
.
_activation_op_args
(
op
)
elif
op
.
type
()
==
'batch_norm'
:
elif
op
.
type
()
==
'batch_norm'
and
only_conv
==
False
:
tmp
=
self
.
_batch_norm_op_args
(
op
)
elif
op
.
type
()
==
'pool2d'
:
elif
op
.
type
()
==
'pool2d'
and
only_conv
==
False
:
tmp
=
self
.
_pooling_op_args
(
op
)
elif
op
.
type
()
==
'batch_norm'
:
tmp
=
self
.
_batch_norm_op_args
(
op
)
elif
op
.
type
()
==
'softmax'
:
elif
op
.
type
()
==
'softmax'
and
only_conv
==
False
:
tmp
=
self
.
_softmax_op_args
(
op
)
elif
op
.
type
()
==
'mul'
:
elif
op
.
type
()
==
'mul'
and
only_conv
==
False
:
tmp
=
self
.
_fc_op_args
(
op
)
else
:
tmp
=
None
...
...
@@ -268,11 +266,12 @@ class TableLatencyEvaluator(LatencyEvaluator):
assert
op_str
in
self
.
_table
return
self
.
_table
[
op_str
]
def
latency
(
self
,
graph
):
def
latency
(
self
,
graph
,
only_conv
=
True
):
"""
Get latency of target graph.
Args:
- graph(GrapWrapper | Program): The graph to be evaluated.
- only_conv(bool): only evaluated convolution layer if `only_conv` is true. Default: True.
Returns:
latency(float): The latency of given graph on current evaluator.
"""
...
...
@@ -280,7 +279,7 @@ class TableLatencyEvaluator(LatencyEvaluator):
if
isinstance
(
graph
,
Program
):
graph
=
GraphWrapper
(
graph
)
assert
isinstance
(
graph
,
GraphWrapper
)
for
op
in
self
.
_get_ops_from_graph
(
graph
):
for
op
in
self
.
_get_ops_from_graph
(
graph
,
only_conv
):
total_latency
+=
self
.
_op_latency
(
self
.
_delimiter
.
join
(
map
(
lambda
x
:
str
(
x
),
op
)))
return
total_latency
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录