Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
6b3a0ebe
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
6b3a0ebe
编写于
10月 12, 2018
作者:
D
dolphin8
提交者:
GitHub
10月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1061 from dolphin8/opencl
fix reshape & relu & softmax
上级
3bc7573f
500c90ea
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
10 deletion
+40
-10
src/operators/kernel/cl/relu_kernel.cpp
src/operators/kernel/cl/relu_kernel.cpp
+6
-4
src/operators/kernel/cl/reshape_kernel.cpp
src/operators/kernel/cl/reshape_kernel.cpp
+27
-1
src/operators/kernel/cl/softmax_kernel.cpp
src/operators/kernel/cl/softmax_kernel.cpp
+7
-5
未找到文件。
src/operators/kernel/cl/relu_kernel.cpp
浏览文件 @
6b3a0ebe
...
...
@@ -28,11 +28,13 @@ template <>
void
ReluKernel
<
GPU_CL
,
float
>::
Compute
(
const
ReluParam
<
GPU_CL
>
&
param
)
{
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
const
auto
*
input
=
param
.
InputX
();
auto
*
output
=
par
ma
.
Out
();
auto
*
output
=
par
am
.
Out
();
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
output
);
clSetKernelArg
((
kernel
,
0
,
sizeof
(
cl_mem
),
&
input
.
getCLImage
());
clSetKernelArg
((
kernel
,
1
,
sizeof
(
cl_mem
),
&
output
.
getCLImage
());
int
work_size
[
2
]
=
{
input
.
ImageWidth
(),
input
.
ImageHeight
()
};
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
const
size_t
work_size
[
2
]
=
{
input
->
ImageWidth
(),
input
->
ImageHeight
()
};
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
}
...
...
src/operators/kernel/cl/reshape_kernel.cpp
浏览文件 @
6b3a0ebe
...
...
@@ -19,11 +19,37 @@ namespace operators {
template
<
>
bool
ReshapeKernel
<
GPU_CL
,
float
>::
Init
(
ReshapeParam
<
GPU_CL
>
*
param
)
{
this
->
cl_helper_
.
AddKernel
(
"reshape"
,
"reshape.cl"
);
return
true
;
}
template
<
>
void
ReshapeKernel
<
GPU_CL
,
float
>::
Compute
(
const
ReshapeParam
<
GPU_CL
>
&
param
)
{}
void
ReshapeKernel
<
GPU_CL
,
float
>::
Compute
(
const
ReshapeParam
<
GPU_CL
>
&
param
)
{
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
const
auto
*
input
=
param
.
InputX
();
auto
*
output
=
param
.
Out
();
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
const
auto
&
inputDim
=
input
->
dims
();
const
auto
&
outputDim
=
output
->
dims
();
int
dims
[
4
]
=
{
inputDim
[
0
],
inputDim
[
1
],
inputDim
[
2
],
inputDim
[
3
]};
int
odims
[
4
]
=
{
outputDim
[
0
],
outputDim
[
1
],
outputDim
[
2
],
outputDim
[
3
]};
clSetKernelArg
(
kernel
,
2
,
sizeof
(
int
),
dims
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
int
),
dims
+
1
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
dims
+
2
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
int
),
dims
+
3
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
odims
);
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
odims
+
1
);
clSetKernelArg
(
kernel
,
8
,
sizeof
(
int
),
odims
+
2
);
clSetKernelArg
(
kernel
,
9
,
sizeof
(
int
),
odims
+
3
);
const
size_t
work_size
[
2
]
=
{
output
->
ImageWidth
(),
output
->
ImageHeight
()
};
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
}
template
class
ReshapeKernel
<
GPU_CL
,
float
>;
...
...
src/operators/kernel/cl/softmax_kernel.cpp
浏览文件 @
6b3a0ebe
...
...
@@ -29,11 +29,13 @@ template <>
void
SoftmaxKernel
<
GPU_CL
,
float
>::
Compute
(
const
SoftmaxParam
<
GPU_CL
>
&
param
)
{
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
(
param
.
Out
()));
auto
&
input
=
param
.
InputX
();
auto
&
output
=
param
.
Out
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
input
.
getCLImage
());
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
output
.
getCLImage
());
const
auto
&
inputDim
=
input
.
dims
();
const
auto
*
input
=
param
.
InputX
();
auto
*
output
=
param
.
Out
();
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
const
auto
&
inputDim
=
input
->
dims
();
int
dims
[
4
]
=
{
inputDim
[
0
],
inputDim
[
1
],
inputDim
[
2
],
inputDim
[
3
]};
clSetKernelArg
(
kernel
,
2
,
sizeof
(
int
),
dims
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
int
),
dims
+
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录