Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
a7f36675
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看板
提交
a7f36675
编写于
1月 09, 2018
作者:
李
李寅
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor hexagon engine since several changes break it.
上级
6e946c75
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
22 deletion
+30
-22
mace/core/mace.cc
mace/core/mace.cc
+15
-11
mace/core/runtime/hexagon/hexagon_control_wrapper.cc
mace/core/runtime/hexagon/hexagon_control_wrapper.cc
+1
-1
mace/core/runtime/hexagon/libhexagon_controller.so
mace/core/runtime/hexagon/libhexagon_controller.so
+0
-0
mace/examples/mace_run.cc
mace/examples/mace_run.cc
+2
-2
tools/validate_gcn_dsp.sh
tools/validate_gcn_dsp.sh
+12
-8
未找到文件。
mace/core/mace.cc
浏览文件 @
a7f36675
...
@@ -513,14 +513,22 @@ const OperatorDef &NetDef::op(const int idx) const {
...
@@ -513,14 +513,22 @@ const OperatorDef &NetDef::op(const int idx) const {
MaceEngine
::
MaceEngine
(
const
NetDef
*
net_def
,
DeviceType
device_type
)
:
MaceEngine
::
MaceEngine
(
const
NetDef
*
net_def
,
DeviceType
device_type
)
:
op_registry_
(
new
OperatorRegistry
()),
device_type_
(
device_type
),
op_registry_
(
new
OperatorRegistry
()),
device_type_
(
device_type
),
ws_
(
new
Workspace
()),
net_
(
nullptr
),
hexagon_controller_
(
nullptr
)
{
ws_
(
new
Workspace
()),
net_
(
nullptr
),
hexagon_controller_
(
nullptr
)
{
ws_
->
CreateTensor
(
"mace_input_node:0"
,
GetDeviceAllocator
(
device_type_
),
DT_FLOAT
);
ws_
->
CreateTensor
(
"mace_output_node:0"
,
GetDeviceAllocator
(
device_type_
),
DT_FLOAT
);
if
(
device_type
==
HEXAGON
)
{
if
(
device_type
==
HEXAGON
)
{
hexagon_controller_
.
reset
(
new
HexagonControlWrapper
());
hexagon_controller_
.
reset
(
new
HexagonControlWrapper
());
hexagon_controller_
->
Init
();
hexagon_controller_
->
Init
();
hexagon_controller_
->
SetDebugLevel
(
0
);
hexagon_controller_
->
SetDebugLevel
(
static_cast
<
int
>
(
mace
::
internal
::
LogMessage
::
MinVLogLevel
()));
hexagon_controller_
->
Config
();
hexagon_controller_
->
Config
();
hexagon_controller_
->
SetupGraph
(
*
net_def
);
hexagon_controller_
->
SetupGraph
(
*
net_def
);
hexagon_controller_
->
PrintGraph
();
if
(
VLOG_IS_ON
(
2
))
{
hexagon_controller_
->
PrintGraph
();
}
}
else
{
}
else
{
ws_
->
LoadModelTensor
(
*
net_def
,
device_type
);
ws_
->
LoadModelTensor
(
*
net_def
,
device_type
);
...
@@ -531,19 +539,15 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type) :
...
@@ -531,19 +539,15 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type) :
LOG
(
FATAL
)
<<
"Net init run failed"
;
LOG
(
FATAL
)
<<
"Net init run failed"
;
}
}
ws_
->
RemoveUnsedTensor
();
ws_
->
RemoveUnsedTensor
();
ws_
->
CreateTensor
(
"mace_input_node:0"
,
GetDeviceAllocator
(
device_type_
),
DT_FLOAT
);
ws_
->
CreateTensor
(
"mace_output_node:0"
,
GetDeviceAllocator
(
device_type_
),
DT_FLOAT
);
net_
=
std
::
move
(
CreateNet
(
op_registry_
,
*
net_def
,
ws_
.
get
(),
device_type
));
net_
=
std
::
move
(
CreateNet
(
op_registry_
,
*
net_def
,
ws_
.
get
(),
device_type
));
}
}
}
}
MaceEngine
::~
MaceEngine
()
{
MaceEngine
::~
MaceEngine
()
{
if
(
device_type_
==
HEXAGON
)
{
if
(
device_type_
==
HEXAGON
)
{
hexagon_controller_
->
GetPerfInfo
();
if
(
VLOG_IS_ON
(
2
))
{
hexagon_controller_
->
PrintLog
();
hexagon_controller_
->
GetPerfInfo
();
hexagon_controller_
->
PrintLog
();
}
hexagon_controller_
->
TeardownGraph
();
hexagon_controller_
->
TeardownGraph
();
hexagon_controller_
->
Finalize
();
hexagon_controller_
->
Finalize
();
}
}
...
...
mace/core/runtime/hexagon/hexagon_control_wrapper.cc
浏览文件 @
a7f36675
...
@@ -184,7 +184,7 @@ void HexagonControlWrapper::SetDebugLevel(int level) {
...
@@ -184,7 +184,7 @@ void HexagonControlWrapper::SetDebugLevel(int level) {
void
HexagonControlWrapper
::
GetPerfInfo
()
{
void
HexagonControlWrapper
::
GetPerfInfo
()
{
LOG
(
INFO
)
<<
"Get perf info"
;
LOG
(
INFO
)
<<
"Get perf info"
;
vector
<
hexagon_nn_perfinfo
>
perf_info
(
MAX_NODE
);
vector
<
hexagon_nn_perfinfo
>
perf_info
(
MAX_NODE
);
unsigned
int
n_items
;
unsigned
int
n_items
=
0
;
hexagon_nn_get_perfinfo
(
nn_id_
,
perf_info
.
data
(),
MAX_NODE
,
&
n_items
);
hexagon_nn_get_perfinfo
(
nn_id_
,
perf_info
.
data
(),
MAX_NODE
,
&
n_items
);
std
::
unordered_map
<
uint32_t
,
float
>
node_id_counters
;
std
::
unordered_map
<
uint32_t
,
float
>
node_id_counters
;
...
...
mace/core/runtime/hexagon/libhexagon_controller.so
浏览文件 @
a7f36675
无法预览此类型文件
mace/examples/mace_run.cc
浏览文件 @
a7f36675
...
@@ -124,7 +124,7 @@ int main(int argc, char **argv) {
...
@@ -124,7 +124,7 @@ int main(int argc, char **argv) {
Flag
(
"output_shape"
,
&
output_shape
,
"output shape, separated by comma"
),
Flag
(
"output_shape"
,
&
output_shape
,
"output shape, separated by comma"
),
Flag
(
"input_file"
,
&
input_file
,
"input file name"
),
Flag
(
"input_file"
,
&
input_file
,
"input file name"
),
Flag
(
"output_file"
,
&
output_file
,
"output file name"
),
Flag
(
"output_file"
,
&
output_file
,
"output file name"
),
Flag
(
"device"
,
&
device
,
"CPU/NEON"
),
Flag
(
"device"
,
&
device
,
"CPU/NEON
/OPENCL/HEXAGON
"
),
Flag
(
"round"
,
&
round
,
"round"
),
Flag
(
"round"
,
&
round
,
"round"
),
Flag
(
"malloc_check_cycle"
,
&
malloc_check_cycle
,
Flag
(
"malloc_check_cycle"
,
&
malloc_check_cycle
,
"malloc debug check cycle, -1 to disable"
),
"malloc debug check cycle, -1 to disable"
),
...
@@ -175,7 +175,7 @@ int main(int argc, char **argv) {
...
@@ -175,7 +175,7 @@ int main(int argc, char **argv) {
input_size
*
sizeof
(
float
));
input_size
*
sizeof
(
float
));
in_file
.
close
();
in_file
.
close
();
}
else
{
}
else
{
LOG
(
ERROR
)
<<
"Open input file failed"
;
LOG
(
FATAL
)
<<
"Open input file failed"
;
}
}
// Init model
// Init model
...
...
tools/validate_gcn_dsp.sh
浏览文件 @
a7f36675
...
@@ -36,13 +36,17 @@ build_and_run()
...
@@ -36,13 +36,17 @@ build_and_run()
--cpu
=
armeabi-v7a
\
--cpu
=
armeabi-v7a
\
--copt
=
"-std=c++11"
\
--copt
=
"-std=c++11"
\
--copt
=
"-D_GLIBCXX_USE_C99_MATH_TR1"
\
--copt
=
"-D_GLIBCXX_USE_C99_MATH_TR1"
\
--copt
=
"-Werror=return-type"
--copt
=
"-Werror=return-type"
\
--copt
=
"-DMACE_MODEL_TAG=
${
MODEL_TAG
}
"
\
--define
hexagon
=
true
--define
production
=
true
||
exit
-1
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
||
exit
-1
adb push
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
${
PHONE_DATA_DIR
}
adb push
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
${
PHONE_DATA_DIR
}
||
exit
-1
adb push bazel-bin/mace/examples/mace_run
${
PHONE_DATA_DIR
}
adb push bazel-bin/mace/examples/mace_run
${
PHONE_DATA_DIR
}
||
exit
-1
adb push mace/core/runtime/hexagon/libhexagon_controller.so
${
PHONE_DATA_DIR
}
||
exit
-1
adb </dev/null shell
\
adb </dev/null shell
\
LD_LIBRARY_PATH
=
${
PHONE_DATA_DIR
}
\
MACE_CPP_MIN_VLOG_LEVEL
=
$VLOG_LEVEL
\
MACE_CPP_MIN_VLOG_LEVEL
=
$VLOG_LEVEL
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
${
PHONE_DATA_DIR
}
/mace_run
\
${
PHONE_DATA_DIR
}
/mace_run
\
...
@@ -50,15 +54,15 @@ build_and_run()
...
@@ -50,15 +54,15 @@ build_and_run()
--output_shape
=
"1,
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,2"
\
--output_shape
=
"1,
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,2"
\
--input_file
=
${
PHONE_DATA_DIR
}
/
${
INPUT_FILE_NAME
}
\
--input_file
=
${
PHONE_DATA_DIR
}
/
${
INPUT_FILE_NAME
}
\
--output_file
=
${
PHONE_DATA_DIR
}
/
${
OUTPUT_FILE_NAME
}
\
--output_file
=
${
PHONE_DATA_DIR
}
/
${
OUTPUT_FILE_NAME
}
\
--device
=
HEXAGON
\
--device
=
HEXAGON
\
--round
=
$round
--round
=
2
||
exit
-1
}
}
echo
"Step 1: Generate input data"
echo
"Step 1: Generate input data"
rm
-rf
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
rm
-rf
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
python tools/validate.py
--generate_data
true
\
python tools/validate.py
--generate_data
true
\
--input_file
=
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
\
--input_file
=
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
\
--input_shape
=
"
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,3"
--input_shape
=
"
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,3"
||
exit
-1
echo
"Step 2: Convert tf model to mace model and optimize memory"
echo
"Step 2: Convert tf model to mace model and optimize memory"
bazel build //mace/python/tools:tf_converter
bazel build //mace/python/tools:tf_converter
...
@@ -73,7 +77,7 @@ bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
...
@@ -73,7 +77,7 @@ bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
--output_type
=
source
\
--output_type
=
source
\
--template
=
${
MACE_SOURCE_DIR
}
/mace/python/tools/model.template
\
--template
=
${
MACE_SOURCE_DIR
}
/mace/python/tools/model.template
\
--model_tag
=
${
MODEL_TAG
}
\
--model_tag
=
${
MODEL_TAG
}
\
--obfuscate
=
True
--obfuscate
=
True
||
exit
-1
echo
"Step 3: Generate version source"
echo
"Step 3: Generate version source"
rm
-rf
${
VERSION_SOURCE_PATH
}
rm
-rf
${
VERSION_SOURCE_PATH
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录