Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
e44b5dd6
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看板
提交
e44b5dd6
编写于
11月 15, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support caffe scale op, and fix fold_batchnorm op in transformer
上级
fbc1d019
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
55 addition
and
8 deletion
+55
-8
docs/faq.md
docs/faq.md
+2
-2
docs/user_guide/basic_usage.rst
docs/user_guide/basic_usage.rst
+1
-2
mace/python/tools/converter_tool/caffe_converter.py
mace/python/tools/converter_tool/caffe_converter.py
+47
-0
mace/python/tools/converter_tool/shape_inference.py
mace/python/tools/converter_tool/shape_inference.py
+1
-0
mace/python/tools/converter_tool/transformer.py
mace/python/tools/converter_tool/transformer.py
+4
-4
未找到文件。
docs/faq.md
浏览文件 @
e44b5dd6
...
@@ -46,7 +46,7 @@ due to high memory usage or fragmentation. Several solutions can be tried:
...
@@ -46,7 +46,7 @@ due to high memory usage or fragmentation. Several solutions can be tried:
Why is the performance worse than the official result for the same model?
Why is the performance worse than the official result for the same model?
-------------------------------------------------------------------------
-------------------------------------------------------------------------
The power options may not set properly, see
`mace/public/mace
_runtime
.h`
for
The power options may not set properly, see
`mace/public/mace.h`
for
details.
details.
Why is the UI getting poor responsiveness when running model with GPU runtime?
Why is the UI getting poor responsiveness when running model with GPU runtime?
...
...
docs/user_guide/basic_usage.rst
浏览文件 @
e44b5dd6
...
@@ -299,8 +299,7 @@ header files.
...
@@ -299,8 +299,7 @@ header files.
├── include
├── include
│ └── mace
│ └── mace
│ └── public
│ └── public
│ ├── mace.h
│ └── mace.h
│ └── mace_runtime.h
├── lib
├── lib
│ ├── arm64-v8a
│ ├── arm64-v8a
│ │ └── cpu_gpu
│ │ └── cpu_gpu
...
...
mace/python/tools/converter_tool/caffe_converter.py
浏览文件 @
e44b5dd6
...
@@ -186,6 +186,7 @@ class CaffeConverter(base_converter.ConverterInterface):
...
@@ -186,6 +186,7 @@ class CaffeConverter(base_converter.ConverterInterface):
'InnerProduct'
:
self
.
convert_fully_connected
,
'InnerProduct'
:
self
.
convert_fully_connected
,
'BatchNorm'
:
self
.
convert_folded_batchnorm
,
'BatchNorm'
:
self
.
convert_folded_batchnorm
,
'Crop'
:
self
.
convert_crop
,
'Crop'
:
self
.
convert_crop
,
'Scale'
:
self
.
convert_scale
,
}
}
self
.
_option
=
option
self
.
_option
=
option
self
.
_mace_net_def
=
mace_pb2
.
NetDef
()
self
.
_mace_net_def
=
mace_pb2
.
NetDef
()
...
@@ -604,3 +605,49 @@ class CaffeConverter(base_converter.ConverterInterface):
...
@@ -604,3 +605,49 @@ class CaffeConverter(base_converter.ConverterInterface):
mace_pb2
.
DT_FLOAT
,
mace_pb2
.
DT_FLOAT
,
bias_data
)
bias_data
)
op
.
input
.
extend
([
bias_tensor_name
])
op
.
input
.
extend
([
bias_tensor_name
])
def
convert_scale
(
self
,
caffe_op
):
op
=
self
.
convert_general_op
(
caffe_op
)
op
.
type
=
MaceOp
.
Eltwise
.
name
scale_op_name
=
op
.
name
op
.
name
=
scale_op_name
+
'_prod'
type_arg
=
op
.
arg
.
add
()
type_arg
.
name
=
MaceKeyword
.
mace_element_type_str
type_arg
.
i
=
EltwiseType
.
PROD
.
value
scale_tensor_name
=
scale_op_name
+
'_scale'
scale_data
=
caffe_op
.
blobs
[
0
]
self
.
add_tensor
(
scale_tensor_name
,
scale_data
.
shape
,
mace_pb2
.
DT_FLOAT
,
scale_data
)
op
.
input
.
extend
([
scale_tensor_name
])
if
len
(
caffe_op
.
blobs
)
==
2
:
bias_tensor_name
=
scale_op_name
+
'_offset'
bias_data
=
caffe_op
.
blobs
[
1
]
# caffe of old version has 4-dimension bias, so reshape it
# to single dimension
self
.
add_tensor
(
bias_tensor_name
,
bias_data
.
reshape
(
-
1
).
shape
,
mace_pb2
.
DT_FLOAT
,
bias_data
)
op
.
input
.
extend
([
bias_tensor_name
])
biasadd_op
=
self
.
_mace_net_def
.
op
.
add
()
biasadd_op
.
name
=
scale_op_name
+
'_biasadd'
biasadd_op
.
type
=
MaceOp
.
BiasAdd
.
name
biasadd_op
.
output
.
extend
(
op
.
output
)
op
.
output
[:]
=
[
op
.
output
[
0
]
+
'_prod_output'
]
biasadd_op
.
input
.
extend
(
op
.
output
)
biasadd_op
.
input
.
extend
([
op
.
input
[
2
]])
biasadd_op
.
output_shape
.
extend
(
op
.
output_shape
)
del
op
.
input
[
2
]
data_type_arg
=
biasadd_op
.
arg
.
add
()
data_type_arg
.
name
=
'T'
data_type_arg
.
i
=
self
.
_option
.
data_type
ConverterUtil
.
add_data_format_arg
(
biasadd_op
,
DataFormat
.
NCHW
)
mace/python/tools/converter_tool/shape_inference.py
浏览文件 @
e44b5dd6
...
@@ -47,6 +47,7 @@ class ShapeInference(object):
...
@@ -47,6 +47,7 @@ class ShapeInference(object):
MaceOp
.
Softmax
.
name
:
self
.
infer_shape_general
,
MaceOp
.
Softmax
.
name
:
self
.
infer_shape_general
,
MaceOp
.
FullyConnected
.
name
:
self
.
infer_shape_fully_connected
,
MaceOp
.
FullyConnected
.
name
:
self
.
infer_shape_fully_connected
,
MaceOp
.
Crop
.
name
:
self
.
infer_shape_crop
,
MaceOp
.
Crop
.
name
:
self
.
infer_shape_crop
,
MaceOp
.
BiasAdd
.
name
:
self
.
infer_shape_general
,
}
}
self
.
_net
=
net
self
.
_net
=
net
...
...
mace/python/tools/converter_tool/transformer.py
浏览文件 @
e44b5dd6
...
@@ -344,12 +344,14 @@ class Transformer(base_converter.ConverterInterface):
...
@@ -344,12 +344,14 @@ class Transformer(base_converter.ConverterInterface):
==
EltwiseType
.
PROD
.
value
)
\
==
EltwiseType
.
PROD
.
value
)
\
and
len
(
op
.
input
)
==
2
\
and
len
(
op
.
input
)
==
2
\
and
op
.
input
[
1
]
in
self
.
_consts
\
and
op
.
input
[
1
]
in
self
.
_consts
\
and
op
.
output_shape
[
0
].
dims
[
-
1
:]
==
\
self
.
_consts
[
op
.
input
[
1
]].
dims
\
and
self
.
consumer_count
(
op
.
output
[
0
])
==
1
\
and
self
.
consumer_count
(
op
.
output
[
0
])
==
1
\
and
not
self
.
is_op_output_node
(
op
):
and
not
self
.
is_op_output_node
(
op
):
consumer_op
=
self
.
_consumers
[
op
.
output
[
0
]][
0
]
consumer_op
=
self
.
_consumers
[
op
.
output
[
0
]][
0
]
if
(
consumer_op
.
type
==
MaceOp
.
Eltwise
.
name
if
(
consumer_op
.
type
==
MaceOp
.
Eltwise
.
name
and
ConverterUtil
.
get_arg
(
and
ConverterUtil
.
get_arg
(
op
,
MaceKeyword
.
mace_element_type_str
).
i
consumer_
op
,
MaceKeyword
.
mace_element_type_str
).
i
==
EltwiseType
.
SUM
.
value
==
EltwiseType
.
SUM
.
value
or
consumer_op
.
type
==
MaceOp
.
BiasAdd
.
name
)
\
or
consumer_op
.
type
==
MaceOp
.
BiasAdd
.
name
)
\
and
len
(
consumer_op
.
input
)
==
2
\
and
len
(
consumer_op
.
input
)
==
2
\
...
@@ -359,10 +361,8 @@ class Transformer(base_converter.ConverterInterface):
...
@@ -359,10 +361,8 @@ class Transformer(base_converter.ConverterInterface):
consumer_op
.
type
=
MaceOp
.
BatchNorm
.
name
consumer_op
.
type
=
MaceOp
.
BatchNorm
.
name
consumer_op
.
input
[:]
=
[
op
.
input
[
0
],
op
.
input
[
1
],
consumer_op
.
input
[:]
=
[
op
.
input
[
0
],
op
.
input
[
1
],
consumer_op
.
input
[
1
]]
consumer_op
.
input
[
1
]]
net
.
op
.
remove
(
op
)
self
.
safe_remove_node
(
op
,
None
)
return
True
return
True
return
False
return
False
def
fold_squared_diff_mean
(
self
):
def
fold_squared_diff_mean
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录