Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
ce034c0b
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看板
提交
ce034c0b
编写于
4月 12, 2020
作者:
xiebaiyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LITE][OPENCL][Image] fix cl_test_functions compile , test=develop
上级
a9bb9fcc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
20 deletion
+28
-20
lite/backends/opencl/cl_functions_test.cc
lite/backends/opencl/cl_functions_test.cc
+28
-20
未找到文件。
lite/backends/opencl/cl_functions_test.cc
浏览文件 @
ce034c0b
...
...
@@ -46,11 +46,11 @@ TEST(cl_test, context_test) {
auto
*
runtime
=
CLRuntime
::
Global
();
CHECK
(
runtime
->
IsInitSuccess
());
CLContext
context
;
context
.
AddKernel
(
"pool_max"
,
"image/pool_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
context
.
AddKernel
(
"pool_max"
,
"image/pool_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
context
.
AddKernel
(
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
context
.
AddKernel
(
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
}
TEST
(
cl_test
,
kernel_test
)
{
...
...
@@ -58,10 +58,10 @@ TEST(cl_test, kernel_test) {
CHECK
(
runtime
->
IsInitSuccess
());
std
::
unique_ptr
<
CLContext
>
context
(
new
CLContext
);
context
->
AddKernel
(
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
context
->
AddKernel
(
"pool_max"
,
"image/pool_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
context
->
AddKernel
(
"pool_max"
,
"image/pool_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
context
->
AddKernel
(
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
float
"
);
"elementwise_add"
,
"image/elementwise_add_kernel.cl"
,
"-DCL_DTYPE_
half
"
);
auto
kernel
=
context
->
GetKernel
(
2
);
std
::
unique_ptr
<
float
[]
>
in_data
(
new
float
[
4
*
3
*
256
*
512
]);
...
...
@@ -90,19 +90,23 @@ TEST(cl_test, kernel_test) {
LOG
(
INFO
)
<<
out_image
;
cl_int
status
;
status
=
kernel
.
setArg
(
0
,
*
in_image
.
cl_image
());
status
=
kernel
->
setArg
(
0
,
*
in_image
.
cl_image
());
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
1
,
*
bias_image
.
cl_image
());
status
=
kernel
->
setArg
(
1
,
*
bias_image
.
cl_image
());
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
2
,
*
out_image
.
cl_image
());
status
=
kernel
->
setArg
(
2
,
*
out_image
.
cl_image
());
CL_CHECK_FATAL
(
status
);
size_t
width
=
in_image
.
ImageWidth
();
size_t
height
=
in_image
.
ImageHeight
();
auto
global_work_size
=
cl
::
NDRange
{
width
,
height
};
cl
::
Event
event
;
status
=
context
->
GetCommandQueue
().
enqueueNDRangeKernel
(
kernel
,
cl
::
NullRange
,
global_work_size
,
cl
::
NullRange
,
nullptr
,
&
event
);
status
=
context
->
GetCommandQueue
().
enqueueNDRangeKernel
(
*
kernel
.
get
(),
cl
::
NullRange
,
global_work_size
,
cl
::
NullRange
,
nullptr
,
&
event
);
CL_CHECK_FATAL
(
status
);
status
=
context
->
GetCommandQueue
().
finish
();
CL_CHECK_FATAL
(
status
);
...
...
@@ -118,7 +122,7 @@ TEST(cl_test, target_wrapper_buffer_test) {
CHECK
(
inited
)
<<
"Fail to initialize OpenCL runtime."
;
std
::
unique_ptr
<
CLContext
>
context
(
new
CLContext
);
std
::
string
kernel_name
=
"elementwise_add"
;
std
::
string
build_options
=
"-DCL_DTYPE_
float
"
;
std
::
string
build_options
=
"-DCL_DTYPE_
half
"
;
context
->
AddKernel
(
kernel_name
,
"buffer/elementwise_add_kernel.cl"
,
build_options
);
std
::
vector
<
float
>
h_a
;
...
...
@@ -145,21 +149,25 @@ TEST(cl_test, target_wrapper_buffer_test) {
d_b
,
h_b
.
data
(),
sizeof
(
float
)
*
h_b
.
size
(),
IoDirection
::
HtoD
);
// x + y: x[n=1, c=10, h=1, w=1], y[c=10]
auto
kernel
=
context
->
GetKernel
(
kernel_name
+
build_options
);
cl_int
status
=
kernel
.
setArg
(
0
,
*
d_a
);
cl_int
status
=
kernel
->
setArg
(
0
,
*
d_a
);
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
1
,
*
d_b
);
status
=
kernel
->
setArg
(
1
,
*
d_b
);
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
2
,
*
d_out
);
status
=
kernel
->
setArg
(
2
,
*
d_out
);
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
3
,
1
);
status
=
kernel
->
setArg
(
3
,
1
);
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
4
,
10
);
status
=
kernel
->
setArg
(
4
,
10
);
CL_CHECK_FATAL
(
status
);
status
=
kernel
.
setArg
(
5
,
1
);
status
=
kernel
->
setArg
(
5
,
1
);
CL_CHECK_FATAL
(
status
);
auto
global_work_size
=
cl
::
NDRange
{
10
,
1
};
status
=
context
->
GetCommandQueue
().
enqueueNDRangeKernel
(
kernel
,
cl
::
NullRange
,
global_work_size
,
cl
::
NullRange
,
nullptr
,
nullptr
);
status
=
context
->
GetCommandQueue
().
enqueueNDRangeKernel
(
*
kernel
.
get
(),
cl
::
NullRange
,
global_work_size
,
cl
::
NullRange
,
nullptr
,
nullptr
);
CL_CHECK_FATAL
(
status
);
status
=
context
->
GetCommandQueue
().
finish
();
CL_CHECK_FATAL
(
status
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录