Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
fd490e7b
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看板
未验证
提交
fd490e7b
编写于
11月 06, 2018
作者:
S
suiyang
提交者:
GitHub
11月 06, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
a186b4c9
1e365645
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
90 addition
and
10 deletion
+90
-10
src/framework/cl/cl_engine.h
src/framework/cl/cl_engine.h
+4
-0
src/framework/cl/cl_scope.h
src/framework/cl/cl_scope.h
+2
-1
src/framework/executor.cpp
src/framework/executor.cpp
+6
-2
src/framework/loader.cpp
src/framework/loader.cpp
+48
-0
src/io/api_paddle_mobile.cc
src/io/api_paddle_mobile.cc
+3
-1
src/io/paddle_inference_api.h
src/io/paddle_inference_api.h
+1
-0
src/io/paddle_mobile.cpp
src/io/paddle_mobile.cpp
+7
-0
src/io/paddle_mobile.h
src/io/paddle_mobile.h
+8
-0
src/operators/math/gemm.cpp
src/operators/math/gemm.cpp
+7
-2
test/framework/test_load_memory_inference_api.cpp
test/framework/test_load_memory_inference_api.cpp
+3
-3
test/net/test_mobilenet_GPU.cpp
test/net/test_mobilenet_GPU.cpp
+1
-1
未找到文件。
src/framework/cl/cl_engine.h
浏览文件 @
fd490e7b
...
...
@@ -114,6 +114,9 @@ class CLEngine {
cl_device_id
DeviceID
(
int
index
=
0
)
{
return
devices_
[
index
];
}
std
::
string
GetCLPath
()
{
return
cl_path_
;
}
void
setClPath
(
std
::
string
cl_path
)
{
cl_path_
=
cl_path
;
}
private:
CLEngine
()
{
initialized_
=
false
;
}
...
...
@@ -129,6 +132,7 @@ class CLEngine {
cl_int
status_
;
std
::
string
cl_path_
;
std
::
unique_ptr
<
_cl_program
,
CLProgramDeleter
>
program_
;
// bool SetClContext();
...
...
src/framework/cl/cl_scope.h
浏览文件 @
fd490e7b
...
...
@@ -58,7 +58,8 @@ class CLScope {
}
auto
program
=
CLEngine
::
Instance
()
->
CreateProgramWith
(
context_
.
get
(),
"./cl_kernel/"
+
file_name
);
context_
.
get
(),
CLEngine
::
Instance
()
->
GetCLPath
()
+
"/cl_kernel/"
+
file_name
);
DLOG
<<
" --- begin build program -> "
<<
file_name
<<
" --- "
;
CLEngine
::
Instance
()
->
BuildProgram
(
program
.
get
());
...
...
src/framework/executor.cpp
浏览文件 @
fd490e7b
...
...
@@ -649,12 +649,14 @@ void Executor<GPU_CL, Precision::FP32>::InitMemory() {
template
<
>
void
Executor
<
GPU_CL
,
Precision
::
FP32
>::
InitCombineMemory
()
{
char
*
origin_data
;
char
*
origin_data
=
nullptr
;
bool
self_alloc
=
false
;
if
(
program_
.
combined_params_buf
&&
program_
.
combined_params_len
)
{
LOG
(
kLOG_INFO
)
<<
"use outter memory"
;
origin_data
=
reinterpret_cast
<
char
*>
(
program_
.
combined_params_buf
);
}
else
{
LOG
(
kLOG_INFO
)
<<
" begin init combine memory"
;
self_alloc
=
true
;
origin_data
=
ReadFileToBuff
(
program_
.
para_path
);
}
PADDLE_MOBILE_ENFORCE
(
origin_data
!=
nullptr
,
"origin_data==nullptr!!!"
);
...
...
@@ -701,7 +703,9 @@ void Executor<GPU_CL, Precision::FP32>::InitCombineMemory() {
}
}
}
delete
origin_data
;
if
(
self_alloc
)
{
delete
origin_data
;
}
LOG
(
kLOG_INFO
)
<<
" end init combine memory "
;
}
...
...
src/framework/loader.cpp
浏览文件 @
fd490e7b
...
...
@@ -82,6 +82,54 @@ void Loader<GPU_CL, Precision::FP32>::InitMemoryFromProgram(
}
}
}
template
<
>
const
Program
<
GPU_CL
,
Precision
::
FP32
>
Loader
<
GPU_CL
,
Precision
::
FP32
>::
LoadCombinedMemory
(
size_t
read_size
,
const
uint8_t
*
buf
,
size_t
combined_params_len
,
uint8_t
*
combined_params_buf
,
bool
optimize
,
bool
quantification
)
{
bool
can_add_split
=
false
;
PaddleMobile__Framework__Proto__ProgramDesc
*
c_program
;
PADDLE_MOBILE_ENFORCE
(
buf
!=
nullptr
,
"read from __model__ is null"
);
c_program
=
paddle_mobile__framework__proto__program_desc__unpack
(
nullptr
,
read_size
,
buf
);
//
PADDLE_MOBILE_ENFORCE
(
c_program
!=
nullptr
,
"program is null"
);
//
DLOG
<<
"n_ops: "
<<
(
*
c_program
->
blocks
)
->
n_ops
;
//
auto
originProgramDesc
=
std
::
make_shared
<
ProgramDesc
>
(
c_program
);
Program
<
GPU_CL
,
Precision
::
FP32
>
program
;
program
.
combined
=
true
;
program
.
originProgram
=
originProgramDesc
;
program
.
quantification
=
quantification
;
program
.
combined_params_len
=
combined_params_len
;
program
.
combined_params_buf
=
combined_params_buf
;
auto
scope
=
std
::
make_shared
<
Scope
>
();
program
.
scope
=
scope
;
InitMemoryFromProgram
(
originProgramDesc
,
scope
);
if
(
optimize
)
{
ProgramOptimize
program_optimize
;
program
.
optimizeProgram
=
program_optimize
.
FusionOptimize
(
originProgramDesc
,
can_add_split
);
if
(
!
program
.
optimizeProgram
)
{
program
.
optimizeProgram
=
originProgramDesc
;
}
}
if
(
optimize
)
{
program
.
optimizeProgram
->
Description
(
"optimize: "
);
}
else
{
originProgramDesc
->
Description
(
"program: "
);
}
paddle_mobile__framework__proto__program_desc__free_unpacked
(
c_program
,
nullptr
);
return
program
;
}
#endif
/**
...
...
src/io/api_paddle_mobile.cc
浏览文件 @
fd490e7b
...
...
@@ -29,7 +29,9 @@ PaddleMobilePredictor<Dtype, P>::PaddleMobilePredictor(
template
<
typename
Dtype
,
Precision
P
>
bool
PaddleMobilePredictor
<
Dtype
,
P
>::
Init
(
const
PaddleMobileConfig
&
config
)
{
paddle_mobile_
.
reset
(
new
PaddleMobile
<
Dtype
,
P
>
());
#ifdef PADDLE_MOBILE_CL
paddle_mobile_
->
SetCLPath
(
config
.
cl_path
);
#endif
if
(
config
.
memory_pack
.
from_memory
)
{
DLOG
<<
"load from memory!"
;
paddle_mobile_
->
LoadCombinedMemory
(
config
.
memory_pack
.
model_size
,
...
...
src/io/paddle_inference_api.h
浏览文件 @
fd490e7b
...
...
@@ -132,6 +132,7 @@ struct PaddleMobileConfig : public PaddlePredictor::Config {
int
thread_num
=
1
;
std
::
string
prog_file
;
std
::
string
param_file
;
std
::
string
cl_path
;
struct
PaddleModelMemoryPack
memory_pack
;
};
...
...
src/io/paddle_mobile.cpp
浏览文件 @
fd490e7b
...
...
@@ -158,6 +158,13 @@ void PaddleMobile<Dtype, P>::Predict_To(int end) {
}
#endif
#ifdef PADDLE_MOBILE_CL
template
<
typename
Dtype
,
Precision
P
>
void
PaddleMobile
<
Dtype
,
P
>::
SetCLPath
(
std
::
string
path
)
{
framework
::
CLEngine
::
Instance
()
->
setClPath
(
path
);
}
#endif
template
class
PaddleMobile
<
CPU
,
Precision
::
FP32
>;
template
class
PaddleMobile
<
FPGA
,
Precision
::
FP32
>;
template
class
PaddleMobile
<
GPU_MALI
,
Precision
::
FP32
>;
...
...
src/io/paddle_mobile.h
浏览文件 @
fd490e7b
...
...
@@ -26,6 +26,9 @@ limitations under the License. */
#include "framework/load_ops.h"
#include "framework/loader.h"
#include "framework/tensor.h"
#ifdef PADDLE_MOBILE_CL
#include "framework/cl/cl_engine.h"
#endif
namespace
paddle_mobile
{
...
...
@@ -68,6 +71,11 @@ class PaddleMobile {
void
Predict_To
(
int
end
);
#endif
#ifdef PADDLE_MOBILE_CL
public:
void
SetCLPath
(
std
::
string
cl_path
);
#endif
private:
std
::
shared_ptr
<
framework
::
Loader
<
Dtype
,
P
>>
loader_
;
std
::
shared_ptr
<
framework
::
Executor
<
Dtype
,
P
>>
executor_
;
...
...
src/operators/math/gemm.cpp
浏览文件 @
fd490e7b
...
...
@@ -3307,8 +3307,13 @@ void Gemm::Sgemm_omp(int m, int n, int k, float alpha, const float *A, int lda,
float
*
local_A
=
packedA
+
MC
*
KC
*
local_threads
;
float
*
local_C
=
packedC
+
MC
*
NC
*
local_threads
;
(
*
this
.
*
procPackA
)(
mc
,
KC
,
mc
%
MR
,
&
A
(
i
,
0
),
lda
,
local_A
);
InnerKernelWithBias
(
mc
,
n
,
alpha
,
local_A
,
packedB
,
beta
,
local_C
,
&
C
(
i
,
0
),
ldc
,
relu
,
bias
+
i
);
if
(
bias
==
nullptr
)
{
InnerKernelWithBias
(
mc
,
n
,
alpha
,
local_A
,
packedB
,
beta
,
local_C
,
&
C
(
i
,
0
),
ldc
,
relu
,
nullptr
);
}
else
{
InnerKernelWithBias
(
mc
,
n
,
alpha
,
local_A
,
packedB
,
beta
,
local_C
,
&
C
(
i
,
0
),
ldc
,
relu
,
bias
+
i
);
}
}
}
else
{
#pragma omp parallel for
...
...
test/framework/test_load_memory_inference_api.cpp
浏览文件 @
fd490e7b
...
...
@@ -55,11 +55,11 @@ static char *Get_binary_data(std::string filename) {
paddle_mobile
::
PaddleMobileConfig
GetConfig
()
{
paddle_mobile
::
PaddleMobileConfig
config
;
config
.
precision
=
paddle_mobile
::
PaddleMobileConfig
::
FP32
;
config
.
device
=
paddle_mobile
::
PaddleMobileConfig
::
k
CPU
;
config
.
device
=
paddle_mobile
::
PaddleMobileConfig
::
k
GPU_CL
;
const
std
::
shared_ptr
<
paddle_mobile
::
PaddleModelMemoryPack
>
&
memory_pack
=
std
::
make_shared
<
paddle_mobile
::
PaddleModelMemoryPack
>
();
auto
model_path
=
std
::
string
(
g_
genet_combine
)
+
"/model"
;
auto
params_path
=
std
::
string
(
g_
genet_combine
)
+
"/params"
;
auto
model_path
=
std
::
string
(
g_
mobilenet_combined
)
+
"/model"
;
auto
params_path
=
std
::
string
(
g_
mobilenet_combined
)
+
"/params"
;
memory_pack
->
model_size
=
ReadBuffer
(
model_path
.
c_str
(),
&
memory_pack
->
model_buf
);
std
::
cout
<<
"sizeBuf: "
<<
memory_pack
->
model_size
<<
std
::
endl
;
...
...
test/net/test_mobilenet_GPU.cpp
浏览文件 @
fd490e7b
...
...
@@ -22,7 +22,7 @@ int main() {
auto
time1
=
paddle_mobile
::
time
();
// auto isok = paddle_mobile.Load(std::string(g_mobilenet_detect) + "/model",
// std::string(g_mobilenet_detect) + "/params", true);
paddle_mobile
.
SetCLPath
(
"."
);
auto
isok
=
paddle_mobile
.
Load
(
std
::
string
(
g_mobilenet
),
true
);
if
(
isok
)
{
auto
time2
=
paddle_mobile
::
time
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录