Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
70966b6f
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看板
提交
70966b6f
编写于
11月 12, 2018
作者:
Y
yangfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cpu and gpu predict function,optimize feed op kernel
上级
d89d0cfd
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
28 addition
and
18 deletion
+28
-18
src/io/api_paddle_mobile.cc
src/io/api_paddle_mobile.cc
+4
-0
src/io/api_paddle_mobile.h
src/io/api_paddle_mobile.h
+2
-0
src/io/paddle_inference_api.h
src/io/paddle_inference_api.h
+1
-1
src/io/paddle_mobile.cpp
src/io/paddle_mobile.cpp
+6
-4
src/io/paddle_mobile.h
src/io/paddle_mobile.h
+1
-2
test/net/test_yologpu.cpp
test/net/test_yologpu.cpp
+14
-11
未找到文件。
src/io/api_paddle_mobile.cc
浏览文件 @
70966b6f
...
@@ -52,6 +52,10 @@ bool PaddleMobilePredictor<Dtype, P>::Init(const PaddleMobileConfig &config) {
...
@@ -52,6 +52,10 @@ bool PaddleMobilePredictor<Dtype, P>::Init(const PaddleMobileConfig &config) {
paddle_mobile_
->
SetThreadNum
(
config
.
thread_num
);
paddle_mobile_
->
SetThreadNum
(
config
.
thread_num
);
return
true
;
return
true
;
}
}
template
<
typename
Dtype
,
Precision
P
>
double
PaddleMobilePredictor
<
Dtype
,
P
>::
CaculatePredictTime
()
{
return
paddle_mobile_
->
GetPredictTime
();
};
template
<
typename
Dtype
,
Precision
P
>
template
<
typename
Dtype
,
Precision
P
>
bool
PaddleMobilePredictor
<
Dtype
,
P
>::
Run
(
bool
PaddleMobilePredictor
<
Dtype
,
P
>::
Run
(
...
...
src/io/api_paddle_mobile.h
浏览文件 @
70966b6f
...
@@ -40,6 +40,8 @@ class PaddleMobilePredictor : public PaddlePredictor {
...
@@ -40,6 +40,8 @@ class PaddleMobilePredictor : public PaddlePredictor {
std
::
vector
<
PaddleTensor
>*
output_data
,
std
::
vector
<
PaddleTensor
>*
output_data
,
int
batch_size
=
-
1
)
override
;
int
batch_size
=
-
1
)
override
;
double
CaculatePredictTime
()
override
;
~
PaddleMobilePredictor
()
override
;
~
PaddleMobilePredictor
()
override
;
private:
private:
...
...
src/io/paddle_inference_api.h
浏览文件 @
70966b6f
...
@@ -98,7 +98,7 @@ class PaddlePredictor {
...
@@ -98,7 +98,7 @@ class PaddlePredictor {
virtual
bool
Run
(
const
std
::
vector
<
PaddleTensor
>&
inputs
,
virtual
bool
Run
(
const
std
::
vector
<
PaddleTensor
>&
inputs
,
std
::
vector
<
PaddleTensor
>*
output_data
,
std
::
vector
<
PaddleTensor
>*
output_data
,
int
batch_size
=
-
1
)
=
0
;
int
batch_size
=
-
1
)
=
0
;
virtual
double
CaculatePredictTime
()
=
0
;
// Destroy the Predictor.
// Destroy the Predictor.
virtual
~
PaddlePredictor
()
=
default
;
virtual
~
PaddlePredictor
()
=
default
;
...
...
src/io/paddle_mobile.cpp
浏览文件 @
70966b6f
...
@@ -13,9 +13,11 @@ See the License for the specific language governing permissions and
...
@@ -13,9 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "io/paddle_mobile.h"
#include "io/paddle_mobile.h"
#ifdef PADDLE_MOBILE_CL
#include <CL/cl.h>
#include <CL/cl.h>
#include "common/common.h"
#include "framework/cl/cl_tensor.h"
#include "framework/cl/cl_tensor.h"
#endif
#include "common/common.h"
#include "operators/math/gemm.h"
#include "operators/math/gemm.h"
namespace
paddle_mobile
{
namespace
paddle_mobile
{
...
@@ -123,7 +125,7 @@ void PaddleMobile<Dtype, P>::Clear() {
...
@@ -123,7 +125,7 @@ void PaddleMobile<Dtype, P>::Clear() {
}
}
template
<
typename
Dtype
,
Precision
P
>
template
<
typename
Dtype
,
Precision
P
>
double
PaddleMobile
<
Dtype
,
P
>::
Get
CPU
PredictTime
()
{
double
PaddleMobile
<
Dtype
,
P
>::
GetPredictTime
()
{
int
m
=
32
;
int
m
=
32
;
int
n
=
224
*
224
;
int
n
=
224
*
224
;
int
k
=
27
;
int
k
=
27
;
...
@@ -204,8 +206,8 @@ void PaddleMobile<Dtype, P>::SetCLPath(std::string path) {
...
@@ -204,8 +206,8 @@ void PaddleMobile<Dtype, P>::SetCLPath(std::string path) {
framework
::
CLEngine
::
Instance
()
->
setClPath
(
path
);
framework
::
CLEngine
::
Instance
()
->
setClPath
(
path
);
}
}
}
}
template
<
typename
Dtype
,
Precision
P
>
template
<
>
double
PaddleMobile
<
Dtype
,
P
>::
GetGPU
PredictTime
()
{
double
PaddleMobile
<
GPU_CL
,
Precision
::
FP32
>::
Get
PredictTime
()
{
cl_int
status
;
cl_int
status
;
cl_uint
nPlatform
;
cl_uint
nPlatform
;
clGetPlatformIDs
(
0
,
NULL
,
&
nPlatform
);
clGetPlatformIDs
(
0
,
NULL
,
&
nPlatform
);
...
...
src/io/paddle_mobile.h
浏览文件 @
70966b6f
...
@@ -65,7 +65,7 @@ class PaddleMobile {
...
@@ -65,7 +65,7 @@ class PaddleMobile {
void
SetThreadNum
(
int
num
);
void
SetThreadNum
(
int
num
);
void
Clear
();
void
Clear
();
double
Get
CPU
PredictTime
();
double
GetPredictTime
();
~
PaddleMobile
();
~
PaddleMobile
();
...
@@ -81,7 +81,6 @@ class PaddleMobile {
...
@@ -81,7 +81,6 @@ class PaddleMobile {
#ifdef PADDLE_MOBILE_CL
#ifdef PADDLE_MOBILE_CL
public:
public:
void
SetCLPath
(
std
::
string
cl_path
);
void
SetCLPath
(
std
::
string
cl_path
);
double
GetGPUPredictTime
();
int
readText
(
const
char
*
kernelPath
,
int
readText
(
const
char
*
kernelPath
,
char
**
pcode
);
// 读取文本文件放入 pcode,返回字符串长度
char
**
pcode
);
// 读取文本文件放入 pcode,返回字符串长度
#endif
#endif
...
...
test/net/test_yologpu.cpp
浏览文件 @
70966b6f
...
@@ -18,15 +18,16 @@ limitations under the License. */
...
@@ -18,15 +18,16 @@ limitations under the License. */
#include "../test_helper.h"
#include "../test_helper.h"
#include "../test_include.h"
#include "../test_include.h"
void
t1
()
{
void
t1
()
{
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
GPU_CL
>
paddle_mobile
;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
GPU_CL
>
paddle_mobile_gpu
;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile_cpu
;
// paddle_mobile.SetThreadNum(4);
// paddle_mobile.SetThreadNum(4);
#ifdef PADDLE_MOBILE_CL
#ifdef PADDLE_MOBILE_CL
paddle_mobile
.
SetCLPath
(
"/data/local/tmp/bin"
);
paddle_mobile
_gpu
.
SetCLPath
(
"/data/local/tmp/bin"
);
#endif
#endif
printf
(
"cpu time:%f
\n
"
,
paddle_mobile
.
GetCPU
PredictTime
());
printf
(
"cpu time:%f
\n
"
,
paddle_mobile
_cpu
.
Get
PredictTime
());
printf
(
"gpu time:%f
\n
"
,
paddle_mobile
.
GetGPU
PredictTime
());
printf
(
"gpu time:%f
\n
"
,
paddle_mobile
_gpu
.
Get
PredictTime
());
auto
time1
=
paddle_mobile
::
time
();
auto
time1
=
paddle_mobile
::
time
();
auto
isok
=
paddle_mobile
.
Load
(
std
::
string
(
g_yolo_mul
)
+
"/model"
,
auto
isok
=
paddle_mobile
_gpu
.
Load
(
std
::
string
(
g_yolo_mul
)
+
"/model"
,
std
::
string
(
g_yolo_mul
)
+
"/params"
,
true
);
std
::
string
(
g_yolo_mul
)
+
"/params"
,
true
);
// auto isok = paddle_mobile.Load(std::string(g_yolo_mul), true);
// auto isok = paddle_mobile.Load(std::string(g_yolo_mul), true);
...
@@ -45,7 +46,7 @@ void t1() {
...
@@ -45,7 +46,7 @@ void t1() {
auto
time3
=
paddle_mobile
::
time
();
auto
time3
=
paddle_mobile
::
time
();
int
max
=
10
;
int
max
=
10
;
for
(
int
i
=
0
;
i
<
max
;
++
i
)
{
for
(
int
i
=
0
;
i
<
max
;
++
i
)
{
vec_result
=
paddle_mobile
.
Predict
(
input
,
dims
);
vec_result
=
paddle_mobile
_gpu
.
Predict
(
input
,
dims
);
}
}
auto
time4
=
paddle_mobile
::
time
();
auto
time4
=
paddle_mobile
::
time
();
...
@@ -174,9 +175,11 @@ void t3() {
...
@@ -174,9 +175,11 @@ void t3() {
int
main
()
{
int
main
()
{
// std::thread th1(t1);
// std::thread th1(t1);
// std::thread th2(t2);
// std::thread th2(t2);
std
::
thread
th1
(
t1
);
std
::
thread
th3
(
t3
);
// std::thread th1(t1);
// th1.join();
// th1.join();
// th2.join();
// th2.join();
th1
.
join
();
th3
.
join
();
// th1.join();
return
0
;
return
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录