Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
e71a13c4
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看板
提交
e71a13c4
编写于
2月 11, 2018
作者:
李
李寅
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'update_build_run_merge_process' into 'master'
refactor validate_model.sh with python See merge request !23
上级
b6eb7b8a
2ac3ca52
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
51 addition
and
45 deletion
+51
-45
python/tools/binary_codegen.py
python/tools/binary_codegen.py
+33
-29
python/tools/opencl_codegen.py
python/tools/opencl_codegen.py
+18
-16
未找到文件。
python/tools/binary_codegen.py
浏览文件 @
e71a13c4
...
@@ -8,23 +8,22 @@ import jinja2
...
@@ -8,23 +8,22 @@ import jinja2
import
numpy
as
np
import
numpy
as
np
# python mace/python/tools/binary_codegen.py \
# python mace/python/tools/binary_codegen.py \
# --binary_file=${BIN_FILE} --output_path=${CODE_GEN_PATH} --variable_name=kTuningParamsData
# --binary_dirs=${BIN_FILE} \
# --binary_file_name=mace_run.config \
# --output_path=${CODE_GEN_PATH} --variable_name=kTuningParamsData
FLAGS
=
None
FLAGS
=
None
def
generate_cpp_source
():
def
generate_cpp_source
():
data_map
=
{}
data_map
=
{}
if
not
os
.
path
.
exists
(
FLAGS
.
binary_file
):
for
binary_dir
in
FLAGS
.
binary_dirs
.
split
(
","
):
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
binary_path
=
os
.
path
.
join
(
binary_dir
,
FLAGS
.
binary_file_name
)
return
env
.
get_template
(
'str2vec_maps.cc.tmpl'
).
render
(
if
not
os
.
path
.
exists
(
binary_path
):
maps
=
data_map
,
continue
data_type
=
'unsigned int'
,
variable_name
=
FLAGS
.
variable_name
)
with
open
(
FLAGS
.
binary_file
,
"rb"
)
as
binary_file
:
with
open
(
binary_path
,
"rb"
)
as
f
:
binary_array
=
np
.
fromfile
(
binary_file
,
dtype
=
np
.
uint8
)
binary_array
=
np
.
fromfile
(
f
,
dtype
=
np
.
uint8
)
idx
=
0
idx
=
0
size
,
=
struct
.
unpack
(
"Q"
,
binary_array
[
idx
:
idx
+
8
])
size
,
=
struct
.
unpack
(
"Q"
,
binary_array
[
idx
:
idx
+
8
])
...
@@ -63,10 +62,15 @@ def parse_args():
...
@@ -63,10 +62,15 @@ def parse_args():
"""Parses command line arguments."""
"""Parses command line arguments."""
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
parser
.
add_argument
(
"--binary_
file
"
,
"--binary_
dirs
"
,
type
=
str
,
type
=
str
,
default
=
""
,
default
=
"
cl_bin0/,cl_bin1/
"
,
help
=
"The binaries file path."
)
help
=
"The binaries file path."
)
parser
.
add_argument
(
"--binary_file_name"
,
type
=
str
,
default
=
"mace_run.config"
,
help
=
"The binary file name."
)
parser
.
add_argument
(
parser
.
add_argument
(
"--output_path"
,
"--output_path"
,
type
=
str
,
type
=
str
,
...
...
python/tools/opencl_codegen.py
浏览文件 @
e71a13c4
...
@@ -7,15 +7,19 @@ import numpy as np
...
@@ -7,15 +7,19 @@ import numpy as np
import
jinja2
import
jinja2
# python mace/python/tools/opencl_codegen.py \
# python mace/python/tools/opencl_codegen.py \
# --cl_binary_dir=${CL_BIN_DIR} --output_path=${CL_HEADER_PATH}
# --cl_binary_dir
s
=${CL_BIN_DIR} --output_path=${CL_HEADER_PATH}
FLAGS
=
None
FLAGS
=
None
def
generate_cpp_source
():
def
generate_cpp_source
():
maps
=
{}
maps
=
{}
for
file_name
in
os
.
listdir
(
FLAGS
.
cl_binary_dir
):
cl_binary_dir_arr
=
FLAGS
.
cl_binary_dirs
.
split
(
","
)
file_path
=
os
.
path
.
join
(
FLAGS
.
cl_binary_dir
,
file_name
)
for
cl_binary_dir
in
cl_binary_dir_arr
:
if
not
os
.
path
.
exists
(
cl_binary_dir
):
print
(
"Input cl_binary_dir "
+
cl_binary_dir
+
" doesn't exist!"
)
for
file_name
in
os
.
listdir
(
cl_binary_dir
):
file_path
=
os
.
path
.
join
(
cl_binary_dir
,
file_name
)
if
file_path
[
-
4
:]
==
".bin"
:
if
file_path
[
-
4
:]
==
".bin"
:
# read binary
# read binary
f
=
open
(
file_path
,
"rb"
)
f
=
open
(
file_path
,
"rb"
)
...
@@ -35,8 +39,6 @@ def generate_cpp_source():
...
@@ -35,8 +39,6 @@ def generate_cpp_source():
def
main
(
unused_args
):
def
main
(
unused_args
):
if
not
os
.
path
.
exists
(
FLAGS
.
cl_binary_dir
):
print
(
"Input cl_binary_dir "
+
FLAGS
.
cl_binary_dir
+
" doesn't exist!"
)
cpp_cl_binary_source
=
generate_cpp_source
()
cpp_cl_binary_source
=
generate_cpp_source
()
if
os
.
path
.
isfile
(
FLAGS
.
output_path
):
if
os
.
path
.
isfile
(
FLAGS
.
output_path
):
...
@@ -50,10 +52,10 @@ def parse_args():
...
@@ -50,10 +52,10 @@ def parse_args():
"""Parses command line arguments."""
"""Parses command line arguments."""
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
parser
.
add_argument
(
"--cl_binary_dir"
,
"--cl_binary_dir
s
"
,
type
=
str
,
type
=
str
,
default
=
"
./cl_bin
/"
,
default
=
"
cl_bin0/,cl_bin1/,cl_bin2
/"
,
help
=
"The cl binaries director
y
."
)
help
=
"The cl binaries director
ies
."
)
parser
.
add_argument
(
parser
.
add_argument
(
"--output_path"
,
"--output_path"
,
type
=
str
,
type
=
str
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录