Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr.Vain
Mace
提交
16631aaa
Mace
项目概览
Mr.Vain
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
1
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,发现更多精彩内容 >>
提交
16631aaa
编写于
8月 28, 2019
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update hexagon nn to 0x00020F00
上级
6efb1870
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
128 addition
and
51 deletion
+128
-51
mace/python/tools/BUILD.bazel
mace/python/tools/BUILD.bazel
+0
-12
third_party/nnlib/BUILD.bazel
third_party/nnlib/BUILD.bazel
+2
-1
third_party/nnlib/arm64-v8a/libcdsprpc.so
third_party/nnlib/arm64-v8a/libcdsprpc.so
+0
-0
third_party/nnlib/arm64-v8a/libhexagon_controller.so
third_party/nnlib/arm64-v8a/libhexagon_controller.so
+0
-0
third_party/nnlib/armeabi-v7a/libhexagon_controller.so
third_party/nnlib/armeabi-v7a/libhexagon_controller.so
+0
-0
third_party/nnlib/ops.h
third_party/nnlib/ops.h
+96
-6
third_party/nnlib/v60/libhexagon_nn_skel.so
third_party/nnlib/v60/libhexagon_nn_skel.so
+0
-0
third_party/nnlib/v65/libhexagon_nn_skel.so
third_party/nnlib/v65/libhexagon_nn_skel.so
+0
-0
third_party/nnlib/v66/libhexagon_nn_skel.so
third_party/nnlib/v66/libhexagon_nn_skel.so
+0
-0
tools/device.py
tools/device.py
+3
-14
tools/layers_validate.py
tools/layers_validate.py
+27
-18
未找到文件。
mace/python/tools/BUILD.bazel
浏览文件 @
16631aaa
...
...
@@ -4,15 +4,3 @@ py_binary(
srcs_version
=
"PY2AND3"
,
visibility
=
[
"//visibility:public"
],
)
py_binary
(
name
=
"layers_validate"
,
srcs
=
[
"layers_validate.py"
,
],
srcs_version
=
"PY2AND3"
,
deps
=
[
":converter_lib"
,
":model_saver_lib"
,
],
)
third_party/nnlib/BUILD.bazel
浏览文件 @
16631aaa
...
...
@@ -6,8 +6,8 @@ exports_files(["license.txt"])
load
(
"//mace:mace.bzl"
,
"if_android_armv7"
,
"if_android_arm64"
,
"if_android_armv7"
,
)
cc_library
(
...
...
@@ -15,6 +15,7 @@ cc_library(
srcs
=
if_android_armv7
([
"armeabi-v7a/libhexagon_controller.so"
,
])
+
if_android_arm64
([
"arm64-v8a/libcdsprpc.so"
,
"arm64-v8a/libhexagon_controller.so"
,
]),
hdrs
=
[
...
...
third_party/nnlib/arm64-v8a/libcdsprpc.so
0 → 100755
浏览文件 @
16631aaa
文件已添加
third_party/nnlib/arm64-v8a/libhexagon_controller.so
浏览文件 @
16631aaa
无法预览此类型文件
third_party/nnlib/armeabi-v7a/libhexagon_controller.so
浏览文件 @
16631aaa
无法预览此类型文件
third_party/nnlib/ops.h
浏览文件 @
16631aaa
...
...
@@ -164,12 +164,13 @@ DEF_OP_WREF(QuantizedPRelu_8)
DEF_OP
(
Sum_f
)
DEF_OP
(
Prod_f
)
DEF_OP
(
Mul_int32
)
DEF_OP
(
Logical
And_int32
)
DEF_OP
(
Logical
Or_int32
)
DEF_OP
(
Logical
Xor_int32
)
DEF_OP
(
Bitwise
And_int32
)
DEF_OP
(
Bitwise
Or_int32
)
DEF_OP
(
Bitwise
Xor_int32
)
DEF_OP
(
Shape_int32
)
DEF_OP
(
Pack_int32
)
DEF_OP
(
MirrorPad_f
)
DEF_OP
(
MirrorPad_8
)
DEF_OP
(
ResizeNearestNeighbor_f
)
DEF_OP
(
StridedSlice_int32
)
DEF_OP
(
StridedSlice_f
)
...
...
@@ -227,7 +228,7 @@ DEF_OP_WREF(QuantizedMul_8x8to8_d32)
DEF_OP
(
FullyConnected_u8
)
#if 0
DEF_OP_WREF(QuantizedFC_8x8p8to8)
DEF_OP_WREF(QuantizedFC_8x8p8to8)
#endif
DEF_OP_WREF
(
QuantizedAdd_8p8to8_d32
)
...
...
@@ -355,8 +356,7 @@ DEF_OP(QuantizeForTest_16b_d32)
DEF_OP
(
QuantizeForTest_u16b_d32
)
DEF_OP
(
Close_16b_d32
)
DEF_OP
(
Close_u16b_d32
)
DEF_OP
(
Convert_from_d32_b16
)
DEF_OP
(
Supernode_16x16p16to16_d32
)
DEF_OP
(
Convert_from_d32_16b
)
DEF_OP
(
Supernode_u16x16p16to16_d32
)
DEF_OP
(
QuantizedMatMulDims_8x8p32to16
)
...
...
@@ -408,11 +408,101 @@ DEF_OP(AxisShuffle_8)
DEF_OP
(
ResizeNearestNeighbor_8
)
DEF_OP
(
QuantizedHeatmapMaxKP_8
)
DEF_OP
(
Moments_8to32
)
DEF_OP
(
Moments_f
)
DEF_OP
(
ArgMin_8
)
DEF_OP
(
Select_f
)
DEF_OP
(
Select_8
)
DEF_OP
(
QuantizedGroupedConv2d_8x8p32to8
)
DEF_OP
(
QuantizedAdd_16
)
DEF_OP
(
QuantizedSub_16
)
DEF_OP
(
QuantizedMul_16
)
DEF_OP
(
QuantizedAdd_u16
)
DEF_OP
(
QuantizedSub_u16
)
DEF_OP
(
QuantizedMul_u16
)
DEF_OP
(
Dequantize_u16
)
DEF_OP
(
Convert_8_u16
)
DEF_OP
(
Convert_16_8
)
DEF_OP
(
Convert_u16_8
)
DEF_OP
(
Convert_u16_16
)
DEF_OP
(
Convert_16_u16
)
DEF_OP
(
Requantize_u16_u16
)
DEF_OP
(
Requantize_16_16
)
DEF_OP
(
Quantize_u16
)
DEF_OP
(
QuantizedPRelu_8_V2
)
DEF_OP
(
QuantizedPRelu_8_V2_d32
)
DEF_OP
(
QuantizedMean_8
)
DEF_OP
(
QuantizedRoiAlignV2_8
)
DEF_OP
(
MultiClassNms_8
)
DEF_OP_WREF
(
QuantizedConcat_u16
)
DEF_OP
(
BitwiseNot_int32
)
DEF_OP
(
QuantizedDilatedConv2d_8x8p32to8
)
DEF_OP
(
Convert_to_aix_d32_d32
)
DEF_OP
(
QuantizedEqual_8
)
DEF_OP
(
QuantizedNotEqual_8
)
DEF_OP
(
QuantizedLess_8
)
DEF_OP
(
QuantizedLessEqual_8
)
DEF_OP
(
QuantizedGreater_8
)
DEF_OP
(
QuantizedGreaterEqual_8
)
DEF_OP
(
Ceil_f
)
DEF_OP
(
Floor_f
)
DEF_OP
(
Round_f
)
DEF_OP
(
AxisShuffle_f
)
DEF_OP
(
AxisShuffle_int32
)
DEF_OP
(
AxisShuffle_16
)
DEF_OP
(
Transpose_16
)
DEF_OP
(
SpaceToDepth_16
)
DEF_OP
(
DepthToSpace_16
)
DEF_OP
(
Convert_to_d32_16b
)
DEF_OP
(
ArgMax_8_d32
)
DEF_OP
(
ArgMin_8_d32
)
DEF_OP
(
QuantizedRoiPool_8_v2
)
DEF_OP
(
QuantizedPad_16
)
DEF_OP
(
QuantizedPad_u16
)
DEF_OP
(
Close_quint16
)
DEF_OP
(
AxisAlignedBBoxTransform_f
)
DEF_OP
(
AxisAlignedBBoxTransform_q8q16
)
DEF_OP
(
QuantizedConv2d_16x16to32
)
DEF_OP
(
QuantizedTransposeConv2d_16x16p32to16
)
DEF_OP
(
Supernode_16x16p16to16
)
DEF_OP
(
Supernode_16x16p32to16
)
DEF_OP
(
Supernode_u16x16p32to16_d32
)
DEF_OP
(
Requantize_32tou16
)
DEF_OP
(
DepthToSpace_16_d32
)
DEF_OP
(
QuantizedConcat_u16_d32
)
DEF_OP
(
QuantizedConcatCommon_u16_d32
)
DEF_OP
(
QuantizedChannelScale_32xf
)
DEF_OP
(
QuantizedHashtableLookup_8
)
DEF_OP
(
QuantizedAdd_u16_d32
)
DEF_OP
(
QuantizedSub_u16_d32
)
DEF_OP
(
QuantizedMul_u16_d32
)
DEF_OP
(
QuantizedPad_u16_d32
)
DEF_OP
(
QuantizedPad_16_d32
)
DEF_OP
(
Proposal_q8q16
)
DEF_OP
(
Close_q_qint16
)
DEF_OP
(
QuantizedPad_V2_8
)
DEF_OP
(
BoxWithNmsLimit_f
)
DEF_OP
(
BoxWithNmsLimit_q8q16
)
DEF_OP
(
L2Normalize_8
)
DEF_OP
(
Close_boxes_quint16
)
DEF_OP
(
DepthwiseSupernode_16x16p16to16
)
DEF_OP
(
DepthwiseSupernode_16x16p16to16_d32
)
DEF_OP
(
DepthwiseSupernode_16x16p32to16
)
DEF_OP
(
DepthwiseSupernode_16x16p32to16_d32
)
DEF_OP
(
Close_mse_u8
)
DEF_OP
(
MirrorPad_8_d32
)
DEF_OP
(
QuantizedPadForConv_8_d32
)
DEF_OP
(
QuantizedPadForConv_u16_d32
)
DEF_OP
(
LSHProjection
)
DEF_OP
(
Requantize_8to8
)
DEF_OP
(
InputSupernode_16x16p16to16_outd32
)
DEF_OP
(
InputSupernode_16x16p32to16_outd32
)
DEF_OP_WREF
(
QuantizedCorrelation1d_8x8to8
)
// Add new operations above this line
#ifdef __SELF_DEF_OP_WREF
#undef __SELF_DEF_OP_WREF
...
...
third_party/nnlib/v60/libhexagon_nn_skel.so
浏览文件 @
16631aaa
无法预览此类型文件
third_party/nnlib/v65/libhexagon_nn_skel.so
0 → 100755
浏览文件 @
16631aaa
文件已添加
third_party/nnlib/v66/libhexagon_nn_skel.so
100755 → 100644
浏览文件 @
16631aaa
无法预览此类型文件
tools/device.py
浏览文件 @
16631aaa
...
...
@@ -13,13 +13,9 @@
# limitations under the License.
import
numpy
as
np
import
os
import
sys
import
socket
import
subprocess
import
time
import
six
import
sh
import
yaml
...
...
@@ -27,8 +23,7 @@ import common
from
common
import
*
from
dana.dana_cli
import
DanaTrend
from
dana.dana_util
import
DanaUtil
import
layers_validate
import
sh_commands
...
...
@@ -452,19 +447,13 @@ class DeviceWrapper:
@
staticmethod
def
get_layers
(
model_dir
,
model_name
,
layers
):
sh_commands
.
bazel_build_common
(
"//mace/python/tools:layers_validate"
)
model_file
=
"%s/%s.pb"
%
(
model_dir
,
model_name
)
output_dir
=
"%s/output_models/"
%
model_dir
if
os
.
path
.
exists
(
output_dir
):
sh
.
rm
(
'-rf'
,
output_dir
)
os
.
makedirs
(
output_dir
)
sh
.
python
(
"bazel-bin/mace/python/tools/layers_validate"
,
"-u"
,
"--model_file=%s"
%
model_file
,
"--output_dir=%s"
%
output_dir
,
"--layers=%s"
%
layers
,
_fg
=
True
)
layers_validate
.
convert
(
model_file
,
output_dir
,
layers
)
output_configs_path
=
output_dir
+
"outputs.yml"
with
open
(
output_configs_path
)
as
f
:
...
...
mace/python/
tools/layers_validate.py
→
tools/layers_validate.py
浏览文件 @
16631aaa
...
...
@@ -18,13 +18,13 @@ import os
import
sys
import
yaml
from
mace.proto
import
mace_pb2
from
mace.python.tools.converter_tool.base_converter
import
ConverterUtil
from
mace.python.tools.converter_tool.base_converter
import
MaceKeyword
from
mace.python.tools.converter_tool.base_converter
import
MaceOp
from
mace.python.tools.converter_tool.hexagon_converter
import
Hexagon
Op
from
mace.python.tools.convert_util
import
mace_check
from
mace.python.tools.model_saver
import
save_model_to_proto
sys
.
path
.
insert
(
0
,
"tools/python"
)
# noqa
from
py_proto
import
mace_pb2
from
transform.base_converter
import
ConverterUtil
from
transform.base_converter
import
MaceKeyword
from
transform.base_converter
import
Mace
Op
from
transform.hexagon_converter
import
HexagonOp
from
utils.util
import
mace_check
def
normalize_op_name
(
name
):
...
...
@@ -52,13 +52,22 @@ def handle_index(start, end, layers):
return
start_index
,
end_index
def
main
(
unused_args
):
mace_check
(
os
.
path
.
isfile
(
FLAGS
.
model_file
),
"Input graph file '"
+
FLAGS
.
model_file
+
"' does not exist!"
)
mace_check
(
os
.
path
.
isdir
(
FLAGS
.
output_dir
),
"Output directory '"
+
FLAGS
.
output_dir
+
"' does not exist!"
)
def
save_model_to_proto
(
net_def
,
model_name
,
output_dir
):
output_path
=
output_dir
+
"/"
+
model_name
+
".pb"
with
open
(
output_path
,
"wb"
)
as
f
:
f
.
write
(
net_def
.
SerializeToString
())
with
open
(
output_path
+
"_txt"
,
"w"
)
as
f
:
f
.
write
(
str
(
net_def
))
return
output_path
def
convert
(
model_file
,
output_dir
,
layers
):
mace_check
(
os
.
path
.
isfile
(
model_file
),
"Input graph file '"
+
model_file
+
"' does not exist!"
)
mace_check
(
os
.
path
.
isdir
(
output_dir
),
"Output directory '"
+
output_dir
+
"' does not exist!"
)
net_def
=
mace_pb2
.
NetDef
()
with
open
(
FLAGS
.
model_file
,
"rb"
)
as
f
:
with
open
(
model_file
,
"rb"
)
as
f
:
net_def
.
ParseFromString
(
f
.
read
())
quantize_flag
=
ConverterUtil
.
get_arg
(
...
...
@@ -89,7 +98,7 @@ def main(unused_args):
# omit original output
end_index
-=
1
index
,
end_index
=
handle_index
(
index
,
end_index
,
FLAGS
.
layers
)
index
,
end_index
=
handle_index
(
index
,
end_index
,
layers
)
data_format
=
net_def
.
output_info
[
0
].
data_format
output_configs
=
{
"subgraphs"
:
[]}
...
...
@@ -163,13 +172,13 @@ def main(unused_args):
del
dequantize_op
.
node_input
[
3
:]
model_path
=
save_model_to_proto
(
net
,
normalize_op_name
(
op_name
),
FLAGS
.
output_dir
)
output_dir
)
output_config
=
{
"model_file_path"
:
str
(
model_path
),
"output_tensors"
:
output_tensors
,
"output_shapes"
:
output_shapes
}
output_configs
[
"subgraphs"
].
append
(
output_config
)
output_configs_path
=
FLAGS
.
output_dir
+
"outputs.yml"
output_configs_path
=
output_dir
+
"outputs.yml"
with
open
(
output_configs_path
,
"w"
)
as
f
:
yaml
.
dump
(
output_configs
,
f
,
default_flow_style
=
False
)
...
...
@@ -197,5 +206,5 @@ def parse_args():
if
__name__
==
'__main__'
:
FLAGS
,
unparsed
=
parse_args
()
main
(
unused_args
=
[
sys
.
argv
[
0
]]
+
unparsed
)
FLAGS
,
_
=
parse_args
()
convert
(
FLAGS
.
model_file
,
FLAGS
.
output_dir
,
FLAGS
.
layers
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录