Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冰之2023
Mace
提交
fc2c5bb9
Mace
项目概览
冰之2023
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc2c5bb9
编写于
10月 26, 2017
作者:
Y
Yin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fold BN with convolution if using nnlib
上级
1d89e689
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
3 deletion
+39
-3
mace/dsp/ops.h
mace/dsp/ops.h
+0
-1
mace/python/tools/BUILD
mace/python/tools/BUILD
+4
-1
mace/python/tools/dsp_ops.py
mace/python/tools/dsp_ops.py
+2
-1
mace/python/tools/tf_dsp_converter_lib.py
mace/python/tools/tf_dsp_converter_lib.py
+7
-0
mace/python/tools/tf_graph_util.py
mace/python/tools/tf_graph_util.py
+26
-0
未找到文件。
mace/dsp/ops.h
浏览文件 @
fc2c5bb9
...
...
@@ -150,7 +150,6 @@ DEF_OP_WREF(QuantizedSigmoid_8)
DEF_OP_WREF
(
QuantizedTanh_8
)
DEF_OP_WREF
(
QuantizedSoftmax_8
)
DEF_OP_WREF
(
QuantizedLRN_8
)
DEF_OP_WREF
(
Quantizedpad2d_frame_8p
)
DEF_OP_WREF
(
QuantizedSub_8p8to32
)
DEF_OP_WREF
(
QuantizedMaximum_8
)
DEF_OP_WREF
(
QuantizedMinimum_8
)
...
...
mace/python/tools/BUILD
浏览文件 @
fc2c5bb9
py_library
(
name
=
"tf_converter_lib"
,
srcs
=
[
"tf_converter_lib.py"
,
"tf_dsp_converter_lib.py"
],
srcs
=
[
"tf_converter_lib.py"
,
"tf_dsp_converter_lib.py"
,
"tf_graph_util.py"
],
srcs_version
=
"PY2AND3"
,
deps
=
[
"//mace/proto:mace_py"
,
...
...
mace/python/tools/dsp_ops.py
浏览文件 @
fc2c5bb9
...
...
@@ -47,13 +47,14 @@ class DspOps(object):
'Split'
:
'Split_f'
,
'Transpose'
:
'Transpose_f'
,
'Concat'
:
'Concat_f'
,
'AddN'
:
'AddN_f'
,
}
def
has_op
(
self
,
tf_op
):
return
tf_op
in
self
.
dsp_ops
def
map_nn_op
(
self
,
tf_op
):
if
tf_op
not
in
self
.
dsp_ops
:
raise
Exception
(
'Could not map nn op
'
)
raise
Exception
(
'Could not map nn op
for: '
,
tf_op
)
return
self
.
dsp_ops
[
tf_op
]
mace/python/tools/tf_dsp_converter_lib.py
浏览文件 @
fc2c5bb9
...
...
@@ -4,6 +4,7 @@ import tensorflow as tf
import
numpy
as
np
from
operator
import
mul
from
dsp_ops
import
DspOps
from
mace.python.tools
import
tf_graph_util
padding_mode
=
{
'NA'
:
0
,
...
...
@@ -162,6 +163,12 @@ def add_output_node(net_def, output_node):
node_input
.
output_port
=
0
def
convert_to_mace_pb
(
input_graph_def
,
input_dim
,
output_node
):
"""
nnlib does not have batch norm, so use tensorflow optimizer to fold
batch norm with convolution. The fold optimization reorders ops, so
we sort ops first by topology.
"""
input_graph_def
=
tf_graph_util
.
sort_graph
(
input_graph_def
)
inputs
=
input_dim
.
split
(
';'
)
input_shape
=
{}
for
input
in
inputs
:
...
...
mace/python/tools/tf_graph_util.py
0 → 100644
浏览文件 @
fc2c5bb9
import
tensorflow
as
tf
from
collections
import
OrderedDict
def
sort_graph_node
(
node
,
nodes_map
,
ordered_nodes_map
):
if
node
.
name
not
in
ordered_nodes_map
:
for
input_tensor_name
in
node
.
input
:
input_node_name
=
input_tensor_name
.
split
(
':'
)[
0
]
if
':'
in
input_tensor_name
else
input_tensor_name
if
input_node_name
not
in
nodes_map
or
input_node_name
in
ordered_nodes_map
:
continue
input_node
=
nodes_map
[
input_node_name
]
sort_graph_node
(
input_node
,
nodes_map
,
ordered_nodes_map
)
ordered_nodes_map
[
input_node_name
]
=
input_node
ordered_nodes_map
[
node
.
name
]
=
node
def
sort_graph
(
graph_def
):
nodes_map
=
{}
ordered_nodes_map
=
OrderedDict
()
for
node
in
graph_def
.
node
:
nodes_map
[
node
.
name
]
=
node
for
node
in
graph_def
.
node
:
sort_graph_node
(
node
,
nodes_map
,
ordered_nodes_map
)
sorted_graph
=
tf
.
GraphDef
()
sorted_graph
.
node
.
extend
([
node
for
_
,
node
in
ordered_nodes_map
.
iteritems
()])
return
sorted_graph
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录