Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
2203cdd0
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
2203cdd0
编写于
1月 10, 2018
作者:
W
wuchenghui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix validate_gcn_dsp.sh
上级
7eb89818
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
9 deletion
+32
-9
mace/python/tools/binary_codegen.py
mace/python/tools/binary_codegen.py
+9
-2
tools/gcn.config
tools/gcn.config
+2
-1
tools/validate.py
tools/validate.py
+1
-1
tools/validate_gcn_dsp.sh
tools/validate_gcn_dsp.sh
+20
-5
未找到文件。
mace/python/tools/binary_codegen.py
浏览文件 @
2203cdd0
...
...
@@ -14,11 +14,18 @@ FLAGS = None
def
generate_cpp_source
():
data_map
=
{}
if
not
os
.
path
.
exists
(
FLAGS
.
binary_file
):
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
return
env
.
get_template
(
'str2vec_maps.cc.tmpl'
).
render
(
maps
=
data_map
,
data_type
=
'unsigned int'
,
variable_name
=
FLAGS
.
variable_name
)
with
open
(
FLAGS
.
binary_file
,
"rb"
)
as
binary_file
:
binary_array
=
np
.
fromfile
(
binary_file
,
dtype
=
np
.
uint8
)
data_map
=
{}
idx
=
0
size
,
=
struct
.
unpack
(
"Q"
,
binary_array
[
idx
:
idx
+
8
])
print
size
...
...
tools/gcn.config
浏览文件 @
2203cdd0
TF_INPUT_NODE
=
input
TF_OUTPUT_NODE
=
softmax
/
Reshape_1
\ No newline at end of file
TF_OUTPUT_NODE
=
softmax
/
Reshape_1
TF_OUTPUT_BR_NODE
=
GCN
/
br_result_2
/
fcn_br
\ No newline at end of file
tools/validate.py
浏览文件 @
2203cdd0
...
...
@@ -21,7 +21,7 @@ from tensorflow import gfile
def
generate_data
(
shape
):
np
.
random
.
seed
()
data
=
np
.
random
.
random
(
shape
)
*
-
1
data
=
np
.
random
.
random
(
shape
)
*
2
-
1
print
FLAGS
.
input_file
data
.
astype
(
np
.
float32
).
tofile
(
FLAGS
.
input_file
)
print
"Generate input file done."
...
...
tools/validate_gcn_dsp.sh
浏览文件 @
2203cdd0
...
...
@@ -27,6 +27,9 @@ KERNEL_DIR="${PHONE_DATA_DIR}/cl/"
CODEGEN_DIR
=
${
MACE_SOURCE_DIR
}
/mace/codegen
MODEL_CODEGEN_DIR
=
${
CODEGEN_DIR
}
/models/
${
MODEL_TAG
}
VERSION_SOURCE_PATH
=
${
CODEGEN_DIR
}
/version
CL_CODEGEN_DIR
=
${
CODEGEN_DIR
}
/opencl
CL_BIN_DIR
=
${
CODEGEN_DIR
}
/opencl_bin
TUNING_CODEGEN_DIR
=
${
CODEGEN_DIR
}
/tuning
build_and_run
()
{
...
...
@@ -71,7 +74,7 @@ mkdir -p ${MODEL_CODEGEN_DIR}
bazel-bin/mace/python/tools/tf_converter
--input
=
${
TF_MODEL_FILE_PATH
}
\
--output
=
${
MODEL_CODEGEN_DIR
}
/mace_gcn
${
IMAGE_SIZE
}
.cc
\
--input_node
=
${
TF_INPUT_NODE
}
\
--output_node
=
${
TF_OUTPUT_NODE
}
\
--output_node
=
${
TF_OUTPUT_
BR_
NODE
}
\
--data_type
=
DT_UINT8
\
--runtime
=
dsp
\
--output_type
=
source
\
...
...
@@ -84,18 +87,30 @@ rm -rf ${VERSION_SOURCE_PATH}
mkdir
-p
${
VERSION_SOURCE_PATH
}
bash mace/tools/git/gen_version_source.sh
${
VERSION_SOURCE_PATH
}
/version.cc
echo
"Step 4: Run model on the phone with files"
echo
"Step 4: Generate OpenCL binary program and config code"
rm
-rf
${
CL_BIN_DIR
}
mkdir
-p
${
CL_BIN_DIR
}
python mace/python/tools/opencl_codegen.py
\
--cl_binary_dir
=
${
CL_BIN_DIR
}
--output_path
=
${
CL_CODEGEN_DIR
}
/opencl_compiled_program.cc
echo
"Step 5: Generate tuning source file"
rm
-rf
${
TUNING_CODEGEN_DIR
}
mkdir
-p
${
TUNING_CODEGEN_DIR
}
python mace/python/tools/binary_codegen.py
\
--binary_file
=
${
CL_BIN_DIR
}
/mace_run.config
--output_path
=
${
TUNING_CODEGEN_DIR
}
/tuning_params.cc
echo
"Step 6: Run model on the phone with files"
build_and_run
echo
"Step
5
: Pull the mace run result."
echo
"Step
7
: Pull the mace run result."
rm
-rf
${
MODEL_DIR
}
/
${
OUTPUT_FILE_NAME
}
adb </dev/null pull
${
PHONE_DATA_DIR
}
/
${
OUTPUT_FILE_NAME
}
${
MODEL_DIR
}
echo
"Step
6
: Validate the result"
echo
"Step
8
: Validate the result"
python tools/validate.py
--model_file
${
TF_MODEL_FILE_PATH
}
\
--input_file
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
\
--mace_out_file
${
MODEL_DIR
}
/
${
OUTPUT_FILE_NAME
}
\
--input_node
${
TF_INPUT_NODE
}
\
--output_node
${
TF_OUTPUT_NODE
}
\
--output_node
${
TF_OUTPUT_
BR_
NODE
}
\
--input_shape
"
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,3"
\
--output_shape
"1,
${
IMAGE_SIZE
}
,
${
IMAGE_SIZE
}
,2"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录