Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0ff7c56a
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0ff7c56a
编写于
6月 19, 2018
作者:
R
Ruilong Liu
提交者:
GitHub
6月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #434 from cocodark/develop
optimize conv-add kernel with neon intrinsics
上级
dacb2938
b784d7f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
21 deletion
+51
-21
src/operators/kernel/arm/conv_add_kernel.cpp
src/operators/kernel/arm/conv_add_kernel.cpp
+0
-21
src/operators/kernel/conv_add_kernel.h
src/operators/kernel/conv_add_kernel.h
+51
-0
未找到文件。
src/operators/kernel/arm/conv_add_kernel.cpp
浏览文件 @
0ff7c56a
...
...
@@ -18,27 +18,6 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
void
expand_bias
(
Tensor
&
bias
,
int
axis
,
const
DDim
&
dDim
)
{
auto
bias_ptr
=
bias
.
data
<
float
>
();
const
DDim
bias_ddim
=
bias
.
dims
();
PADDLE_MOBILE_ENFORCE
(
bias
.
dims
().
size
()
==
1
,
"the bias tensor's dims size != 1"
)
DDim
outer_ddim
=
paddle_mobile
::
framework
::
slice_ddim
(
dDim
,
0
,
axis
+
1
);
DDim
inner_ddim
=
paddle_mobile
::
framework
::
slice_ddim
(
dDim
,
axis
+
1
,
dDim
.
size
());
int
outer_size
=
paddle_mobile
::
framework
::
product
(
outer_ddim
);
int
inner_size
=
paddle_mobile
::
framework
::
product
(
inner_ddim
);
bias
.
Resize
(
dDim
);
auto
new_ptr
=
bias
.
mutable_data
<
float
>
();
int
axis_size
=
dDim
[
axis
];
for
(
int
i
=
0
;
i
<
outer_size
;
++
i
)
{
float
v_bias
=
bias_ptr
[
i
*
axis_size
/
outer_size
];
for
(
int
j
=
0
;
j
<
inner_size
;
++
j
)
{
new_ptr
[
i
*
inner_size
+
j
]
=
v_bias
;
}
}
}
template
<
>
void
ConvAddKernel
<
CPU
,
float
>::
Compute
(
const
FushionConvAddParam
&
param
)
const
{
...
...
src/operators/kernel/conv_add_kernel.h
浏览文件 @
0ff7c56a
...
...
@@ -17,6 +17,9 @@ limitations under the License. */
#pragma once
#include <vector>
#if __ARM_NEON
#include <arm_neon.h>
#endif
#include "framework/ddim.h"
#include "framework/operator.h"
#include "operators/math/im2col.h"
...
...
@@ -36,6 +39,54 @@ class ConvAddKernel : public OpKernelBase<DeviceType, FushionConvAddParam> {
void
Compute
(
const
FushionConvAddParam
&
param
)
const
;
};
inline
void
expand_bias
(
Tensor
&
bias
,
int
axis
,
const
DDim
&
dDim
)
{
auto
bias_ptr
=
bias
.
data
<
float
>
();
const
DDim
bias_ddim
=
bias
.
dims
();
PADDLE_MOBILE_ENFORCE
(
bias
.
dims
().
size
()
==
1
,
"the bias tensor's dims size != 1"
)
DDim
outer_ddim
=
paddle_mobile
::
framework
::
slice_ddim
(
dDim
,
0
,
axis
+
1
);
DDim
inner_ddim
=
paddle_mobile
::
framework
::
slice_ddim
(
dDim
,
axis
+
1
,
dDim
.
size
());
int
outer_size
=
paddle_mobile
::
framework
::
product
(
outer_ddim
);
int
inner_size
=
paddle_mobile
::
framework
::
product
(
inner_ddim
);
bias
.
Resize
(
dDim
);
auto
new_ptr
=
bias
.
mutable_data
<
float
>
();
int
axis_size
=
dDim
[
axis
];
#if __ARM_NEON
for
(
int
i
=
0
;
i
<
outer_size
;
++
i
)
{
int
inner_num
=
inner_size
>>
4
;
int
remain
=
inner_size
-
(
inner_num
<<
4
);
float
v_bias
=
bias_ptr
[
i
*
axis_size
/
outer_size
];
for
(;
inner_num
>
0
;
inner_num
--
)
{
float32x4_t
v_newptr1
=
vdupq_n_f32
(
v_bias
);
float32x4_t
v_newptr2
=
vdupq_n_f32
(
v_bias
);
float32x4_t
v_newptr3
=
vdupq_n_f32
(
v_bias
);
float32x4_t
v_newptr4
=
vdupq_n_f32
(
v_bias
);
vst1q_f32
(
new_ptr
,
v_newptr1
);
new_ptr
+=
4
;
vst1q_f32
(
new_ptr
,
v_newptr2
);
new_ptr
+=
4
;
vst1q_f32
(
new_ptr
,
v_newptr3
);
new_ptr
+=
4
;
vst1q_f32
(
new_ptr
,
v_newptr4
);
new_ptr
+=
4
;
}
for
(;
remain
>
0
;
remain
--
)
{
*
new_ptr
=
v_bias
;
new_ptr
++
;
}
}
#else
for
(
int
i
=
0
;
i
<
outer_size
;
++
i
)
{
float
v_bias
=
bias_ptr
[
i
*
axis_size
/
outer_size
];
for
(
int
j
=
0
;
j
<
inner_size
;
++
j
)
{
new_ptr
[
i
*
inner_size
+
j
]
=
v_bias
;
}
}
#endif
}
inline
bool
IsExpand
(
const
std
::
vector
<
int64_t
>
&
filter_dim
,
const
std
::
vector
<
int
>
&
strides
,
const
std
::
vector
<
int
>
&
paddings
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录