Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
9bdc5624
Mace
项目概览
慢慢CG
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9bdc5624
编写于
11月 22, 2017
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'tools' into 'master'
Print const and conv2d ops in tf_ops_stats.py See merge request !107
上级
3738481f
7c8aa99d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
0 deletion
+8
-0
mace/python/tools/tf_ops_stats.py
mace/python/tools/tf_ops_stats.py
+8
-0
未找到文件。
mace/python/tools/tf_ops_stats.py
浏览文件 @
9bdc5624
import
operator
import
functools
import
argparse
import
argparse
import
sys
import
sys
import
six
import
six
...
@@ -39,6 +41,7 @@ def main(unused_args):
...
@@ -39,6 +41,7 @@ def main(unused_args):
# extract kernel size for conv_2d
# extract kernel size for conv_2d
tensor_shapes
=
{}
tensor_shapes
=
{}
tensor_values
=
{}
tensor_values
=
{}
print
(
"=========================consts============================"
)
for
op
in
ops
:
for
op
in
ops
:
if
op
.
type
==
'Const'
:
if
op
.
type
==
'Const'
:
for
output
in
op
.
outputs
:
for
output
in
op
.
outputs
:
...
@@ -46,9 +49,11 @@ def main(unused_args):
...
@@ -46,9 +49,11 @@ def main(unused_args):
tensor
=
output
.
eval
()
tensor
=
output
.
eval
()
tensor_shape
=
list
(
tensor
.
shape
)
tensor_shape
=
list
(
tensor
.
shape
)
tensor_shapes
[
tensor_name
]
=
tensor_shape
tensor_shapes
[
tensor_name
]
=
tensor_shape
print
(
"Const %s: %s, %d"
%
(
tensor_name
,
tensor_shape
,
functools
.
reduce
(
operator
.
mul
,
tensor_shape
,
1
)))
if
len
(
tensor_shape
)
==
1
and
tensor_shape
[
0
]
<
10
:
if
len
(
tensor_shape
)
==
1
and
tensor_shape
[
0
]
<
10
:
tensor_values
[
tensor_name
]
=
list
(
tensor
)
tensor_values
[
tensor_name
]
=
list
(
tensor
)
print
(
"=========================ops============================"
)
for
op
in
ops
:
for
op
in
ops
:
if
op
.
type
in
[
'Conv2D'
]:
if
op
.
type
in
[
'Conv2D'
]:
padding
=
op
.
get_attr
(
'padding'
)
padding
=
op
.
get_attr
(
'padding'
)
...
@@ -63,6 +68,7 @@ def main(unused_args):
...
@@ -63,6 +68,7 @@ def main(unused_args):
if
input_name
.
endswith
(
'weights:0'
)
and
input_name
in
tensor_shapes
:
if
input_name
.
endswith
(
'weights:0'
)
and
input_name
in
tensor_shapes
:
ksize
=
tensor_shapes
[
input_name
]
ksize
=
tensor_shapes
[
input_name
]
break
break
print
(
'%s(padding=%s, strides=%s, ksize=%s, format=%s) %s => %s'
%
(
op
.
type
,
padding
,
strides
,
ksize
,
data_format
,
op
.
inputs
[
0
].
shape
.
as_list
(),
op
.
outputs
[
0
].
shape
.
as_list
()))
key
=
'%s(padding=%s, strides=%s, ksize=%s, format=%s)'
%
(
op
.
type
,
padding
,
strides
,
ksize
,
data_format
)
key
=
'%s(padding=%s, strides=%s, ksize=%s, format=%s)'
%
(
op
.
type
,
padding
,
strides
,
ksize
,
data_format
)
hist_inc
(
stats
,
key
)
hist_inc
(
stats
,
key
)
elif
op
.
type
in
[
'FusedResizeAndPadConv2D'
]:
elif
op
.
type
in
[
'FusedResizeAndPadConv2D'
]:
...
@@ -117,6 +123,7 @@ def main(unused_args):
...
@@ -117,6 +123,7 @@ def main(unused_args):
key
=
'%s(block_shape=%s, paddings=%s)'
%
(
op
.
type
,
block_shape
,
paddings
)
key
=
'%s(block_shape=%s, paddings=%s)'
%
(
op
.
type
,
block_shape
,
paddings
)
else
:
else
:
key
=
'%s(block_shape=%s, crops=%s)'
%
(
op
.
type
,
block_shape
,
crops
)
key
=
'%s(block_shape=%s, crops=%s)'
%
(
op
.
type
,
block_shape
,
crops
)
print
(
key
)
hist_inc
(
stats
,
key
)
hist_inc
(
stats
,
key
)
elif
op
.
type
==
'Pad'
:
elif
op
.
type
==
'Pad'
:
paddings
=
'Unknown'
paddings
=
'Unknown'
...
@@ -130,6 +137,7 @@ def main(unused_args):
...
@@ -130,6 +137,7 @@ def main(unused_args):
else
:
else
:
hist_inc
(
stats
,
op
.
type
)
hist_inc
(
stats
,
op
.
type
)
print
(
"=========================stats============================"
)
for
key
,
value
in
sorted
(
six
.
iteritems
(
stats
)):
for
key
,
value
in
sorted
(
six
.
iteritems
(
stats
)):
print
(
'%s: %d'
%
(
key
,
value
))
print
(
'%s: %d'
%
(
key
,
value
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录