Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
4c9a444e
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看板
提交
4c9a444e
编写于
1月 22, 2019
作者:
刘
刘托
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into 'master'
Add Dockerfile arg and fix some bugs See merge request !962
上级
0f760ccd
858dda57
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
5 deletion
+52
-5
mace/ops/opencl/buffer_transformer.h
mace/ops/opencl/buffer_transformer.h
+1
-1
mace/ops/prior_box.cc
mace/ops/prior_box.cc
+1
-2
mace/ops/reshape.cc
mace/ops/reshape.cc
+8
-0
tools/common.py
tools/common.py
+26
-0
tools/device.py
tools/device.py
+7
-0
tools/sh_commands.py
tools/sh_commands.py
+2
-1
tools/validate.py
tools/validate.py
+7
-1
未找到文件。
mace/ops/opencl/buffer_transformer.h
浏览文件 @
4c9a444e
...
@@ -66,7 +66,7 @@ class OpenCLBufferTransformer {
...
@@ -66,7 +66,7 @@ class OpenCLBufferTransformer {
VLOG
(
2
)
<<
"Transform CPU Buffer "
<<
input
->
name
()
VLOG
(
2
)
<<
"Transform CPU Buffer "
<<
input
->
name
()
<<
" to GPU Buffer "
<<
internal_tensor
->
name
()
<<
" to GPU Buffer "
<<
internal_tensor
->
name
()
<<
" with data type "
<<
dt
;
<<
" with data type "
<<
dt
;
if
(
data_format
==
DataFormat
::
N
HWC
&&
input
->
shape
().
size
()
==
4
)
{
if
(
data_format
==
DataFormat
::
N
CHW
&&
input
->
shape
().
size
()
==
4
)
{
// 1. (NCHW -> NHWC)
// 1. (NCHW -> NHWC)
std
::
vector
<
int
>
dst_dims
=
{
0
,
2
,
3
,
1
};
std
::
vector
<
int
>
dst_dims
=
{
0
,
2
,
3
,
1
};
std
::
vector
<
index_t
>
output_shape
=
std
::
vector
<
index_t
>
output_shape
=
...
...
mace/ops/prior_box.cc
浏览文件 @
4c9a444e
...
@@ -72,10 +72,9 @@ class PriorBoxOp : public Operation {
...
@@ -72,10 +72,9 @@ class PriorBoxOp : public Operation {
Tensor
::
MappingGuard
output_guard
(
output
);
Tensor
::
MappingGuard
output_guard
(
output
);
T
*
output_data
=
output
->
mutable_data
<
T
>
();
T
*
output_data
=
output
->
mutable_data
<
T
>
();
float
box_w
,
box_h
;
float
box_w
,
box_h
;
#pragma omp parallel for collapse(2) schedule(runtime)
for
(
index_t
i
=
0
;
i
<
input_h
;
++
i
)
{
for
(
index_t
i
=
0
;
i
<
input_h
;
++
i
)
{
index_t
idx
=
i
*
input_w
*
num_prior
*
4
;
for
(
index_t
j
=
0
;
j
<
input_w
;
++
j
)
{
for
(
index_t
j
=
0
;
j
<
input_w
;
++
j
)
{
index_t
idx
=
i
*
input_w
*
num_prior
*
4
;
float
center_y
=
(
offset_
+
i
)
*
step_h
;
float
center_y
=
(
offset_
+
i
)
*
step_h
;
float
center_x
=
(
offset_
+
j
)
*
step_w
;
float
center_x
=
(
offset_
+
j
)
*
step_w
;
for
(
index_t
k
=
0
;
k
<
num_min_size
;
++
k
)
{
for
(
index_t
k
=
0
;
k
<
num_min_size
;
++
k
)
{
...
...
mace/ops/reshape.cc
浏览文件 @
4c9a444e
...
@@ -77,6 +77,14 @@ class ReshapeOp : public Operation {
...
@@ -77,6 +77,14 @@ class ReshapeOp : public Operation {
}
}
Tensor
*
output
=
this
->
Output
(
OUTPUT
);
Tensor
*
output
=
this
->
Output
(
OUTPUT
);
// NCHW -> NHWC
if
(
D
==
DeviceType
::
GPU
&&
out_shape
.
size
()
==
4
)
{
std
::
vector
<
int
>
dst_dims
=
{
0
,
2
,
3
,
1
};
std
::
vector
<
index_t
>
out_shape_gpu
=
TransposeShape
<
index_t
,
index_t
>
(
out_shape
,
dst_dims
);
out_shape
=
out_shape_gpu
;
}
output
->
ReuseTensorBuffer
(
*
input
);
output
->
ReuseTensorBuffer
(
*
input
);
output
->
Reshape
(
out_shape
);
output
->
Reshape
(
out_shape
);
...
...
tools/common.py
浏览文件 @
4c9a444e
...
@@ -209,6 +209,30 @@ def sha256_checksum(fname):
...
@@ -209,6 +209,30 @@ def sha256_checksum(fname):
return
hash_func
.
hexdigest
()
return
hash_func
.
hexdigest
()
def
get_dockerfile_file
(
dockerfile_path
=
""
,
dockerfile_sha256_checksum
=
""
):
dockerfile
=
dockerfile_path
if
dockerfile_path
.
startswith
(
"http://"
)
or
\
dockerfile_path
.
startswith
(
"https://"
):
dockerfile
=
\
"third_party/caffe/"
+
md5sum
(
dockerfile_path
)
+
"/Dockerfile"
if
not
os
.
path
.
exists
(
dockerfile
)
or
\
sha256_checksum
(
dockerfile
)
!=
dockerfile_sha256_checksum
:
os
.
makedirs
(
dockerfile
.
strip
(
"/Dockerfile"
))
MaceLogger
.
info
(
"Downloading Dockerfile, please wait ..."
)
six
.
moves
.
urllib
.
request
.
urlretrieve
(
dockerfile_path
,
dockerfile
)
MaceLogger
.
info
(
"Dockerfile downloaded successfully."
)
if
dockerfile
:
if
sha256_checksum
(
dockerfile
)
!=
dockerfile_sha256_checksum
:
MaceLogger
.
error
(
ModuleName
.
MODEL_CONVERTER
,
"Dockerfile sha256checksum not match"
)
else
:
dockerfile
=
"third_party/caffe"
return
dockerfile
def
get_model_files
(
model_file_path
,
def
get_model_files
(
model_file_path
,
model_sha256_checksum
,
model_sha256_checksum
,
model_output_dir
,
model_output_dir
,
...
@@ -373,6 +397,8 @@ class YAMLKeyword(object):
...
@@ -373,6 +397,8 @@ class YAMLKeyword(object):
graph_optimize_options
=
'graph_optimize_options'
# internal use for now
graph_optimize_options
=
'graph_optimize_options'
# internal use for now
cl_mem_type
=
'cl_mem_type'
cl_mem_type
=
'cl_mem_type'
backend
=
'backend'
backend
=
'backend'
dockerfile_path
=
'dockerfile_path'
dockerfile_sha256_checksum
=
'dockerfile_sha256_checksum'
################################
################################
...
...
tools/device.py
浏览文件 @
4c9a444e
...
@@ -624,11 +624,18 @@ class DeviceWrapper:
...
@@ -624,11 +624,18 @@ class DeviceWrapper:
validate_type
=
device_type
validate_type
=
device_type
if
model_config
[
YAMLKeyword
.
quantize
]
==
1
:
if
model_config
[
YAMLKeyword
.
quantize
]
==
1
:
validate_type
=
device_type
+
'_QUANTIZE'
validate_type
=
device_type
+
'_QUANTIZE'
dockerfile_path
=
get_dockerfile_file
(
model_config
.
get
(
YAMLKeyword
.
dockerfile_path
),
model_config
.
get
(
YAMLKeyword
.
dockerfile_sha256_checksum
)
# noqa
)
if
YAMLKeyword
.
dockerfile_path
in
model_config
else
"third_party/caffe"
# noqa
sh_commands
.
validate_model
(
sh_commands
.
validate_model
(
abi
=
target_abi
,
abi
=
target_abi
,
device
=
self
,
device
=
self
,
model_file_path
=
model_file_path
,
model_file_path
=
model_file_path
,
weight_file_path
=
weight_file_path
,
weight_file_path
=
weight_file_path
,
dockerfile_path
=
dockerfile_path
,
platform
=
model_config
[
YAMLKeyword
.
platform
],
platform
=
model_config
[
YAMLKeyword
.
platform
],
device_type
=
device_type
,
device_type
=
device_type
,
input_nodes
=
subgraphs
[
0
][
input_nodes
=
subgraphs
[
0
][
...
...
tools/sh_commands.py
浏览文件 @
4c9a444e
...
@@ -627,6 +627,7 @@ def validate_model(abi,
...
@@ -627,6 +627,7 @@ def validate_model(abi,
device
,
device
,
model_file_path
,
model_file_path
,
weight_file_path
,
weight_file_path
,
dockerfile_path
,
platform
,
platform
,
device_type
,
device_type
,
input_nodes
,
input_nodes
,
...
@@ -690,7 +691,7 @@ def validate_model(abi,
...
@@ -690,7 +691,7 @@ def validate_model(abi,
if
not
docker_image_id
:
if
not
docker_image_id
:
six
.
print_
(
"Build caffe docker"
)
six
.
print_
(
"Build caffe docker"
)
sh
.
docker
(
"build"
,
"-t"
,
image_name
,
sh
.
docker
(
"build"
,
"-t"
,
image_name
,
"third_party/caffe"
)
dockerfile_path
)
container_id
=
sh
.
docker
(
"ps"
,
"-qa"
,
"-f"
,
container_id
=
sh
.
docker
(
"ps"
,
"-qa"
,
"-f"
,
"name=%s"
%
container_name
)
"name=%s"
%
container_name
)
...
...
tools/validate.py
浏览文件 @
4c9a444e
...
@@ -357,6 +357,11 @@ def parse_args():
...
@@ -357,6 +357,11 @@ def parse_args():
type
=
str
,
type
=
str
,
default
=
"tensorflow"
,
default
=
"tensorflow"
,
help
=
"onnx backend framwork"
)
help
=
"onnx backend framwork"
)
parser
.
add_argument
(
"--log_file"
,
type
=
str
,
default
=
""
,
help
=
"log file"
)
return
parser
.
parse_known_args
()
return
parser
.
parse_known_args
()
...
@@ -375,4 +380,5 @@ if __name__ == '__main__':
...
@@ -375,4 +380,5 @@ if __name__ == '__main__':
FLAGS
.
output_node
,
FLAGS
.
output_node
,
FLAGS
.
validation_threshold
,
FLAGS
.
validation_threshold
,
FLAGS
.
input_data_type
,
FLAGS
.
input_data_type
,
FLAGS
.
backend
)
FLAGS
.
backend
,
FLAGS
.
log_file
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录