Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
3047c4b4
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看板
提交
3047c4b4
编写于
12月 16, 2018
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace omp statement to optimize elementwise add while batch size > 1
上级
33e1e2dd
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
22 addition
and
26 deletion
+22
-26
src/common/enforce.h
src/common/enforce.h
+6
-1
src/operators/gru_op.cpp
src/operators/gru_op.cpp
+0
-1
src/operators/kernel/arm/cast_kernel.cpp
src/operators/kernel/arm/cast_kernel.cpp
+0
-1
src/operators/kernel/central-arm-func/elementwise_add_arm_func.h
...rators/kernel/central-arm-func/elementwise_add_arm_func.h
+14
-21
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+2
-2
未找到文件。
src/common/enforce.h
浏览文件 @
3047c4b4
...
...
@@ -63,7 +63,12 @@ struct PaddleMobileException : public std::exception {
#else
#define PADDLE_MOBILE_THROW_EXCEPTION(...)
#define PADDLE_MOBILE_ENFORCE(stat, ...)
#define PADDLE_MOBILE_ENFORCE(stat, ...) \
{ \
if (stat) { \
} else { \
} \
}
#endif
...
...
src/operators/gru_op.cpp
浏览文件 @
3047c4b4
...
...
@@ -15,7 +15,6 @@ limitations under the License. */
#ifdef GRU_OP
#include "operators/gru_op.h"
#include <iostream>
#include <vector>
#include "common/enforce.h"
...
...
src/operators/kernel/arm/cast_kernel.cpp
浏览文件 @
3047c4b4
...
...
@@ -15,7 +15,6 @@ limitations under the License. */
#ifdef CAST_OP
#include <algorithm>
#include <iostream>
#include <vector>
#include "framework/data_type.h"
#include "operators/kernel/kernels.h"
...
...
src/operators/kernel/central-arm-func/elementwise_add_arm_func.h
浏览文件 @
3047c4b4
...
...
@@ -26,18 +26,12 @@ namespace paddle_mobile {
namespace
operators
{
template
<
typename
T
>
struct
AddFunctor
{
inline
T
operator
()(
T
a
,
T
b
)
const
{
return
a
+
b
;
}
};
template
<
typename
P
>
void
ElementwiseAddCompute
(
const
ElementwiseAddParam
<
CPU
>
&
param
)
{
const
Tensor
*
input_x
=
param
.
InputX
();
const
Tensor
*
input_y
=
param
.
InputY
();
Tensor
*
Out
=
param
.
Out
();
Out
->
mutable_data
<
float
>
();
inline
void
ElementwiseAddCompute
(
const
ElementwiseAddParam
<
CPU
>
&
param
)
{
const
framework
::
Tensor
*
input_x
=
param
.
InputX
();
const
framework
::
Tensor
*
input_y
=
param
.
InputY
();
framework
::
Tensor
*
Out
=
param
.
Out
();
int
axis
=
param
.
Axis
();
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
const
auto
&
x_dims
=
input_x
->
dims
();
const
auto
&
y_dims
=
input_y
->
dims
();
/// axis = -1 represent the last dimensions.
...
...
@@ -57,18 +51,20 @@ void ElementwiseAddCompute(const ElementwiseAddParam<CPU> ¶m) {
const
float
*
bias_data
=
input_y
->
data
<
float
>
();
const
float
*
input_data
=
input_x
->
data
<
float
>
();
float
*
output_data
=
Out
->
mutable_data
<
float
>
();
#pragma omp parallel for collapse(2)
for
(
int
i
=
0
;
i
<
batch
;
++
i
)
{
#pragma omp parallel for
for
(
int
j
=
0
;
j
<
channels
;
++
j
)
{
size_t
offset
=
(
i
*
channels
+
j
)
*
elementwise_num
;
const
float
*
input
=
input_data
+
offset
;
const
float
*
bias
=
bias_data
+
j
;
const
float
bias
=
bias_data
[
j
]
;
float
*
output
=
output_data
+
offset
;
int
remain
=
elementwise_num
;
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
int
loop
=
elementwise_num
>>
0x4
;
int
remain
=
elementwise_num
&
0xF
;
remain
=
elementwise_num
&
0xF
;
for
(
int
k
=
0
;
k
<
loop
;
++
k
)
{
float32x4_t
rb
=
vdupq_n_f32
(
*
bias
);
float32x4_t
rb
=
vdupq_n_f32
(
bias
);
float32x4_t
r0
=
vld1q_f32
(
input
);
float32x4_t
r1
=
vld1q_f32
(
input
+
4
);
float32x4_t
r2
=
vld1q_f32
(
input
+
8
);
...
...
@@ -84,15 +80,12 @@ void ElementwiseAddCompute(const ElementwiseAddParam<CPU> ¶m) {
input
+=
16
;
output
+=
16
;
}
#endif
for
(
int
k
=
0
;
k
<
remain
;
++
k
)
{
output
[
k
]
=
input
[
k
]
+
*
bias
;
output
[
k
]
=
input
[
k
]
+
bias
;
}
}
}
#else
ElementwiseComputeEx
<
AddFunctor
<
float
>
,
float
>
(
input_x
,
input_y
,
axis
,
AddFunctor
<
float
>
(),
Out
);
#endif
}
template
class
ElementwiseAddKernel
<
CPU
,
float
>;
...
...
test/net/test_googlenet.cpp
浏览文件 @
3047c4b4
...
...
@@ -19,7 +19,7 @@ limitations under the License. */
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
std
::
cout
<<
"Usage: ./test_benchmark feed_shape [thread_num] [use_fuse]
\n
"
<<
"feed_shape: input tensor shape, such as
1,
3,224,224.
\n
"
<<
"feed_shape: input tensor shape, such as 3,224,224.
\n
"
<<
"thread_num: optional int, threads count, default is 1.
\n
"
<<
"use_fuse: optional bool, default is 0.
\n
"
;
return
1
;
...
...
@@ -52,7 +52,7 @@ int main(int argc, char* argv[]) {
sscanf
(
feed_shape
,
"%d,%d,%d"
,
&
dims
[
1
],
&
dims
[
2
],
&
dims
[
3
]);
}
std
::
cout
<<
"feed shape: ["
<<
dims
[
0
]
<<
", "
<<
dims
[
1
]
<<
", "
<<
dims
[
2
]
<<
", "
<<
dims
[
3
]
<<
"]
\n
"
;
<<
dims
[
2
]
<<
", "
<<
dims
[
3
]
<<
"]
"
<<
std
::
endl
;
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
// warmup
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录