Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
7389dd09
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看板
提交
7389dd09
编写于
10月 15, 2018
作者:
Y
yangfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some function
上级
fea3f17d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
24 deletion
+51
-24
src/common/common.h
src/common/common.h
+1
-1
src/framework/cl/cl_image.h
src/framework/cl/cl_image.h
+14
-1
src/framework/executor.cpp
src/framework/executor.cpp
+1
-1
src/framework/operator.cpp
src/framework/operator.cpp
+25
-13
src/operators/kernel/cl/feed_kernel.cpp
src/operators/kernel/cl/feed_kernel.cpp
+4
-4
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+2
-1
test/net/test_mobilenet_GPU.cpp
test/net/test_mobilenet_GPU.cpp
+4
-3
未找到文件。
src/common/common.h
浏览文件 @
7389dd09
...
...
@@ -28,4 +28,4 @@ inline double time_diff(Time t1, Time t2) {
return
counter
.
count
()
/
1000.0
;
}
}
}
// namespace paddle_mobile
src/framework/cl/cl_image.h
浏览文件 @
7389dd09
...
...
@@ -118,7 +118,20 @@ class CLImage {
cl_image_format
cf
=
{.
image_channel_order
=
CL_RGBA
,
.
image_channel_data_type
=
CL_HALF_FLOAT
};
// NCHW -> [W * (C+3)/4, H * N]
DLOG
<<
tensor_dims_
;
tensor_dims_
=
dim
;
if
(
tensor_data
)
{
tensor_data_
=
tensor_data
;
}
else
{
int
numel
=
1
;
for
(
int
i
=
0
;
i
<
dim
.
size
();
i
++
)
{
numel
*=
dim
[
i
];
}
tensor_data_
=
static_cast
<
float
*>
(
paddle_mobile
::
memory
::
Alloc
(
sizeof
(
float
)
*
numel
));
for
(
int
i
=
0
;
i
<
numel
;
i
++
)
{
tensor_data_
[
i
]
=
0
;
}
}
size_t
N
,
C
,
H
,
W
;
if
(
tensor_dims_
.
size
()
==
4
)
{
N
=
tensor_dims_
[
0
];
...
...
src/framework/executor.cpp
浏览文件 @
7389dd09
...
...
@@ -936,7 +936,7 @@ void Executor<GPU_CL, Precision::FP32>::InitMemory() {
cl_image
->
SetTensorData
(
tensorInput
,
ddim
);
delete
origin_data
;
paddle_mobile
::
memory
::
Free
(
tensorInput
);
//
paddle_mobile::memory::Free(tensorInput);
}
else
{
if
(
var_desc
->
Type
()
==
framework
::
VARTYPE_TYPE_LOD_TENSOR
)
{
auto
cl_image
=
var
->
template
GetMutable
<
framework
::
CLImage
>();
...
...
src/framework/operator.cpp
浏览文件 @
7389dd09
...
...
@@ -72,13 +72,16 @@ void OperatorBase<Dtype>::Run() {
if
(
tensor
)
DLOG
<<
type_
<<
" input- "
<<
key
<<
"="
<<
*
tensor
;
}
else
{
CLImage
*
cl_image
=
vari
->
template
GetMutable
<
framework
::
CLImage
>();
// cl_command_queue commandQueue =
// scope_->GetCLScpoe()->CommandQueue(); Tensor *tmp ;
// CLImageToTensor(cl_image,tmp,commandQueue);
// tmp->Resize(cl_image->dims());
// cl_command_queue commandQueue =
// scope_->GetCLScpoe()->CommandQueue(); Tensor
// *tmp ;
// CLImageToTensor(cl_image,tmp,commandQueue);
// tmp->Resize(cl_image->dims());
const
float
*
input
=
cl_image
->
data
<
float
>
();
if
(
cl_image
)
{
// DLOG<<type_<<" input- "<<key<<"="<<*tmp;
DLOG
<<
type_
<<
" input- "
<<
key
<<
"="
<<
cl_image
->
dims
();
// if(input)
// DLOG<<type_<<" input- "<<key<<"="<<*input;
}
}
...
...
@@ -95,15 +98,24 @@ void OperatorBase<Dtype>::Run() {
auto
vari
=
scope_
->
FindVar
(
var_vec_out
[
i
]);
if
(
vari
->
IsInitialized
())
{
#ifdef PADDLE_MOBILE_CL
CLImage
*
cl_image
=
vari
->
template
GetMutable
<
framework
::
CLImage
>();
// cl_command_queue commandQueue =
// scope_->GetCLScpoe()->CommandQueue(); Tensor *tmp ;
// CLImageToTensor(cl_image,tmp,commandQueue);
// tmp->Resize(cl_image->dims());
if
(
cl_image
)
{
// DLOG<<type_<<" output- "<<key<<"="<<*tmp;
DLOG
<<
type_
<<
" output- "
<<
key
<<
"="
<<
cl_image
->
dims
();
if
(
type_
==
"fetch"
)
{
Tensor
*
tensor
=
vari
->
template
GetMutable
<
framework
::
LoDTensor
>();
if
(
tensor
)
DLOG
<<
type_
<<
" output- "
<<
key
<<
"="
<<
tensor
->
dims
();
}
else
{
CLImage
*
cl_image
=
vari
->
template
GetMutable
<
framework
::
CLImage
>();
// cl_command_queue commandQueue =
// scope_->GetCLScpoe()->CommandQueue(); Tensor *tmp ;
// CLImageToTensor(cl_image,tmp,commandQueue);
// tmp->Resize(cl_image->dims());
if
(
cl_image
)
{
const
float
*
output
=
cl_image
->
data
<
float
>
();
DLOG
<<
type_
<<
" output- "
<<
key
<<
"="
<<
cl_image
->
dims
();
// if(output)
// DLOG<<type_<<" output- "<<key<<"="<<*output;
}
}
#else
Tensor
*
tensor
=
vari
->
template
GetMutable
<
framework
::
LoDTensor
>();
if
(
tensor
)
DLOG
<<
type_
<<
" output- "
<<
key
<<
"="
<<
*
tensor
;
...
...
src/operators/kernel/cl/feed_kernel.cpp
浏览文件 @
7389dd09
...
...
@@ -27,17 +27,17 @@ bool FeedKernel<GPU_CL, float>::Init(FeedParam<GPU_CL> *param) {
template
<
>
void
FeedKernel
<
GPU_CL
,
float
>::
Compute
(
const
FeedParam
<
GPU_CL
>
&
param
)
{
DLOG
<<
"feed_kernel"
;
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
cl_int
status
;
auto
output
=
param
.
Out
();
auto
input
=
param
.
InputX
();
DLOG
<<
" input: "
<<
input
;
const
Tensor
*
input
=
param
.
InputX
();
const
float
*
input_data
=
nullptr
;
input_data
=
input
->
data
<
float
>
();
const
float
*
input_data
=
input
->
data
<
float
>
();
cl_mem
cl_image
=
output
->
GetCLImage
();
int
height
=
output
->
dims
()[
2
];
int
width
=
output
->
dims
()[
3
];
DLOG
<<
output
->
dims
();
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
input_data
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
cl_image
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
width
);
...
...
test/net/test_googlenet.cpp
浏览文件 @
7389dd09
...
...
@@ -30,7 +30,8 @@ int main() {
auto
time1
=
time
();
if
(
paddle_mobile
.
Load
(
g_googlenet
,
optimize
))
{
auto
time2
=
paddle_mobile
::
time
();
std
::
cout
<<
"load cost :"
<<
paddle_mobile
::
time_diff
(
time1
,
time2
)
<<
"ms"
<<
std
::
endl
;
std
::
cout
<<
"load cost :"
<<
paddle_mobile
::
time_diff
(
time1
,
time2
)
<<
"ms"
<<
std
::
endl
;
std
::
vector
<
float
>
input
;
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
...
...
test/net/test_mobilenet_GPU.cpp
浏览文件 @
7389dd09
...
...
@@ -26,7 +26,8 @@ int main() {
auto
isok
=
paddle_mobile
.
Load
(
g_mobilenet
,
false
);
if
(
isok
)
{
auto
time2
=
paddle_mobile
::
time
();
std
::
cout
<<
"load cost :"
<<
paddle_mobile
::
time_diff
(
time1
,
time1
)
<<
"ms"
<<
std
::
endl
;
std
::
cout
<<
"load cost :"
<<
paddle_mobile
::
time_diff
(
time1
,
time1
)
<<
"ms"
<<
std
::
endl
;
std
::
vector
<
float
>
input
;
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
...
...
@@ -48,8 +49,8 @@ int main() {
}
DLOG
<<
vec_result
;
auto
time4
=
paddle_mobile
::
time
();
std
::
cout
<<
"predict cost :"
<<
paddle_mobile
::
time_diff
(
time3
,
time4
)
/
10
<<
"ms"
<<
std
::
endl
;
std
::
cout
<<
"predict cost :"
<<
paddle_mobile
::
time_diff
(
time3
,
time4
)
/
10
<<
"ms"
<<
std
::
endl
;
}
std
::
cout
<<
"如果结果Nan请查看: test/images/g_test_image_1x3x224x224_banana "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录