Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
310b1dbd
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看板
提交
310b1dbd
编写于
12月 30, 2018
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize pooling which efficiency has increased by 30% for googlenet, Fix pooling3x3 for stride 2
上级
2e0735e6
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
726 addition
and
403 deletion
+726
-403
src/operators/kernel/central-arm-func/elementwise_add_arm_func.h
...rators/kernel/central-arm-func/elementwise_add_arm_func.h
+1
-1
src/operators/math/pooling.h
src/operators/math/pooling.h
+45
-1
src/operators/math/pooling2x2.cpp
src/operators/math/pooling2x2.cpp
+2
-2
src/operators/math/pooling3x3.cpp
src/operators/math/pooling3x3.cpp
+627
-348
test/operators/test_pool_op.cpp
test/operators/test_pool_op.cpp
+51
-51
未找到文件。
src/operators/kernel/central-arm-func/elementwise_add_arm_func.h
浏览文件 @
310b1dbd
...
@@ -110,7 +110,7 @@ inline void ElementwiseAddCompute(const ElementwiseAddParam<CPU> ¶m) {
...
@@ -110,7 +110,7 @@ inline void ElementwiseAddCompute(const ElementwiseAddParam<CPU> ¶m) {
break
;
break
;
case
3
:
case
3
:
vst1_f32
(
output
,
vget_low_f32
(
r0
));
vst1_f32
(
output
,
vget_low_f32
(
r0
));
vst1
_lane_f32
(
output
,
vget_high_f32
(
r0
),
0
);
vst1
q_lane_f32
(
output
,
r0
,
2
);
break
;
break
;
}
}
}
}
...
...
src/operators/math/pooling.h
浏览文件 @
310b1dbd
...
@@ -53,7 +53,7 @@ struct PoolingVal<AVG> {
...
@@ -53,7 +53,7 @@ struct PoolingVal<AVG> {
++
count
;
++
count
;
return
*
this
;
return
*
this
;
}
}
inline
float
Value
()
{
return
(
count
>
0
)
?
val
/
count
:
0.
f
;
}
inline
float
Value
()
{
return
(
count
>
0
)
?
val
*
(
1.
f
/
count
)
:
0.
f
;
}
};
};
#if defined(__ARM_NEON) || defined(__ARM_NEON__)
#if defined(__ARM_NEON) || defined(__ARM_NEON__)
...
@@ -67,6 +67,16 @@ inline float32x4_t vPoolInitq_f32<AVG>() {
...
@@ -67,6 +67,16 @@ inline float32x4_t vPoolInitq_f32<AVG>() {
return
vdupq_n_f32
(
0.
f
);
return
vdupq_n_f32
(
0.
f
);
}
}
template
<
PoolingType
P
=
MAX
>
inline
float32x2_t
vPoolInit_f32
()
{
return
vdup_n_f32
(
-
std
::
numeric_limits
<
float
>::
max
());
}
template
<
>
inline
float32x2_t
vPoolInit_f32
<
AVG
>
()
{
return
vdup_n_f32
(
0.
f
);
}
template
<
PoolingType
P
=
MAX
>
template
<
PoolingType
P
=
MAX
>
inline
float32x4_t
vPoolPreq_f32
(
const
float32x4_t
&
x1
,
const
float32x4_t
&
x2
)
{
inline
float32x4_t
vPoolPreq_f32
(
const
float32x4_t
&
x1
,
const
float32x4_t
&
x2
)
{
return
vmaxq_f32
(
x1
,
x2
);
return
vmaxq_f32
(
x1
,
x2
);
...
@@ -78,6 +88,28 @@ inline float32x4_t vPoolPreq_f32<AVG>(const float32x4_t &x1,
...
@@ -78,6 +88,28 @@ inline float32x4_t vPoolPreq_f32<AVG>(const float32x4_t &x1,
return
vaddq_f32
(
x1
,
x2
);
return
vaddq_f32
(
x1
,
x2
);
}
}
template
<
PoolingType
P
=
MAX
>
inline
float32x2_t
vPoolPre_f32
(
const
float32x2_t
&
x1
,
const
float32x2_t
&
x2
)
{
return
vmax_f32
(
x1
,
x2
);
}
template
<
>
inline
float32x2_t
vPoolPre_f32
<
AVG
>
(
const
float32x2_t
&
x1
,
const
float32x2_t
&
x2
)
{
return
vadd_f32
(
x1
,
x2
);
}
template
<
PoolingType
P
=
MAX
>
inline
float32x2_t
vpPoolPre_f32
(
const
float32x2_t
&
x1
,
const
float32x2_t
&
x2
)
{
return
vpmax_f32
(
x1
,
x2
);
}
template
<
>
inline
float32x2_t
vpPoolPre_f32
<
AVG
>
(
const
float32x2_t
&
x1
,
const
float32x2_t
&
x2
)
{
return
vpadd_f32
(
x1
,
x2
);
}
template
<
PoolingType
P
=
MAX
>
template
<
PoolingType
P
=
MAX
>
inline
float32x4_t
vPoolPostq_f32
(
const
float32x4_t
&
x
,
inline
float32x4_t
vPoolPostq_f32
(
const
float32x4_t
&
x
,
const
float32x4_t
&
post
)
{
const
float32x4_t
&
post
)
{
...
@@ -89,6 +121,18 @@ inline float32x4_t vPoolPostq_f32<AVG>(const float32x4_t &x,
...
@@ -89,6 +121,18 @@ inline float32x4_t vPoolPostq_f32<AVG>(const float32x4_t &x,
const
float32x4_t
&
post
)
{
const
float32x4_t
&
post
)
{
return
vmulq_f32
(
x
,
post
);
return
vmulq_f32
(
x
,
post
);
}
}
template
<
PoolingType
P
=
MAX
>
inline
float32x2_t
vPoolPost_f32
(
const
float32x2_t
&
x
,
const
float32x2_t
&
post
)
{
return
x
;
}
template
<
>
inline
float32x2_t
vPoolPost_f32
<
AVG
>
(
const
float32x2_t
&
x
,
const
float32x2_t
&
post
)
{
return
vmul_f32
(
x
,
post
);
}
#endif // __ARM_NEON__
#endif // __ARM_NEON__
template
<
PoolingType
P
=
MAX
>
template
<
PoolingType
P
=
MAX
>
...
...
src/operators/math/pooling2x2.cpp
浏览文件 @
310b1dbd
...
@@ -40,7 +40,7 @@ namespace math {
...
@@ -40,7 +40,7 @@ namespace math {
template
<
PoolingType
P
,
int
Stride
=
1
>
template
<
PoolingType
P
,
int
Stride
=
1
>
struct
Pooling2x2NormalRowLoadInput
{
struct
Pooling2x2NormalRowLoadInput
{
inline
void
operator
()(
const
float
*
input
,
float32x4_t
*
x0
,
float32x4_t
*
x1
)
{
void
operator
()(
const
float
*
input
,
float32x4_t
*
x0
,
float32x4_t
*
x1
)
{
x0
[
0
]
=
vld1q_f32
(
input
);
x0
[
0
]
=
vld1q_f32
(
input
);
x0
[
1
]
=
vld1q_f32
(
input
+
4
);
x0
[
1
]
=
vld1q_f32
(
input
+
4
);
x1
[
0
]
=
vextq_f32
(
x0
[
0
],
x0
[
1
],
1
);
x1
[
0
]
=
vextq_f32
(
x0
[
0
],
x0
[
1
],
1
);
...
@@ -50,7 +50,7 @@ struct Pooling2x2NormalRowLoadInput {
...
@@ -50,7 +50,7 @@ struct Pooling2x2NormalRowLoadInput {
template
<
PoolingType
P
>
template
<
PoolingType
P
>
struct
Pooling2x2NormalRowLoadInput
<
P
,
2
>
{
struct
Pooling2x2NormalRowLoadInput
<
P
,
2
>
{
inline
void
operator
()(
const
float
*
input
,
float32x4_t
*
x0
,
float32x4_t
*
x1
)
{
void
operator
()(
const
float
*
input
,
float32x4_t
*
x0
,
float32x4_t
*
x1
)
{
float32x4x2_t
t0
=
vld2q_f32
(
input
);
float32x4x2_t
t0
=
vld2q_f32
(
input
);
float32x4x2_t
t1
=
vld2q_f32
(
input
+
8
);
float32x4x2_t
t1
=
vld2q_f32
(
input
+
8
);
x0
[
0
]
=
t0
.
val
[
0
];
x0
[
0
]
=
t0
.
val
[
0
];
...
...
src/operators/math/pooling3x3.cpp
浏览文件 @
310b1dbd
此差异已折叠。
点击以展开。
test/operators/test_pool_op.cpp
浏览文件 @
310b1dbd
...
@@ -169,55 +169,55 @@ int main(int argc, char *argv[]) {
...
@@ -169,55 +169,55 @@ int main(int argc, char *argv[]) {
<<
"float, pooling_type=avg, kernel=3, pad=5, stride=2"
;
<<
"float, pooling_type=avg, kernel=3, pad=5, stride=2"
;
paddle_mobile
::
TestPoolOp
<
1
,
3
,
5
,
2
>
(
in_channels
,
in_height
,
in_width
);
paddle_mobile
::
TestPoolOp
<
1
,
3
,
5
,
2
>
(
in_channels
,
in_height
,
in_width
);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=0, stride=1"
;
//
<< "float, pooling_type=max, kernel=2, pad=0, stride=1";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
0
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 0, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=1, stride=1"
;
//
<< "float, pooling_type=max, kernel=2, pad=1, stride=1";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
1
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 1, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=2, stride=1"
;
//
<< "float, pooling_type=max, kernel=2, pad=2, stride=1";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
2
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 2, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=5, stride=1"
;
//
<< "float, pooling_type=max, kernel=2, pad=5, stride=1";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
5
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 5, 1>(in_channels, in_height, in_width);
//
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=0, stride=1"
;
//
<< "float, pooling_type=avg, kernel=2, pad=0, stride=1";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
0
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 0, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=1, stride=1"
;
//
<< "float, pooling_type=avg, kernel=2, pad=1, stride=1";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
1
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 1, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=2, stride=1"
;
//
<< "float, pooling_type=avg, kernel=2, pad=2, stride=1";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
2
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 2, 1>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=5, stride=1"
;
//
<< "float, pooling_type=avg, kernel=2, pad=5, stride=1";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
5
,
1
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 5, 1>(in_channels, in_height, in_width);
//
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=0, stride=2"
;
//
<< "float, pooling_type=max, kernel=2, pad=0, stride=2";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
0
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 0, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=1, stride=2"
;
//
<< "float, pooling_type=max, kernel=2, pad=1, stride=2";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
1
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 1, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=2, stride=2"
;
//
<< "float, pooling_type=max, kernel=2, pad=2, stride=2";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
2
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 2, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=max, kernel=2, pad=5, stride=2"
;
//
<< "float, pooling_type=max, kernel=2, pad=5, stride=2";
paddle_mobile
::
TestPoolOp
<
0
,
2
,
5
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<0, 2, 5, 2>(in_channels, in_height, in_width);
//
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=0, stride=2"
;
//
<< "float, pooling_type=avg, kernel=2, pad=0, stride=2";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
0
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 0, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=1, stride=2"
;
//
<< "float, pooling_type=avg, kernel=2, pad=1, stride=2";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
1
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 1, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=2, stride=2"
;
//
<< "float, pooling_type=avg, kernel=2, pad=2, stride=2";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
2
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 2, 2>(in_channels, in_height, in_width);
LOG
(
paddle_mobile
::
kLOG_INFO
)
//
LOG(paddle_mobile::kLOG_INFO)
<<
"float, pooling_type=avg, kernel=2, pad=5, stride=2"
;
//
<< "float, pooling_type=avg, kernel=2, pad=5, stride=2";
paddle_mobile
::
TestPoolOp
<
1
,
2
,
5
,
2
>
(
in_channels
,
in_height
,
in_width
);
//
paddle_mobile::TestPoolOp<1, 2, 5, 2>(in_channels, in_height, in_width);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录