Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
0dba25ac
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看板
提交
0dba25ac
编写于
7月 13, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
差异文件
merge with master
上级
8b824a98
17ac111e
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
71 addition
and
16 deletion
+71
-16
.gitlab-ci.yml
.gitlab-ci.yml
+6
-0
docs/installation/env_requirement.rst
docs/installation/env_requirement.rst
+4
-4
docs/user_guide/advanced_usage.rst
docs/user_guide/advanced_usage.rst
+12
-1
mace/libmace/mace_runtime.cc
mace/libmace/mace_runtime.cc
+10
-2
mace/python/tools/encrypt_opencl_codegen.py
mace/python/tools/encrypt_opencl_codegen.py
+2
-0
mace/tools/git/gen_version_source.sh
mace/tools/git/gen_version_source.sh
+4
-5
repository/git/git_configure.bzl
repository/git/git_configure.bzl
+3
-1
repository/opencl-kernel/opencl_kernel_configure.bzl
repository/opencl-kernel/opencl_kernel_configure.bzl
+28
-1
tools/converter.py
tools/converter.py
+0
-1
tools/sh_commands.py
tools/sh_commands.py
+2
-1
未找到文件。
.gitlab-ci.yml
浏览文件 @
0dba25ac
...
@@ -3,6 +3,7 @@ stages:
...
@@ -3,6 +3,7 @@ stages:
-
pycodestyle
-
pycodestyle
-
docs
-
docs
-
platform_compatible_tests
-
platform_compatible_tests
-
build_libraries
-
ndk_versions_compatible_tests
-
ndk_versions_compatible_tests
-
ops_test
-
ops_test
-
api_test
-
api_test
...
@@ -72,6 +73,11 @@ platform_compatible_tests:
...
@@ -72,6 +73,11 @@ platform_compatible_tests:
script
:
script
:
-
bazel build mace/core:core
-
bazel build mace/core:core
build_libraries
:
stage
:
build_libraries
script
:
-
bash tools/build-standalone-lib.sh
ndk_versions_compatible_tests
:
ndk_versions_compatible_tests
:
stage
:
ndk_versions_compatible_tests
stage
:
ndk_versions_compatible_tests
script
:
script
:
...
...
docs/installation/env_requirement.rst
浏览文件 @
0dba25ac
...
@@ -30,6 +30,9 @@ Required dependencies
...
@@ -30,6 +30,9 @@ Required dependencies
* - sh
* - sh
- pip install -I sh==1.12.14
- pip install -I sh==1.12.14
- 1.12.14
- 1.12.14
* - Numpy
- pip install -I numpy==1.14.0
- Required by model validation
Optional dependencies
Optional dependencies
---------------------
---------------------
...
@@ -52,15 +55,12 @@ Optional dependencies
...
@@ -52,15 +55,12 @@ Optional dependencies
* - Docker
* - Docker
- `docker installation guide <https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository>`__
- `docker installation guide <https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository>`__
- Required by docker mode for Caffe model
- Required by docker mode for Caffe model
* - Numpy
- pip install -I numpy==1.14.0
- Required by model validation
* - Scipy
* - Scipy
- pip install -I scipy==1.0.0
- pip install -I scipy==1.0.0
- Required by model validation
- Required by model validation
* - FileLock
* - FileLock
- pip install -I filelock==3.0.0
- pip install -I filelock==3.0.0
- Required by
Android run
- Required by
run on Android
.. note::
.. note::
...
...
docs/user_guide/advanced_usage.rst
浏览文件 @
0dba25ac
...
@@ -160,6 +160,17 @@ There are two common advanced use cases:
...
@@ -160,6 +160,17 @@ There are two common advanced use cases:
├── mobilenet-v1.a
├── mobilenet-v1.a
└── mobilenet_v1.data
└── mobilenet_v1.data
# model_graph_format: code
# model_data_format: code
builds
├── include
│ └── mace
│ └── public
│ ├── mace_engine_factory.h
│ └── mobilenet_v1.h
└── model
└── mobilenet-v1.a
* **3. Deployment**
* **3. Deployment**
* Link `libmace.a` and `${library_name}.a` to your target.
* Link `libmace.a` and `${library_name}.a` to your target.
...
@@ -182,7 +193,7 @@ There are two common advanced use cases:
...
@@ -182,7 +193,7 @@ There are two common advanced use cases:
// Create Engine from compiled code
// Create Engine from compiled code
create_engine_status =
create_engine_status =
CreateMaceEngineFromCode(model_name.c_str(),
CreateMaceEngineFromCode(model_name.c_str(),
nullptr,
model_data_file, // empty string if model_data_format is code
input_names,
input_names,
output_names,
output_names,
device_type,
device_type,
...
...
mace/libmace/mace_runtime.cc
浏览文件 @
0dba25ac
...
@@ -34,6 +34,7 @@ class FileStorageFactory::Impl {
...
@@ -34,6 +34,7 @@ class FileStorageFactory::Impl {
};
};
FileStorageFactory
::
Impl
::
Impl
(
const
std
::
string
&
path
)
:
path_
(
path
)
{}
FileStorageFactory
::
Impl
::
Impl
(
const
std
::
string
&
path
)
:
path_
(
path
)
{}
std
::
unique_ptr
<
KVStorage
>
FileStorageFactory
::
Impl
::
CreateStorage
(
std
::
unique_ptr
<
KVStorage
>
FileStorageFactory
::
Impl
::
CreateStorage
(
const
std
::
string
&
name
)
{
const
std
::
string
&
name
)
{
return
std
::
move
(
std
::
unique_ptr
<
KVStorage
>
(
return
std
::
move
(
std
::
unique_ptr
<
KVStorage
>
(
...
@@ -57,10 +58,13 @@ void SetKVStorageFactory(std::shared_ptr<KVStorageFactory> storage_factory) {
...
@@ -57,10 +58,13 @@ void SetKVStorageFactory(std::shared_ptr<KVStorageFactory> storage_factory) {
kStorageFactory
=
storage_factory
;
kStorageFactory
=
storage_factory
;
}
}
#ifdef MACE_ENABLE_OPENCL
// Set OpenCL Compiled Binary paths, just call once. (Not thread-safe)
// Set OpenCL Compiled Binary paths, just call once. (Not thread-safe)
void
SetOpenCLBinaryPaths
(
const
std
::
vector
<
std
::
string
>
&
paths
)
{
void
SetOpenCLBinaryPaths
(
const
std
::
vector
<
std
::
string
>
&
paths
)
{
#ifdef MACE_ENABLE_OPENCL
OpenCLRuntime
::
ConfigureOpenCLBinaryPath
(
paths
);
OpenCLRuntime
::
ConfigureOpenCLBinaryPath
(
paths
);
#else
MACE_UNUSED
(
paths
);
#endif // MACE_ENABLE_OPENCL
}
}
extern
std
::
string
kOpenCLParameterPath
;
extern
std
::
string
kOpenCLParameterPath
;
...
@@ -70,11 +74,15 @@ void SetOpenCLParameterPath(const std::string &path) {
...
@@ -70,11 +74,15 @@ void SetOpenCLParameterPath(const std::string &path) {
}
}
void
SetGPUHints
(
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
void
SetGPUHints
(
GPUPerfHint
gpu_perf_hint
,
GPUPriorityHint
gpu_priority_hint
)
{
#ifdef MACE_ENABLE_OPENCL
VLOG
(
1
)
<<
"Set GPU configurations, gpu_perf_hint: "
<<
gpu_perf_hint
VLOG
(
1
)
<<
"Set GPU configurations, gpu_perf_hint: "
<<
gpu_perf_hint
<<
", gpu_priority_hint: "
<<
gpu_priority_hint
;
<<
", gpu_priority_hint: "
<<
gpu_priority_hint
;
OpenCLRuntime
::
Configure
(
gpu_perf_hint
,
gpu_priority_hint
);
OpenCLRuntime
::
Configure
(
gpu_perf_hint
,
gpu_priority_hint
);
}
#else
MACE_UNUSED
(
gpu_perf_hint
);
MACE_UNUSED
(
gpu_priority_hint
);
#endif // MACE_ENABLE_OPENCL
#endif // MACE_ENABLE_OPENCL
}
MaceStatus
SetOpenMPThreadPolicy
(
int
num_threads_hint
,
MaceStatus
SetOpenMPThreadPolicy
(
int
num_threads_hint
,
CPUAffinityPolicy
policy
)
{
CPUAffinityPolicy
policy
)
{
...
...
mace/python/tools/encrypt_opencl_codegen.py
浏览文件 @
0dba25ac
...
@@ -87,6 +87,8 @@ def encrypt_opencl_codegen(cl_kernel_dir, output_path):
...
@@ -87,6 +87,8 @@ def encrypt_opencl_codegen(cl_kernel_dir, output_path):
with
open
(
output_path
,
"w"
)
as
w_file
:
with
open
(
output_path
,
"w"
)
as
w_file
:
w_file
.
write
(
cpp_cl_encrypted_kernel
)
w_file
.
write
(
cpp_cl_encrypted_kernel
)
print
(
'Generate OpenCL kernel done.'
)
def
parse_args
():
def
parse_args
():
"""Parses command line arguments."""
"""Parses command line arguments."""
...
...
mace/tools/git/gen_version_source.sh
浏览文件 @
0dba25ac
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
MACE_SOURCE_DIR
=
$(
dirname
$
0
)
MACE_SOURCE_DIR
=
$(
dirname
$
(
dirname
$(
dirname
$(
dirname
$0
)))
)
OUTPUT_FILENAME
=
$1
OUTPUT_FILENAME
=
$1
if
[[
-z
"
${
OUTPUT_FILENAME
}
}"
]]
;
then
if
[[
-z
"
${
OUTPUT_FILENAME
}
}"
]]
;
then
...
@@ -28,16 +28,16 @@ fi
...
@@ -28,16 +28,16 @@ fi
mkdir
-p
$OUTPUT_DIR
mkdir
-p
$OUTPUT_DIR
pushd
$MACE_SOURCE_DIR
DATE_STR
=
$(
date
+%Y%m%d
)
DATE_STR
=
$(
date
+%Y%m%d
)
GIT_VERSION
=
$(
git describe
--long
--tags
)
GIT_VERSION
=
$(
git
--git-dir
=
${
MACE_SOURCE_DIR
}
/.git
--work-tree
=
${
MACE_SOURCE_DIR
}
describe
--long
--tags
)
if
[[
$?
!=
0
]]
;
then
if
[[
$?
!=
0
]]
;
then
GIT_VERSION
=
unknown-
${
DATE_STR
}
GIT_VERSION
=
unknown-
${
DATE_STR
}
else
else
GIT_VERSION
=
${
GIT_VERSION
}
-
${
DATE_STR
}
GIT_VERSION
=
${
GIT_VERSION
}
-
${
DATE_STR
}
fi
fi
echo
$GIT_VERSION
cat
<<
EOF
>
${
OUTPUT_FILENAME
}
cat
<<
EOF
>
${
OUTPUT_FILENAME
}
// Copyright 2018 Xiaomi, Inc. All rights reserved.
// Copyright 2018 Xiaomi, Inc. All rights reserved.
//
//
...
@@ -61,4 +61,3 @@ const char *MaceVersion() { return "MACEVER-${GIT_VERSION}" + 8; }
...
@@ -61,4 +61,3 @@ const char *MaceVersion() { return "MACEVER-${GIT_VERSION}" + 8; }
} // namespace mace
} // namespace mace
EOF
EOF
popd
repository/git/git_configure.bzl
浏览文件 @
0dba25ac
...
@@ -9,6 +9,9 @@ def _git_version_conf_impl(repository_ctx):
...
@@ -9,6 +9,9 @@ def _git_version_conf_impl(repository_ctx):
generated_files_path
=
repository_ctx
.
path
(
"gen"
)
generated_files_path
=
repository_ctx
.
path
(
"gen"
)
unused_var
=
repository_ctx
.
path
(
Label
(
"//:.git/HEAD"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:.git/refs/heads/master"
))
repository_ctx
.
execute
([
repository_ctx
.
execute
([
'bash'
,
'%s/mace/tools/git/gen_version_source.sh'
%
mace_root_path
'bash'
,
'%s/mace/tools/git/gen_version_source.sh'
%
mace_root_path
,
'%s/version'
%
generated_files_path
,
'%s/version'
%
generated_files_path
...
@@ -17,5 +20,4 @@ def _git_version_conf_impl(repository_ctx):
...
@@ -17,5 +20,4 @@ def _git_version_conf_impl(repository_ctx):
git_version_repository
=
repository_rule
(
git_version_repository
=
repository_rule
(
implementation
=
_git_version_conf_impl
,
implementation
=
_git_version_conf_impl
,
local
=
True
,
)
)
repository/opencl-kernel/opencl_kernel_configure.bzl
浏览文件 @
0dba25ac
...
@@ -5,6 +5,34 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
...
@@ -5,6 +5,34 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
"BUILD"
,
"BUILD"
,
Label
(
"//repository/opencl-kernel:BUILD.tpl"
))
Label
(
"//repository/opencl-kernel:BUILD.tpl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:.git/HEAD"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:.git/refs/heads/master"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/activation.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/addn.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/batch_norm.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/bias_add.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/buffer_to_image.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/channel_shuffle.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/common.h"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/concat.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/conv_2d.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/conv_2d_1x1.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/conv_2d_3x3.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/deconv_2d.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/depth_to_space.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/depthwise_conv2d.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/eltwise.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/fully_connected.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/matmul.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/pad.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/pooling.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/reduce_mean.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/resize_bilinear.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/slice.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/softmax.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/space_to_batch.cl"
))
unused_var
=
repository_ctx
.
path
(
Label
(
"//:mace/kernels/opencl/cl/winograd_transform.cl"
))
mace_root_path
=
str
(
repository_ctx
.
path
(
Label
(
"@mace//:BUILD"
)))[:
-
len
(
"BUILD"
)]
mace_root_path
=
str
(
repository_ctx
.
path
(
Label
(
"@mace//:BUILD"
)))[:
-
len
(
"BUILD"
)]
generated_files_path
=
repository_ctx
.
path
(
"gen"
)
generated_files_path
=
repository_ctx
.
path
(
"gen"
)
...
@@ -20,5 +48,4 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
...
@@ -20,5 +48,4 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
encrypt_opencl_kernel_repository
=
repository_rule
(
encrypt_opencl_kernel_repository
=
repository_rule
(
implementation
=
_opencl_encrypt_kernel_impl
,
implementation
=
_opencl_encrypt_kernel_impl
,
local
=
True
,
)
)
tools/converter.py
浏览文件 @
0dba25ac
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
# limitations under the License.
# limitations under the License.
import
argparse
import
argparse
import
filelock
import
glob
import
glob
import
hashlib
import
hashlib
import
os
import
os
...
...
tools/sh_commands.py
浏览文件 @
0dba25ac
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
# limitations under the License.
# limitations under the License.
import
falcon_cli
import
falcon_cli
import
filelock
import
glob
import
glob
import
logging
import
logging
import
numpy
as
np
import
numpy
as
np
...
@@ -69,10 +68,12 @@ def device_lock_path(serialno):
...
@@ -69,10 +68,12 @@ def device_lock_path(serialno):
def
device_lock
(
serialno
,
timeout
=
3600
):
def
device_lock
(
serialno
,
timeout
=
3600
):
import
filelock
return
filelock
.
FileLock
(
device_lock_path
(
serialno
),
timeout
=
timeout
)
return
filelock
.
FileLock
(
device_lock_path
(
serialno
),
timeout
=
timeout
)
def
is_device_locked
(
serialno
):
def
is_device_locked
(
serialno
):
import
filelock
try
:
try
:
with
device_lock
(
serialno
,
timeout
=
0.000001
):
with
device_lock
(
serialno
,
timeout
=
0.000001
):
return
False
return
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录