Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
b03ad9ea
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看板
未验证
提交
b03ad9ea
编写于
10月 17, 2018
作者:
J
Jiaying Zhao
提交者:
GitHub
10月 17, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1126 from smilejames/opencl
update fetch_kernel with CLTensor
上级
09592f08
f2d355e4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
35 addition
and
34 deletion
+35
-34
src/operators/kernel/cl/fetch_kernel.cpp
src/operators/kernel/cl/fetch_kernel.cpp
+35
-34
未找到文件。
src/operators/kernel/cl/fetch_kernel.cpp
浏览文件 @
b03ad9ea
...
@@ -13,51 +13,52 @@ See the License for the specific language governing permissions and
...
@@ -13,51 +13,52 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "operators/kernel/fetch_kernel.h"
#include "operators/kernel/fetch_kernel.h"
#include "framework/cl/cl_tensor.h"
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
operators
{
namespace
operators
{
template
<
>
template
<
>
bool
FetchKernel
<
GPU_CL
,
float
>::
Init
(
FetchParam
<
GPU_CL
>
*
param
)
{
bool
FetchKernel
<
GPU_CL
,
float
>::
Init
(
FetchParam
<
GPU_CL
>
*
param
)
{
//
this->cl_helper_.AddKernel("fetch", "fetch_kernel.cl");
this
->
cl_helper_
.
AddKernel
(
"fetch"
,
"fetch_kernel.cl"
);
return
true
;
return
true
;
}
}
template
<
>
template
<
>
void
FetchKernel
<
GPU_CL
,
float
>::
Compute
(
const
FetchParam
<
GPU_CL
>
&
param
)
{
void
FetchKernel
<
GPU_CL
,
float
>::
Compute
(
const
FetchParam
<
GPU_CL
>
&
param
)
{
//
auto kernel = this->cl_helper_.KernelAt(0);
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
// auto default_work_size =
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
param
.
InputX
());
// this->cl_helper_.DefaultWorkSize(*param.InputX());
//
auto
input
=
param
.
InputX
()
->
GetCLImage
();
// auto input = param.InputX()->GetCLImage
();
auto
*
out
=
param
.
Out
();
// auto *out = param.Out();
//
const
auto
&
dims
=
param
.
InputX
()
->
dims
();
// const auto &dims = param.InputX()->dims()
;
const
int
N
=
dims
[
0
]
;
// const int N = dims[0
];
const
int
C
=
dims
[
1
];
// const int C = dims[1
];
const
int
in_height
=
dims
[
2
];
// const int in_height = dims[2
];
const
int
in_width
=
dims
[
3
];
// const int in_width = dims[3];
//
int
size_ch
=
in_height
*
in_width
;
// int size_ch = in_height * in_width
;
int
size_block
=
size_ch
*
4
;
// int size_block = size_ch * 4
;
int
size_batch
=
size_ch
*
C
;
// int size_batch = size_ch * C;
//
CLTensor
out_cl_tensor
(
this
->
cl_helper_
.
CLContext
(),
// // need create outputBuffer
this
->
cl_helper_
.
CLCommandQueue
());
// cl_image_format imageFormat
;
out_cl_tensor
.
Resize
(
out
->
dims
())
;
// imageFormat.image_channel_order = CL_RGBA
;
cl_mem
outBuffer
=
out_cl_tensor
.
mutable_data
<
float
>
()
;
// imageFormat.image_channel_data_type = CL_FLOAT;
// cl_mem outputBuffer
;
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
in_height
)
;
//
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
in_width
);
// clSetKernelArg(kernel, 0, sizeof(int), &in_height
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
int
),
&
size_ch
);
// clSetKernelArg(kernel, 1, sizeof(int), &in_width
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
int
),
&
size_block
);
// clSetKernelArg(kernel, 2, sizeof(int), &size_
ch);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
size_bat
ch
);
// clSetKernelArg(kernel, 3, sizeof(int), &size_block
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_mem
),
&
input
);
// clSetKernelArg(kernel, 4, sizeof(int), &size_batch
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
cl_mem
),
&
outBuffer
);
// clSetKernelArg(kernel, 5, sizeof(cl_mem), &input);
// clSetKernelArg(kernel, 6, sizeof(cl_mem), &outputBuffer);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
//
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
// clEnqueueNDRangeKernel(this->cl_helper_.CLCommandQueue(), kernel, 3, NULL,
// default_work_size.data(), NULL, 0, NULL, NULL
);
memcpy
(
out
->
data
(),
out_cl_tensor
.
Data
(),
out
->
memory_size
()
);
}
}
template
class
FetchKernel
<
GPU_CL
,
float
>;
template
class
FetchKernel
<
GPU_CL
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录