Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
6df2ad4a
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看板
提交
6df2ad4a
编写于
10月 17, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 17, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1109 from codeWorm2015/opencl
update fusion conv kernel
上级
3cb1bad6
f791a439
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
17 deletion
+23
-17
src/framework/operator.cpp
src/framework/operator.cpp
+2
-0
src/operators/kernel/cl/cl_kernel/conv_add_bn_relu_kernel.cl
src/operators/kernel/cl/cl_kernel/conv_add_bn_relu_kernel.cl
+10
-8
src/operators/kernel/cl/cl_kernel/conv_add_kernel.cl
src/operators/kernel/cl/cl_kernel/conv_add_kernel.cl
+9
-7
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
+1
-1
test/net/test_mobilenet_GPU.cpp
test/net/test_mobilenet_GPU.cpp
+1
-1
未找到文件。
src/framework/operator.cpp
浏览文件 @
6df2ad4a
...
...
@@ -57,7 +57,9 @@ void OperatorBase<Dtype>::CheckAllInputOutputSet() const {}
template
<
typename
Dtype
>
void
OperatorBase
<
Dtype
>::
Run
()
{
DLOG
<<
" ----- Begin run impl --- "
<<
type_
<<
" ----- "
;
RunImpl
();
DLOG
<<
" ----- End run impl --- "
<<
type_
<<
" ----- "
;
#ifdef PADDLE_MOBILE_DEBUG
DLOG
<<
"-------------"
<<
type_
<<
"----------------------------"
;
vector
<
string
>
input_keys
=
GetInputKeys
();
...
...
src/operators/kernel/cl/cl_kernel/conv_add_bn_relu_kernel.cl
浏览文件 @
6df2ad4a
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#
pragma
OPENCL
EXTENSION
cl_khr_fp16
:
enable
#
define
BIASE
#
define
BATCH_NORM
...
...
@@ -54,21 +53,24 @@ __kernel void conv_3x3(__private const int global_size_dim0,
ouput_pos_in_one_block.x
=
out_w
;
ouput_pos_in_one_block.y
=
out_nh
;
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
|
CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
int2
in_pos_in_one_block
;
in_pos_in_one_block.x
=
ouput_pos_in_one_block.x
*
stride
+
offset
;
in_pos_in_one_block.y
=
ouput_pos_in_one_block.y
*
stride
+
offset
;
#
ifdef
BIASE
half4
output
=
read_imageh
(
bias,
sampler,
int2
(
out_c,
0
))
;
half4
output
=
read_imageh
(
bias,
sampler,
(
int2
)
(
out_c,
0
))
;
#
else
half4
output
=
0.0f
;
#
endif
half4
input[9]
;
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
|
CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
for
(
int
i
=
0
; i < input_c; ++i) {
int2
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block.x,
in_pos_in_one_block.y
)
;
...
...
@@ -139,7 +141,7 @@ __kernel void conv_3x3(__private const int global_size_dim0,
}
#ifdef BATCH_NORM
output = output * read_imageh(new_scale, sampler,
int2(out_c, 0)) + read_imageh(new_biase, sampler, int2(out_c, 0))
output = output * read_imageh(new_scale, sampler,
(int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0));
#endif
#ifdef RELU
...
...
@@ -250,7 +252,7 @@ __kernel void depth_conv_3x3(__private const int global_size_dim0,
}
#ifdef BATCH_NORM
output = output * read_imageh(new_scale, sampler, (int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0))
output = output * read_imageh(new_scale, sampler, (int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0))
;
#endif
#ifdef RELU
...
...
@@ -321,7 +323,7 @@ __kernel void conv_1x1(__private const int global_size_dim0,
}
#
ifdef
BATCH_NORM
output
=
output
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
output
=
output
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
#
endif
#
ifdef
RELU
...
...
src/operators/kernel/cl/cl_kernel/conv_add_kernel.cl
浏览文件 @
6df2ad4a
...
...
@@ -56,17 +56,19 @@ __kernel void conv_3x3(__private const int global_size_dim0,
in_pos_in_one_block.x
=
ouput_pos_in_one_block.x
*
stride
+
offset
;
in_pos_in_one_block.y
=
ouput_pos_in_one_block.y
*
stride
+
offset
;
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
|
CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
#
ifdef
BIASE
half4
output
=
read_imageh
(
bias,
sampler,
int2
(
out_c,
0
))
;
half4
output
=
read_imageh
(
bias,
sampler,
(
int2
)
(
out_c,
0
))
;
#
else
half4
output
=
0.0f
;
#
endif
half4
input[9]
;
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
|
CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
for
(
int
i
=
0
; i < input_c; ++i) {
int2
pos_in
=
(
int2
)(
i
*
input_width
+
in_pos_in_one_block.x,
in_pos_in_one_block.y
)
;
...
...
@@ -137,7 +139,7 @@ __kernel void conv_3x3(__private const int global_size_dim0,
}
#ifdef BATCH_NORM
output = output * read_imageh(new_scale, sampler,
int2(out_c, 0)) + read_imageh(new_biase, sampler, int2(out_c, 0))
output = output * read_imageh(new_scale, sampler,
(int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0));
#endif
#ifdef RELU
...
...
@@ -248,7 +250,7 @@ __kernel void depth_conv_3x3(__private const int global_size_dim0,
}
#ifdef BATCH_NORM
output = output * read_imageh(new_scale, sampler, (int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0))
output = output * read_imageh(new_scale, sampler, (int2)(out_c, 0)) + read_imageh(new_biase, sampler, (int2)(out_c, 0))
;
#endif
#ifdef RELU
...
...
@@ -319,7 +321,7 @@ __kernel void conv_1x1(__private const int global_size_dim0,
}
#
ifdef
BATCH_NORM
output
=
output
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
output
=
output
*
read_imageh
(
new_scale,
sampler,
(
int2
)(
out_c,
0
))
+
read_imageh
(
new_biase,
sampler,
(
int2
)(
out_c,
0
))
;
#
endif
#
ifdef
RELU
...
...
src/operators/kernel/cl/conv_add_bn_relu_kernel.cpp
浏览文件 @
6df2ad4a
...
...
@@ -117,7 +117,7 @@ void ConvAddBNReluKernel<GPU_CL, float>::Compute(
auto
biase
=
param
.
Bias
()
->
GetCLImage
();
auto
new_scale
=
param
.
NewScale
()
->
GetCLImage
();
auto
new_bias
=
param
.
NewBias
()
->
GetCLImage
();
auto
output
=
param
.
Output
();
auto
output
=
param
.
Output
()
->
GetCLImage
()
;
int
stride
=
param
.
Strides
()[
0
];
int
offset
=
param
.
Offset
();
int
input_c
=
param
.
Input
()
->
CBlock
();
...
...
test/net/test_mobilenet_GPU.cpp
浏览文件 @
6df2ad4a
...
...
@@ -23,7 +23,7 @@ int main() {
// auto isok = paddle_mobile.Load(std::string(g_mobilenet_detect) + "/model",
// std::string(g_mobilenet_detect) + "/params", true);
auto
isok
=
paddle_mobile
.
Load
(
g_mobilenet
,
fals
e
);
auto
isok
=
paddle_mobile
.
Load
(
g_mobilenet
,
tru
e
);
if
(
isok
)
{
auto
time2
=
paddle_mobile
::
time
();
std
::
cout
<<
"load cost :"
<<
paddle_mobile
::
time_diff
(
time1
,
time1
)
<<
"ms"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录