Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
747a9e2a
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,发现更多精彩内容 >>
提交
747a9e2a
编写于
2月 12, 2018
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize activation and fix export lib scripts
上级
dd501eea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
10 deletion
+17
-10
mace/kernels/activation.h
mace/kernels/activation.h
+5
-0
tools/export_lib.sh
tools/export_lib.sh
+12
-10
未找到文件。
mace/kernels/activation.h
浏览文件 @
747a9e2a
...
...
@@ -54,17 +54,20 @@ void DoActivation(const T *input_ptr,
case
NOOP
:
break
;
case
RELU
:
#pragma omp parallel for
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
output_ptr
[
i
]
=
std
::
max
(
input_ptr
[
i
],
static_cast
<
T
>
(
0
));
}
break
;
case
RELUX
:
#pragma omp parallel for
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
output_ptr
[
i
]
=
std
::
min
(
std
::
max
(
input_ptr
[
i
],
static_cast
<
T
>
(
0
)),
static_cast
<
T
>
(
relux_max_limit
));
}
break
;
case
PRELU
:
#pragma omp parallel for
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
T
in
=
input_ptr
[
i
];
if
(
in
<
0
)
{
...
...
@@ -75,12 +78,14 @@ void DoActivation(const T *input_ptr,
}
break
;
case
TANH
:
#pragma omp parallel for
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
T
in_exp
=
std
::
exp
(
-
2
*
input_ptr
[
i
]);
output_ptr
[
i
]
=
(
1
-
in_exp
)
/
(
1
+
in_exp
);
}
break
;
case
SIGMOID
:
#pragma omp parallel for
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
output_ptr
[
i
]
=
1
/
(
1
+
std
::
exp
(
-
input_ptr
[
i
]));
}
...
...
tools/export_lib.sh
浏览文件 @
747a9e2a
...
...
@@ -3,8 +3,8 @@
set
-e
Usage
()
{
echo
"Usage: ./tools/export_lib.sh
android_abi[armeabi-v7a/arm64-v8a] runtime[gpu/
dsp] export_include_dir export_lib_dir"
echo
"eg: ./tools/export_lib.sh armeabi-v7a ../include ../lib/libmace_v7"
echo
"Usage: ./tools/export_lib.sh
target_abi[armeabi-v7a | arm64-v8a | host] runtime[gpu |
dsp] export_include_dir export_lib_dir"
echo
"eg: ./tools/export_lib.sh armeabi-v7a
gpu
../include ../lib/libmace_v7"
}
if
[
$#
-lt
4
]
;
then
...
...
@@ -12,9 +12,7 @@ if [ $# -lt 4 ]; then
exit
1
fi
# ANDROID_ABI=arm64-v8a
# ANDROID_ABI=armeabi-v7a
ANDROID_ABI
=
$1
TARGET_ABI
=
$1
RUNTIME
=
$2
EXPORT_INCLUDE_DIR
=
$3
EXPORT_LIB_DIR
=
$4
...
...
@@ -63,15 +61,18 @@ build_target()
bazel build
--verbose_failures
-c
opt
--strip
always
$BAZEL_TARGET
\
--crosstool_top
=
//external:android/crosstool
\
--host_crosstool_top
=
@bazel_tools//tools/cpp:toolchain
\
--cpu
=
$
ANDROID
_ABI
\
--cpu
=
$
TARGET
_ABI
\
--copt
=
"-std=c++11"
\
--copt
=
"-D_GLIBCXX_USE_C99_MATH_TR1"
\
--copt
=
"-Werror=return-type"
\
--copt
=
"-DMACE_OBFUSCATE_LITERALS"
\
--copt
=
"-O3"
\
--define
neon
=
true
\
--define
openmp
=
true
\
$DSP_MODE_BUILD_FLAGS
||
exit
1
}
build_
local
_target
()
build_
host
_target
()
{
BAZEL_TARGET
=
$1
bazel build
--verbose_failures
-c
opt
--strip
always
$BAZEL_TARGET
\
...
...
@@ -79,7 +80,8 @@ build_local_target()
--copt
=
"-D_GLIBCXX_USE_C99_MATH_TR1"
\
--copt
=
"-Werror=return-type"
\
--copt
=
"-DMACE_OBFUSCATE_LITERALS"
\
--define
openmp
=
true
||
exit
-1
--copt
=
"-O3"
\
--define
openmp
=
true
||
exit
1
}
merge_libs
()
...
...
@@ -132,10 +134,10 @@ bash mace/tools/git/gen_version_source.sh ${CODEGEN_DIR}/version/version.cc || e
echo
"Step 3: Build libmace targets"
bazel clean
if
[
x
"
${
RUNTIME
}
"
=
x
"local"
]
;
then
if
[
x
"
${
TARGET_ABI
}
"
=
x
"host"
]
||
[
x
"
${
TARGET_ABI
}
"
=
x
"local"
]
;
then
for
target
in
${
all_targets
[*]
}
do
build_
local
_target
${
target
}
build_
host
_target
${
target
}
done
else
for
target
in
${
all_targets
[*]
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录