Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
c22dee0a
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,发现更多精彩内容 >>
提交
c22dee0a
编写于
12月 19, 2018
作者:
L
liutuo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix leakyrelu
上级
5d980e20
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
15 addition
and
8 deletion
+15
-8
mace/ops/activation.h
mace/ops/activation.h
+2
-2
mace/ops/arm/activation_neon.cc
mace/ops/arm/activation_neon.cc
+5
-3
mace/python/tools/converter_tool/onnx_converter.py
mace/python/tools/converter_tool/onnx_converter.py
+8
-3
未找到文件。
mace/ops/activation.h
浏览文件 @
c22dee0a
...
...
@@ -96,8 +96,8 @@ void DoActivation(const T *input_ptr,
case
LEAKYRELU
:
#pragma omp parallel for schedule(runtime)
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
output_ptr
[
i
]
=
std
::
max
(
input_ptr
[
i
],
static_cast
<
T
>
(
0
))
*
relux_max_limit
;
output_ptr
[
i
]
=
std
::
max
(
input_ptr
[
i
],
static_cast
<
T
>
(
0
))
+
std
::
min
(
input_ptr
[
i
],
static_cast
<
T
>
(
0
))
*
relux_max_limit
;
}
break
;
default:
...
...
mace/ops/arm/activation_neon.cc
浏览文件 @
c22dee0a
...
...
@@ -75,18 +75,20 @@ void LeakyReluNeon(const float *input, const float alpha,
#pragma omp parallel for schedule(runtime)
for
(
index_t
i
=
0
;
i
<=
size
-
4
;
i
+=
4
)
{
float32x4_t
v
=
vld1q_f32
(
input
+
i
);
float32x4_t
u
=
vminq_f32
(
v
,
vzero
);;
v
=
vmaxq_f32
(
v
,
vzero
);
v
=
vmulq_f32
(
v
,
valpha
);
v
=
vmlaq_f32
(
v
,
valpha
,
u
);
vst1q_f32
(
output
+
i
,
v
);
}
// remain
for
(
index_t
i
=
(
size
>>
2
)
<<
2
;
i
<
size
;
++
i
)
{
output
[
i
]
=
std
::
max
(
input
[
i
],
0.
f
)
*
alpha
;
output
[
i
]
=
std
::
max
(
input
[
i
],
0.
f
)
+
std
::
min
(
input
[
i
],
0.
f
)
*
alpha
;
}
#else
#pragma omp parallel for schedule(runtime)
for
(
index_t
i
=
0
;
i
<
size
;
++
i
)
{
output
[
i
]
=
std
::
max
(
input
[
i
],
0.
f
)
*
alpha
;
output
[
i
]
=
std
::
max
(
input
[
i
],
0.
f
)
+
std
::
min
(
input
[
i
],
0.
f
)
*
alpha
;
}
#endif
}
...
...
mace/python/tools/converter_tool/onnx_converter.py
浏览文件 @
c22dee0a
...
...
@@ -309,7 +309,7 @@ class OnnxConverter(base_converter.ConverterInterface):
OnnxOpType
.
Div
.
name
:
self
.
convert_eltwise
,
OnnxOpType
.
Equal
.
name
:
self
.
convert_eltwise
,
OnnxOpType
.
Gather
.
name
:
self
.
convert_gather
,
OnnxOpType
.
Gemm
.
name
:
self
.
convert_
fully_connected
,
OnnxOpType
.
Gemm
.
name
:
self
.
convert_
gemm
,
OnnxOpType
.
GlobalAveragePool
.
name
:
self
.
convert_reduce
,
OnnxOpType
.
GlobalMaxPool
.
name
:
self
.
convert_reduce
,
OnnxOpType
.
Identity
.
name
:
self
.
convert_identity
,
...
...
@@ -415,6 +415,7 @@ class OnnxConverter(base_converter.ConverterInterface):
kernels_arg
.
name
=
MaceKeyword
.
mace_kernel_str
kernels_arg
.
ints
.
extend
(
kernel
)
# TODO: Does not support AutoPad yet.
if
'pads'
in
attrs
:
pads
=
attrs
[
'pads'
]
if
len
(
pads
)
==
4
:
...
...
@@ -587,6 +588,9 @@ class OnnxConverter(base_converter.ConverterInterface):
if
"alpha"
in
node
.
attrs
:
alpha_value
=
node
.
attrs
[
"alpha"
]
else
:
if
node
.
op_type
==
OnnxOpType
.
LeakyRelu
.
name
:
alpha_value
=
0.01
else
:
alpha_value
=
0
alpha_arg
=
op
.
arg
.
add
()
...
...
@@ -894,7 +898,8 @@ class OnnxConverter(base_converter.ConverterInterface):
tensor
.
float_data
[:]
=
tensor_data
.
flat
tensor
.
dims
[:]
=
tensor_data
.
shape
def
convert_fully_connected
(
self
,
node
):
def
convert_gemm
(
self
,
node
):
# only supports FullyConnected Style Gemm for now.
trans_a
=
node
.
attrs
[
'transA'
]
if
'transA'
in
node
.
attrs
else
0
trans_b
=
node
.
attrs
[
'transB'
]
if
'transB'
in
node
.
attrs
else
0
shape_a
=
self
.
_graph_shapes_dict
[
node
.
inputs
[
0
]]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录