Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
61bd1d3b
Mace
项目概览
毕竟曾有刹那
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
61bd1d3b
编写于
8月 09, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix link for libmace.so and libmodels.a
上级
f291a048
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
49 addition
and
30 deletion
+49
-30
docs/user_guide/advanced_usage.rst
docs/user_guide/advanced_usage.rst
+3
-0
mace/codegen/BUILD
mace/codegen/BUILD
+1
-7
mace/examples/cli/BUILD
mace/examples/cli/BUILD
+1
-1
mace/libmace/mace_version_script.lds
mace/libmace/mace_version_script.lds
+14
-0
mace/tools/validation/BUILD
mace/tools/validation/BUILD
+1
-1
tools/bazel.rc
tools/bazel.rc
+3
-1
tools/build-standalone-lib.sh
tools/build-standalone-lib.sh
+3
-3
tools/converter.py
tools/converter.py
+20
-17
tools/sh_commands.py
tools/sh_commands.py
+3
-0
未找到文件。
docs/user_guide/advanced_usage.rst
浏览文件 @
61bd1d3b
...
@@ -378,6 +378,9 @@ Reduce Library Size
...
@@ -378,6 +378,9 @@ Reduce Library Size
- Futher more, if only ``cpu`` device needed, change ``--define opencl=true`` to ``false``. This way
- Futher more, if only ``cpu`` device needed, change ``--define opencl=true`` to ``false``. This way
will reduce half of library size to about ``700KB`` for ``armeabi-v7a`` and ``1000KB`` for ``arm64-v8a``
will reduce half of library size to about ``700KB`` for ``armeabi-v7a`` and ``1000KB`` for ``arm64-v8a``
- About ``300KB`` can be reduced when add ``--config symbol_hidden`` building option. It will change
the visibility of inner apis of libmace.so and lead to linking error when load model(s) in ``code``.
* **static library**
* **static library**
- The methods in dynamic library can be useful for static library too. In additional, the static
- The methods in dynamic library can be useful for static library too. In additional, the static
...
...
mace/codegen/BUILD
浏览文件 @
61bd1d3b
...
@@ -44,13 +44,7 @@ cc_library(
...
@@ -44,13 +44,7 @@ cc_library(
cc_library
(
cc_library
(
name
=
"generated_libmace"
,
name
=
"generated_libmace"
,
srcs
=
glob
([
"lib/*.so"
]),
srcs
=
glob
([
"lib/*"
]),
visibility
=
[
"//visibility:public"
],
)
cc_library
(
name
=
"generated_libmace_static"
,
srcs
=
glob
([
"lib/*.a"
]),
linkstatic
=
1
,
linkstatic
=
1
,
visibility
=
[
"//visibility:public"
],
visibility
=
[
"//visibility:public"
],
)
)
mace/examples/cli/BUILD
浏览文件 @
61bd1d3b
...
@@ -29,7 +29,7 @@ cc_binary(
...
@@ -29,7 +29,7 @@ cc_binary(
deps
=
[
deps
=
[
"//external:gflags_nothreads"
,
"//external:gflags_nothreads"
,
"//mace/codegen:generated_mace_engine_factory"
,
"//mace/codegen:generated_mace_engine_factory"
,
"//mace/codegen:generated_libmace
_static
"
,
"//mace/codegen:generated_libmace"
,
]
+
if_hexagon_enabled
([
]
+
if_hexagon_enabled
([
"//third_party/nnlib:libhexagon"
,
"//third_party/nnlib:libhexagon"
,
]),
]),
...
...
mace/libmace/mace_version_script.lds
浏览文件 @
61bd1d3b
...
@@ -12,6 +12,20 @@ mace {
...
@@ -12,6 +12,20 @@ mace {
*SetOpenMPThreadAffinity*;
*SetOpenMPThreadAffinity*;
*GetBigLittleCoreIDs*;
*GetBigLittleCoreIDs*;
*MaceVersion*;
*MaceVersion*;
# api for static library of models
*mace*logging*LogMessage*;
*mace*NetDef*;
*mace*MemoryArena*;
*mace*InputInfo*;
*mace*OutputInfo*;
*mace*OutputShape*;
*mace*OperatorDef*;
*mace*ConstTensor*;
*mace*Argument*;
*mace*MemoryBlock*;
*google*protobuf*;
local:
local:
*;
*;
};
};
mace/tools/validation/BUILD
浏览文件 @
61bd1d3b
...
@@ -42,7 +42,7 @@ cc_binary(
...
@@ -42,7 +42,7 @@ cc_binary(
deps
=
[
deps
=
[
"//external:gflags_nothreads"
,
"//external:gflags_nothreads"
,
"//mace/codegen:generated_mace_engine_factory"
,
"//mace/codegen:generated_mace_engine_factory"
,
"//mace/codegen:generated_models"
,
"//mace/libmace:libmace_dynamic"
,
"//mace/libmace:libmace_dynamic"
,
"//mace/utils:utils"
,
],
],
)
)
tools/bazel.rc
浏览文件 @
61bd1d3b
...
@@ -11,6 +11,9 @@ build --copt=-D_GLIBCXX_USE_C99_MATH_TR1
...
@@ -11,6 +11,9 @@ build --copt=-D_GLIBCXX_USE_C99_MATH_TR1
build --copt=-DMACE_OBFUSCATE_LITERALS
build --copt=-DMACE_OBFUSCATE_LITERALS
build --copt=-DGEMMLOWP_USE_OPENMP
build --copt=-DGEMMLOWP_USE_OPENMP
# Usage example: bazel build --config symbol_hidden
build:symbol_hidden --copt=-fvisibility=hidden
# Usage example: bazel build --config android
# Usage example: bazel build --config android
build:android --crosstool_top=//external:android/crosstool
build:android --crosstool_top=//external:android/crosstool
build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
...
@@ -23,7 +26,6 @@ build:optimization --linkopt=-Wl,--strip-all
...
@@ -23,7 +26,6 @@ build:optimization --linkopt=-Wl,--strip-all
build:optimization --copt=-ffunction-sections
build:optimization --copt=-ffunction-sections
build:optimization --copt=-fdata-sections
build:optimization --copt=-fdata-sections
build:optimization --linkopt=-Wl,--gc-sections
build:optimization --linkopt=-Wl,--gc-sections
build:optimization --copt=-fvisibility=hidden
# Address sanitizer
# Address sanitizer
build:asan --strip=never
build:asan --strip=never
...
...
tools/build-standalone-lib.sh
浏览文件 @
61bd1d3b
...
@@ -44,16 +44,16 @@ fi
...
@@ -44,16 +44,16 @@ fi
# build static libraries
# build static libraries
echo
"build static lib for armeabi-v7a + cpu_gpu_dsp"
echo
"build static lib for armeabi-v7a + cpu_gpu_dsp"
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--define
hexagon
=
true
--cpu
=
armeabi-v7a
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--
config
symbol_hidden
--
define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--define
hexagon
=
true
--cpu
=
armeabi-v7a
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/armeabi-v7a/cpu_gpu_dsp/
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/armeabi-v7a/cpu_gpu_dsp/
cp
third_party/nnlib/
*
so
$LIB_DIR
/armeabi-v7a/cpu_gpu_dsp/
cp
third_party/nnlib/
*
so
$LIB_DIR
/armeabi-v7a/cpu_gpu_dsp/
echo
"build static lib for armeabi-v7a + cpu_gpu"
echo
"build static lib for armeabi-v7a + cpu_gpu"
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
armeabi-v7a
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--
config
symbol_hidden
--
define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
armeabi-v7a
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/armeabi-v7a/cpu_gpu/
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/armeabi-v7a/cpu_gpu/
echo
"build static lib for arm64-v8a + cpu_gpu"
echo
"build static lib for arm64-v8a + cpu_gpu"
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
arm64-v8a
bazel build
--config
android
--config
optimization mace/libmace:libmace_static
--
config
symbol_hidden
--
define
neon
=
true
--define
openmp
=
true
--define
opencl
=
true
--cpu
=
arm64-v8a
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/arm64-v8a/cpu_gpu/
cp
bazel-genfiles/mace/libmace/libmace.a
$LIB_DIR
/arm64-v8a/cpu_gpu/
if
[[
"
$OSTYPE
"
!=
"darwin"
*
]]
;
then
if
[[
"
$OSTYPE
"
!=
"darwin"
*
]]
;
then
...
...
tools/converter.py
浏览文件 @
61bd1d3b
...
@@ -786,7 +786,8 @@ def build_model_lib(configs, address_sanitizer):
...
@@ -786,7 +786,8 @@ def build_model_lib(configs, address_sanitizer):
abi
=
target_abi
,
abi
=
target_abi
,
hexagon_mode
=
hexagon_mode
,
hexagon_mode
=
hexagon_mode
,
enable_opencl
=
get_opencl_mode
(
configs
),
enable_opencl
=
get_opencl_mode
(
configs
),
address_sanitizer
=
address_sanitizer
address_sanitizer
=
address_sanitizer
,
symbol_hidden
=
True
)
)
sh
.
cp
(
"-f"
,
MODEL_LIB_PATH
,
model_lib_output_path
)
sh
.
cp
(
"-f"
,
MODEL_LIB_PATH
,
model_lib_output_path
)
...
@@ -880,8 +881,10 @@ def build_mace_run(configs, target_abi, enable_openmp, address_sanitizer,
...
@@ -880,8 +881,10 @@ def build_mace_run(configs, target_abi, enable_openmp, address_sanitizer,
sh
.
rm
(
"-rf"
,
build_tmp_binary_dir
)
sh
.
rm
(
"-rf"
,
build_tmp_binary_dir
)
os
.
makedirs
(
build_tmp_binary_dir
)
os
.
makedirs
(
build_tmp_binary_dir
)
symbol_hidden
=
True
mace_run_target
=
MACE_RUN_STATIC_TARGET
mace_run_target
=
MACE_RUN_STATIC_TARGET
if
mace_lib_type
==
MACELibType
.
dynamic
:
if
mace_lib_type
==
MACELibType
.
dynamic
:
symbol_hidden
=
False
mace_run_target
=
MACE_RUN_DYNAMIC_TARGET
mace_run_target
=
MACE_RUN_DYNAMIC_TARGET
build_arg
=
""
build_arg
=
""
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
...
@@ -897,6 +900,7 @@ def build_mace_run(configs, target_abi, enable_openmp, address_sanitizer,
...
@@ -897,6 +900,7 @@ def build_mace_run(configs, target_abi, enable_openmp, address_sanitizer,
enable_openmp
=
enable_openmp
,
enable_openmp
=
enable_openmp
,
enable_opencl
=
get_opencl_mode
(
configs
),
enable_opencl
=
get_opencl_mode
(
configs
),
address_sanitizer
=
address_sanitizer
,
address_sanitizer
=
address_sanitizer
,
symbol_hidden
=
symbol_hidden
,
extra_args
=
build_arg
extra_args
=
build_arg
)
)
sh_commands
.
update_mace_run_binary
(
build_tmp_binary_dir
,
sh_commands
.
update_mace_run_binary
(
build_tmp_binary_dir
,
...
@@ -924,6 +928,7 @@ def build_quantize_stat(configs):
...
@@ -924,6 +928,7 @@ def build_quantize_stat(configs):
quantize_stat_target
,
quantize_stat_target
,
abi
=
ABIType
.
host
,
abi
=
ABIType
.
host
,
enable_openmp
=
True
,
enable_openmp
=
True
,
symbol_hidden
=
True
,
extra_args
=
build_arg
extra_args
=
build_arg
)
)
...
@@ -943,36 +948,39 @@ def build_example(configs, target_abi, enable_openmp, mace_lib_type):
...
@@ -943,36 +948,39 @@ def build_example(configs, target_abi, enable_openmp, mace_lib_type):
sh
.
rm
(
"-rf"
,
build_tmp_binary_dir
)
sh
.
rm
(
"-rf"
,
build_tmp_binary_dir
)
os
.
makedirs
(
build_tmp_binary_dir
)
os
.
makedirs
(
build_tmp_binary_dir
)
symbol_hidden
=
True
libmace_target
=
LIBMACE_STATIC_TARGET
libmace_target
=
LIBMACE_STATIC_TARGET
if
mace_lib_type
==
MACELibType
.
dynamic
:
if
mace_lib_type
==
MACELibType
.
dynamic
:
symbol_hidden
=
False
libmace_target
=
LIBMACE_SO_TARGET
libmace_target
=
LIBMACE_SO_TARGET
sh_commands
.
bazel_build
(
libmace_target
,
sh_commands
.
bazel_build
(
libmace_target
,
abi
=
target_abi
,
abi
=
target_abi
,
enable_openmp
=
enable_openmp
,
enable_openmp
=
enable_openmp
,
enable_opencl
=
get_opencl_mode
(
configs
),
enable_opencl
=
get_opencl_mode
(
configs
),
hexagon_mode
=
hexagon_mode
)
hexagon_mode
=
hexagon_mode
,
symbol_hidden
=
symbol_hidden
)
if
os
.
path
.
exists
(
LIB_CODEGEN_DIR
):
if
os
.
path
.
exists
(
LIB_CODEGEN_DIR
):
sh
.
rm
(
"-rf"
,
LIB_CODEGEN_DIR
)
sh
.
rm
(
"-rf"
,
LIB_CODEGEN_DIR
)
sh
.
mkdir
(
"-p"
,
LIB_CODEGEN_DIR
)
sh
.
mkdir
(
"-p"
,
LIB_CODEGEN_DIR
)
build_arg
=
""
build_arg
=
""
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
mace_check
(
os
.
path
.
exists
(
ENGINE_CODEGEN_DIR
),
ModuleName
.
RUN
,
"You should convert model first."
)
model_lib_path
=
get_model_lib_output_path
(
library_name
,
target_abi
)
sh
.
cp
(
"-f"
,
model_lib_path
,
LIB_CODEGEN_DIR
)
build_arg
=
"--per_file_copt=mace/examples/cli/example.cc@-DMODEL_GRAPH_FORMAT_CODE"
# noqa
if
mace_lib_type
==
MACELibType
.
dynamic
:
if
mace_lib_type
==
MACELibType
.
dynamic
:
example_target
=
EXAMPLE_DYNAMIC_TARGET
example_target
=
EXAMPLE_DYNAMIC_TARGET
sh
.
cp
(
"-f"
,
LIBMACE_DYNAMIC_PATH
,
LIB_CODEGEN_DIR
)
sh
.
cp
(
"-f"
,
LIBMACE_DYNAMIC_PATH
,
LIB_CODEGEN_DIR
)
else
:
else
:
sh
.
cp
(
"-f"
,
LIBMACE_STATIC_PATH
,
LIB_CODEGEN_DIR
)
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
mace_check
(
os
.
path
.
exists
(
ENGINE_CODEGEN_DIR
),
ModuleName
.
RUN
,
"You should convert model first."
)
model_lib_path
=
get_model_lib_output_path
(
library_name
,
target_abi
)
sh
.
cp
(
"-f"
,
model_lib_path
,
LIB_CODEGEN_DIR
)
build_arg
=
"--per_file_copt=mace/examples/cli/example.cc@-DMODEL_GRAPH_FORMAT_CODE"
# noqa
example_target
=
EXAMPLE_STATIC_TARGET
example_target
=
EXAMPLE_STATIC_TARGET
sh
.
cp
(
"-f"
,
LIBMACE_STATIC_PATH
,
LIB_CODEGEN_DIR
)
sh_commands
.
bazel_build
(
example_target
,
sh_commands
.
bazel_build
(
example_target
,
abi
=
target_abi
,
abi
=
target_abi
,
...
@@ -1325,11 +1333,6 @@ def print_package_summary(package_path):
...
@@ -1325,11 +1333,6 @@ def print_package_summary(package_path):
def
run_mace
(
flags
):
def
run_mace
(
flags
):
configs
=
format_model_config
(
flags
)
configs
=
format_model_config
(
flags
)
if
flags
.
mace_lib_type
==
MACELibType
.
dynamic
and
\
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
MaceLogger
.
error
(
ModuleName
.
YAML_CONFIG
,
"If you want to link MACE dynamic library, "
"you must use file-type MACE model."
)
clear_build_dirs
(
configs
[
YAMLKeyword
.
library_name
])
clear_build_dirs
(
configs
[
YAMLKeyword
.
library_name
])
...
...
tools/sh_commands.py
浏览文件 @
61bd1d3b
...
@@ -279,6 +279,7 @@ def bazel_build(target,
...
@@ -279,6 +279,7 @@ def bazel_build(target,
enable_neon
=
True
,
enable_neon
=
True
,
enable_opencl
=
True
,
enable_opencl
=
True
,
address_sanitizer
=
False
,
address_sanitizer
=
False
,
symbol_hidden
=
False
,
extra_args
=
""
):
extra_args
=
""
):
print
(
"* Build %s with ABI %s"
%
(
target
,
abi
))
print
(
"* Build %s with ABI %s"
%
(
target
,
abi
))
if
abi
==
"host"
:
if
abi
==
"host"
:
...
@@ -307,6 +308,8 @@ def bazel_build(target,
...
@@ -307,6 +308,8 @@ def bazel_build(target,
bazel_args
+=
(
"--config"
,
"asan"
)
bazel_args
+=
(
"--config"
,
"asan"
)
else
:
else
:
bazel_args
+=
(
"--config"
,
"optimization"
)
bazel_args
+=
(
"--config"
,
"optimization"
)
if
symbol_hidden
:
bazel_args
+=
(
"--config"
,
"symbol_hidden"
)
if
extra_args
:
if
extra_args
:
bazel_args
+=
(
extra_args
,
)
bazel_args
+=
(
extra_args
,
)
print
bazel_args
print
bazel_args
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录