Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
86cb0443
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看板
提交
86cb0443
编写于
7月 11, 2018
作者:
W
WangLiu
提交者:
GitHub
7月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #553 from cocodark/develop
accelerate with openmp
上级
2557bd23
7df896bf
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
171 addition
and
131 deletion
+171
-131
CMakeLists.txt
CMakeLists.txt
+1
-1
src/io/executor.cpp
src/io/executor.cpp
+12
-0
src/io/executor.h
src/io/executor.h
+2
-0
src/operators/kernel/lrn_kernel.h
src/operators/kernel/lrn_kernel.h
+4
-1
src/operators/math/pool_3x3.cpp
src/operators/math/pool_3x3.cpp
+139
-121
src/operators/math/pool_3x3.h
src/operators/math/pool_3x3.h
+4
-1
src/operators/math/pooling.cpp
src/operators/math/pooling.cpp
+5
-4
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+4
-3
未找到文件。
CMakeLists.txt
浏览文件 @
86cb0443
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
project
(
paddle-mobile
)
project
(
paddle-mobile
)
option
(
DEBUGING
"enable debug mode"
ON
)
option
(
DEBUGING
"enable debug mode"
ON
)
option
(
USE_OPENMP
"openmp support"
O
FF
)
option
(
USE_OPENMP
"openmp support"
O
N
)
option
(
USE_EXCEPTION
"use std exception"
ON
)
option
(
USE_EXCEPTION
"use std exception"
ON
)
option
(
LOG_PROFILE
"log profile"
ON
)
option
(
LOG_PROFILE
"log profile"
ON
)
# select the platform to build
# select the platform to build
...
...
src/io/executor.cpp
浏览文件 @
86cb0443
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "io/executor.h"
#include "io/executor.h"
#include <operators/math/gemm.h>
#include <algorithm>
#include <algorithm>
#include <vector>
#include <vector>
#include "common/enforce.h"
#include "common/enforce.h"
...
@@ -25,6 +26,9 @@ limitations under the License. */
...
@@ -25,6 +26,9 @@ limitations under the License. */
#include "framework/program/var_desc.h"
#include "framework/program/var_desc.h"
#include "framework/scope.h"
#include "framework/scope.h"
#include "framework/tensor.h"
#include "framework/tensor.h"
#ifdef _OPENMP
#include <omp.h>
#endif // _OPENMP
#ifdef PADDLE_EXECUTOR_MULTITHREAD
#ifdef PADDLE_EXECUTOR_MULTITHREAD
#include <queue>
#include <queue>
#include <utility>
#include <utility>
...
@@ -403,6 +407,14 @@ std::vector<typename Executor<Dtype, P>::Ptype> Executor<Dtype, P>::Predict(
...
@@ -403,6 +407,14 @@ std::vector<typename Executor<Dtype, P>::Ptype> Executor<Dtype, P>::Predict(
return
result_vector
;
return
result_vector
;
}
}
template
<
typename
Dtype
,
Precision
P
>
void
Executor
<
Dtype
,
P
>::
SetThreadNum
(
int
num
)
{
#ifdef _OPENMP
// omp_set_dynamic(0);
omp_set_num_threads
(
num
);
#endif
}
template
class
Executor
<
CPU
,
Precision
::
FP32
>;
template
class
Executor
<
CPU
,
Precision
::
FP32
>;
template
class
Executor
<
FPGA
,
Precision
::
FP32
>;
template
class
Executor
<
FPGA
,
Precision
::
FP32
>;
template
class
Executor
<
GPU_MALI
,
Precision
::
FP32
>;
template
class
Executor
<
GPU_MALI
,
Precision
::
FP32
>;
...
...
src/io/executor.h
浏览文件 @
86cb0443
...
@@ -58,6 +58,8 @@ class Executor {
...
@@ -58,6 +58,8 @@ class Executor {
std
::
vector
<
Ptype
>
Predict
(
const
std
::
vector
<
Ptype
>
&
input
,
std
::
vector
<
Ptype
>
Predict
(
const
std
::
vector
<
Ptype
>
&
input
,
const
std
::
vector
<
int64_t
>
&
dims
);
const
std
::
vector
<
int64_t
>
&
dims
);
void
SetThreadNum
(
int
num
);
protected:
protected:
Executor
()
=
default
;
Executor
()
=
default
;
void
InitMemory
();
void
InitMemory
();
...
...
src/operators/kernel/lrn_kernel.h
浏览文件 @
86cb0443
...
@@ -13,7 +13,9 @@ See the License for the specific language governing permissions and
...
@@ -13,7 +13,9 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#ifdef LRN_OP
#ifdef LRN_OP
#ifdef _OPENMP
#include <omp.h>
#endif
#include "framework/operator.h"
#include "framework/operator.h"
#include "operators/op_param.h"
#include "operators/op_param.h"
...
@@ -47,6 +49,7 @@ struct LRNFunctor {
...
@@ -47,6 +49,7 @@ struct LRNFunctor {
std
::
fill
(
sqr_buffer_ptr
,
sqr_buffer_ptr
+
sqr_buffer
.
numel
(),
0.0
);
std
::
fill
(
sqr_buffer_ptr
,
sqr_buffer_ptr
+
sqr_buffer
.
numel
(),
0.0
);
for
(
int
a
=
0
;
a
<
N
;
a
++
)
{
for
(
int
a
=
0
;
a
<
N
;
a
++
)
{
#pragma parallel for
for
(
int
b
=
0
;
b
<
C
;
b
++
)
{
for
(
int
b
=
0
;
b
<
C
;
b
++
)
{
for
(
int
index
=
start
;
index
<
end
;
index
++
)
{
for
(
int
index
=
start
;
index
<
end
;
index
++
)
{
int
channel
=
b
+
index
;
int
channel
=
b
+
index
;
...
...
src/operators/math/pool_3x3.cpp
浏览文件 @
86cb0443
此差异已折叠。
点击以展开。
src/operators/math/pool_3x3.h
浏览文件 @
86cb0443
...
@@ -15,10 +15,13 @@ limitations under the License. */
...
@@ -15,10 +15,13 @@ limitations under the License. */
#ifdef POOL_OP
#ifdef POOL_OP
#pragma once
#pragma once
#ifdef _OPENMP
#include <omp.h>
#endif
#include <algorithm>
#include <algorithm>
#include <vector>
#include <vector>
#include "framework/tensor.h"
#include "framework/tensor.h"
#if
def
__ARM_NEON
#if __ARM_NEON
#include <arm_neon.h>
#include <arm_neon.h>
#endif // __ARM_NEON
#endif // __ARM_NEON
...
...
src/operators/math/pooling.cpp
浏览文件 @
86cb0443
...
@@ -14,10 +14,11 @@ limitations under the License. */
...
@@ -14,10 +14,11 @@ limitations under the License. */
#ifdef POOL_OP
#ifdef POOL_OP
#include "operators/math/pooling.h"
#include "pooling.h"
#include <algorithm>
#include <vector>
#include "common/types.h"
#include "common/types.h"
#ifdef _OPENMP
#include <omp.h>
#endif
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
operators
{
namespace
operators
{
...
@@ -59,7 +60,7 @@ class PoolFunctor<CPU, PoolProcess, T> {
...
@@ -59,7 +60,7 @@ class PoolFunctor<CPU, PoolProcess, T> {
T
*
output_data
=
output
->
mutable_data
<
T
>
();
T
*
output_data
=
output
->
mutable_data
<
T
>
();
for
(
int
i
=
0
;
i
<
batch_size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
batch_size
;
i
++
)
{
//
#pragma omp parallel for
#pragma omp parallel for
for
(
int
c
=
0
;
c
<
output_channels
;
++
c
)
{
for
(
int
c
=
0
;
c
<
output_channels
;
++
c
)
{
for
(
int
ph
=
0
;
ph
<
output_height
;
++
ph
)
{
for
(
int
ph
=
0
;
ph
<
output_height
;
++
ph
)
{
int
hstart
=
ph
*
stride_height
-
padding_height
;
int
hstart
=
ph
*
stride_height
-
padding_height
;
...
...
test/net/test_googlenet.cpp
浏览文件 @
86cb0443
...
@@ -26,16 +26,17 @@ int main() {
...
@@ -26,16 +26,17 @@ int main() {
auto
time2
=
time
();
auto
time2
=
time
();
DLOG
<<
"load cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms
\n
"
;
DLOG
<<
"load cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms
\n
"
;
paddle_mobile
::
Executor
<
paddle_mobile
::
CPU
>
executor
(
program
,
1
,
optimize
);
paddle_mobile
::
Executor
<
paddle_mobile
::
CPU
>
executor
(
program
,
1
,
optimize
);
executor
.
SetThreadNum
(
4
);
std
::
vector
<
float
>
input
;
std
::
vector
<
float
>
input
;
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
auto
time3
=
time
();
auto
time3
=
time
();
int
count
=
1
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
executor
.
Predict
(
input
,
dims
);
executor
.
Predict
(
input
,
dims
);
}
}
auto
time4
=
time
();
auto
time4
=
time
();
DLOG
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms
\n
"
;
DLOG
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
/
count
<<
"ms
\n
"
;
return
0
;
return
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录