Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5a2334af
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看板
提交
5a2334af
编写于
4月 25, 2019
作者:
Z
zhaojiaying01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gpu conv_bn_add_relu use 1x1 optimise kernel
上级
3f41ac2b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
177 addition
and
16 deletion
+177
-16
src/operators/kernel/cl/cl_kernel/conv_kernel.inc.cl
src/operators/kernel/cl/cl_kernel/conv_kernel.inc.cl
+170
-0
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
+1
-6
src/operators/kernel/cl/conv_add_kernel.cpp
src/operators/kernel/cl/conv_add_kernel.cpp
+1
-6
src/operators/kernel/cl/conv_add_relu_kernel.cpp
src/operators/kernel/cl/conv_add_relu_kernel.cpp
+1
-1
src/operators/kernel/cl/conv_bn_add_relu_kernel.cpp
src/operators/kernel/cl/conv_bn_add_relu_kernel.cpp
+2
-1
src/operators/kernel/cl/conv_bn_relu_kernel.cpp
src/operators/kernel/cl/conv_bn_relu_kernel.cpp
+1
-1
src/operators/kernel/cl/conv_kernel.cpp
src/operators/kernel/cl/conv_kernel.cpp
+1
-1
未找到文件。
src/operators/kernel/cl/cl_kernel/conv_kernel.inc.cl
浏览文件 @
5a2334af
...
...
@@ -2157,6 +2157,176 @@ __kernel void convBNAdd_1x1(__private const int global_size_dim0,
write_imageh(output_image, output_pos, output);
}
__kernel void convBNAdd_1x1_spl(
__private const int global_size_dim0, __private const int global_size_dim1,
__private const int global_size_dim2, __read_only image2d_t input_image,
__read_only image2d_t filter,
#ifdef BIASE
__read_only image2d_t bias,
#endif
#ifdef BATCH_NORM
__read_only image2d_t new_scale, __read_only image2d_t new_biase,
#endif
__write_only image2d_t output_image, __private const int stride,
__private const int offset, __private const int input_c,
__private const int dilation,
__private const int input_width, /* of one block */
__private const int input_height, /* of one block */
__private const int output_width,
__private const int output_height,
__private const int old_w
) {
const int out_c = get_global_id(0);
const int out_w = get_global_id(1);
const int out_nh = get_global_id(2);
int out_w0 = out_w;
int out_w1 = out_w + global_size_dim1;
int out_w2 = out_w + global_size_dim1 * 2;
int out_w3 = out_w + global_size_dim1 * 3;
// int out_w1 = out_w + global_size_dim1;
// int out_w2 = out_w + global_size_dim1 * 2;
// int out_w3 = out_w + global_size_dim1 * 3;
const sampler_t sampler =
CLK_NORMALIZED_COORDS_TRUE |
CLK_ADDRESS_CLAMP
|
CLK_FILTER_NEAREST
;
int2
stride_xy
=
(
int2
)(
stride,
stride
)
;
int2
ouput_pos_in_one_block0
=
(
int2
)(
out_w0,
out_nh
)
;
int2
in_pos_in_one_block0
=
ouput_pos_in_one_block0
*
stride_xy
+
(
int2
)(
offset,
offset
)
;
int2
ouput_pos_in_one_block1
=
(
int2
)(
out_w1,
out_nh
)
;
int2
in_pos_in_one_block1
=
ouput_pos_in_one_block1
*
stride_xy
+
(
int2
)(
offset,
offset
)
;
int2
ouput_pos_in_one_block2
=
(
int2
)(
out_w2,
out_nh
)
;
int2
in_pos_in_one_block2
=
ouput_pos_in_one_block2
*
stride_xy
+
(
int2
)(
offset,
offset
)
;
int2
ouput_pos_in_one_block3
=
(
int2
)(
out_w3,
out_nh
)
;
int2
in_pos_in_one_block3
=
ouput_pos_in_one_block3
*
stride_xy
+
(
int2
)(
offset,
offset
)
;
half4
output0
=
0.0f
;
half4
output1
=
0.0f
;
half4
output2
=
0.0f
;
half4
output3
=
0.0f
;
for
(
int
i
=
0
; i < input_c; ++i) {
//
------------0---------------
int2
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block0.x,
in_pos_in_one_block0.y
)
;
half4
input0
=
read_imageh
(
input_image,
sampler,
pos_in
)
;
half4
weight0
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
0
))
;
half4
weight1
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
1
))
;
half4
weight2
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
2
))
;
half4
weight3
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
3
))
;
output0
=
mad
(
input0.x,
weight0,
output0
)
;
output0
=
mad
(
input0.y,
weight1,
output0
)
;
output0
=
mad
(
input0.z,
weight2,
output0
)
;
output0
=
mad
(
input0.w,
weight3,
output0
)
;
//
-------------1--------------
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block1.x,
in_pos_in_one_block1.y
)
;
half4
input1
=
read_imageh
(
input_image,
sampler,
pos_in
)
;
//
//
half4
weight0
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
//
0
))
; half4 weight1 = read_imageh(filter, sampler, (int2)(out_c, i * 4
//
+
1
))
; half4 weight2 = read_imageh(filter, sampler, (int2)(out_c, i *
//
4
+
2
))
; half4 weight3 = read_imageh(filter, sampler, (int2)(out_c, i
//
*
4
+
3
))
;
output1
=
mad
(
input1.x,
weight0,
output1
)
;
output1
=
mad
(
input1.y,
weight1,
output1
)
;
output1
=
mad
(
input1.z,
weight2,
output1
)
;
output1
=
mad
(
input1.w,
weight3,
output1
)
;
//
-------------2--------------
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block2.x,
in_pos_in_one_block2.y
)
;
half4
input2
=
read_imageh
(
input_image,
sampler,
pos_in
)
;
//
half4
weight0
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
//
0
))
; half4 weight1 = read_imageh(filter, sampler, (int2)(out_c, i * 4
//
+
1
))
; half4 weight2 = read_imageh(filter, sampler, (int2)(out_c, i *
//
4
+
2
))
; half4 weight3 = read_imageh(filter, sampler, (int2)(out_c, i
//
*
4
+
3
))
;
output2
=
mad
(
input2.x,
weight0,
output2
)
;
output2
=
mad
(
input2.y,
weight1,
output2
)
;
output2
=
mad
(
input2.z,
weight2,
output2
)
;
output2
=
mad
(
input2.w,
weight3,
output2
)
;
//
-------------3--------------
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block3.x,
in_pos_in_one_block3.y
)
;
half4
input3
=
read_imageh
(
input_image,
sampler,
pos_in
)
;
//
half4
weight0
=
read_imageh
(
filter,
sampler,
(
int2
)(
out_c,
i
*
4
+
//
0
))
; half4 weight1 = read_imageh(filter, sampler, (int2)(out_c, i * 4
//
+
1
))
; half4 weight2 = read_imageh(filter, sampler, (int2)(out_c, i *
//
4
+
2
))
; half4 weight3 = read_imageh(filter, sampler, (int2)(out_c, i
//
*
4
+
3
))
;
output3
=
mad
(
input3.x,
weight0,
output3
)
;
output3
=
mad
(
input3.y,
weight1,
output3
)
;
output3
=
mad
(
input3.z,
weight2,
output3
)
;
output3
=
mad
(
input3.w,
weight3,
output3
)
;
}
#
ifdef
BATCH_NORM
output0
=
output0
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
output1
=
output1
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
output2
=
output2
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
output3
=
output3
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
#
endif
#
ifdef
BIASE
output0=
read_imageh
(
bias,
sampler,
(
int2
)(
out_c,
0
))
;
output1
=
read_imageh
(
bias,
sampler,
(
int2
)(
out_c,
0
))
;
output2
=
read_imageh
(
bias,
sampler,
(
int2
)(
out_c,
0
))
;
output3
=
read_imageh
(
bias,
sampler,
(
int2
)(
out_c,
0
))
;
#
endif
#
ifdef
RELU
output0
=
activation
(
output0
)
;
output1
=
activation
(
output1
)
;
output2
=
activation
(
output2
)
;
output3
=
activation
(
output3
)
;
#
endif
int
outpos_main
=
mul24
(
out_c
,
old_w
)
;
int2
output_pos0
=
(
int2
)(
outpos_main
+
out_w0,
out_nh
)
;
if
(
out_w0
<
old_w
)
{
write_imageh
(
output_image,
output_pos0,
output0
)
;
}
int2
output_pos1
=
(
int2
)(
outpos_main
+
out_w1,
out_nh
)
;
if
(
out_w1
<
old_w
)
{
write_imageh
(
output_image,
output_pos1,
output1
)
;
}
int2
output_pos2
=
(
int2
)(
outpos_main
+
out_w2,
out_nh
)
;
if
(
out_w2
<
old_w
)
{
write_imageh
(
output_image,
output_pos2,
output2
)
;
}
int2
output_pos3
=
(
int2
)(
outpos_main
+
out_w3,
out_nh
)
;
if
(
out_w3
<
old_w
)
{
write_imageh
(
output_image,
output_pos3,
output3
)
;
}
}
...
...
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -22,7 +22,6 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
bool
optimise
=
true
;
template
<
>
bool
ConvAddBNReluKernel
<
GPU_CL
,
float
>::
Init
(
FusionConvAddBNReluParam
<
GPU_CL
>
*
param
)
{
...
...
@@ -140,11 +139,7 @@ bool ConvAddBNReluKernel<GPU_CL, float>::Init(
if
(
param
->
Filter
()
->
dims
()[
2
]
==
1
&&
param
->
Filter
()
->
dims
()[
3
]
==
1
)
{
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
if
(
optimise
)
{
this
->
cl_helper_
.
AddKernel
(
"conv_1x1_spl"
,
"conv_add_bn_relu_kernel.cl"
);
}
else
{
this
->
cl_helper_
.
AddKernel
(
"conv_1x1"
,
"conv_add_bn_relu_kernel.cl"
);
}
this
->
cl_helper_
.
AddKernel
(
"conv_1x1_spl"
,
"conv_add_bn_relu_kernel.cl"
);
DLOG
<<
" conv add bn relu conv 1x1"
;
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
...
...
src/operators/kernel/cl/conv_add_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -19,7 +19,6 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
bool
optimise_convadd
=
true
;
template
<
>
bool
ConvAddKernel
<
GPU_CL
,
float
>::
Init
(
FusionConvAddParam
<
GPU_CL
>
*
param
)
{
...
...
@@ -37,11 +36,7 @@ bool ConvAddKernel<GPU_CL, float>::Init(FusionConvAddParam<GPU_CL> *param) {
if
(
param
->
Filter
()
->
dims
()[
2
]
==
1
&&
param
->
Filter
()
->
dims
()[
3
]
==
1
)
{
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
if
(
optimise_convadd
)
{
this
->
cl_helper_
.
AddKernel
(
"conv_1x1_spl"
,
"conv_add_kernel.cl"
);
}
else
{
this
->
cl_helper_
.
AddKernel
(
"conv_1x1"
,
"conv_add_kernel.cl"
);
}
this
->
cl_helper_
.
AddKernel
(
"conv_1x1_spl"
,
"conv_add_kernel.cl"
);
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
param
->
Input
()
->
dims
()[
1
]
==
param
->
Output
()
->
dims
()[
1
]
&&
param
->
Filter
()
->
dims
()[
2
]
==
3
)
{
...
...
src/operators/kernel/cl/conv_add_relu_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -38,7 +38,7 @@ bool ConvAddReluKernel<GPU_CL, float>::Init(
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
this
->
cl_helper_
.
AddKernel
(
"conv_1x1"
,
"conv_add_relu_kernel.cl"
);
this
->
cl_helper_
.
AddKernel
(
"conv_1x1
_spl
"
,
"conv_add_relu_kernel.cl"
);
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
param
->
Input
()
->
dims
()[
1
]
==
param
->
Output
()
->
dims
()[
1
]
&&
param
->
Filter
()
->
dims
()[
2
]
==
3
)
{
...
...
src/operators/kernel/cl/conv_bn_add_relu_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -103,7 +103,8 @@ bool ConvBNAddReluKernel<GPU_CL, float>::Init(
if
(
param
->
Filter
()
->
dims
()[
2
]
==
1
&&
param
->
Filter
()
->
dims
()[
3
]
==
1
)
{
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
this
->
cl_helper_
.
AddKernel
(
"convBNAdd_1x1"
,
"conv_bn_add_relu_kernel.cl"
);
this
->
cl_helper_
.
AddKernel
(
"convBNAdd_1x1_spl"
,
"conv_bn_add_relu_kernel.cl"
);
DLOG
<<
" conv bn add relu conv 1x1"
;
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
param
->
Input
()
->
dims
()[
1
]
==
param
->
Output
()
->
dims
()[
1
]
&&
...
...
src/operators/kernel/cl/conv_bn_relu_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -101,7 +101,7 @@ bool ConvBNReluKernel<GPU_CL, float>::Init(
if
(
param
->
Filter
()
->
dims
()[
2
]
==
1
&&
param
->
Filter
()
->
dims
()[
3
]
==
1
)
{
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
this
->
cl_helper_
.
AddKernel
(
"conv_1x1"
,
"conv_bn_relu_kernel.cl"
);
this
->
cl_helper_
.
AddKernel
(
"conv_1x1
_spl
"
,
"conv_bn_relu_kernel.cl"
);
DLOG
<<
" conv bn relu conv 1x1"
;
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
param
->
Input
()
->
dims
()[
1
]
==
param
->
Output
()
->
dims
()[
1
]
&&
...
...
src/operators/kernel/cl/conv_kernel.cpp
浏览文件 @
5a2334af
...
...
@@ -40,7 +40,7 @@ bool ConvKernel<GPU_CL, float>::Init(ConvParam<GPU_CL> *param) {
if
(
param
->
Filter
()
->
dims
()[
2
]
==
1
&&
param
->
Filter
()
->
dims
()[
3
]
==
1
)
{
param
->
Filter
()
->
InitNImage
(
cl_helper_
.
CLContext
(),
cl_helper_
.
CLCommandQueue
());
this
->
cl_helper_
.
AddKernel
(
"conv_1x1"
,
"conv_kernel.cl"
);
this
->
cl_helper_
.
AddKernel
(
"conv_1x1
_spl
"
,
"conv_kernel.cl"
);
DLOG
<<
"conv 1x1"
;
}
else
if
(
param
->
Filter
()
->
dims
()[
1
]
==
1
&&
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录