Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
312239cc
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看板
提交
312239cc
编写于
3月 03, 2020
作者:
Y
Yuan Shuai
提交者:
GitHub
3月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix kernel of conv1x1, fc OOM in opencl buffer kernel. test=develop (#3062)
上级
7788fe08
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
10 deletion
+20
-10
lite/backends/opencl/cl_kernel/buffer/fc_kernel.cl
lite/backends/opencl/cl_kernel/buffer/fc_kernel.cl
+2
-6
lite/kernels/opencl/conv_buffer_compute.cc
lite/kernels/opencl/conv_buffer_compute.cc
+16
-2
lite/kernels/opencl/conv_buffer_compute_test.cc
lite/kernels/opencl/conv_buffer_compute_test.cc
+2
-2
未找到文件。
lite/backends/opencl/cl_kernel/buffer/fc_kernel.cl
浏览文件 @
312239cc
...
...
@@ -91,11 +91,7 @@ void gemm_batch_naive(__global const CL_DTYPE* a,
c0
+=
a0
*
b0
;
}
#
ifdef
RELU
cur_c[row
*
N
+
col]
=
activation
(
c0
)
;
#
else
cur_c[row
*
N
+
col]
=
c0
;
#
endif
}
...
...
@@ -103,7 +99,7 @@ void gemm_batch_naive(__global const CL_DTYPE* a,
//
a:
filter_d
//
b:
x_d
//
c:
output_d
#
if
0
//
TODO
(
ysh239
)
:
cause
CL_OUT_OF_HOST_MEMORY
on
some
devices
(
such
as
snapdragon
855
)
//#define
PRINT_KERNEL
__kernel
void
gemm_batch
(
__global
const
CL_DTYPE*
Aptr,
...
...
@@ -213,7 +209,7 @@ void gemm_batch(__global const CL_DTYPE* Aptr,
}
}
}
#
endif
//
fc_gemv_naive:
keep
for
check
//
used
for
fc
with
M
=
1
...
...
lite/kernels/opencl/conv_buffer_compute.cc
浏览文件 @
312239cc
...
...
@@ -71,7 +71,11 @@ void ConvCompute::PrepareForRun() {
if
(
kernel_h
==
1
&&
kernel_w
==
1
&&
stride_h
==
1
&&
stride_w
==
1
&&
zero_pad
&&
no_dilation
&&
pad_equal
)
{
// conv2d_1x1
/* TODO(ysh329): CL_OUT_OF_MEMORY when use gemm_batched OpenCL kernel,
use gemm_batched_naive instead.
kernel_func_names_.push_back("gemm_batch");
*/
kernel_func_names_
.
push_back
(
"gemm_batch_naive"
);
kernel_func_paths_
.
push_back
(
"buffer/fc_kernel.cl"
);
if
(
relu_fused
)
{
build_options_
.
push_back
(
"-DCL_DTYPE_float -DRELU"
);
...
...
@@ -84,7 +88,11 @@ void ConvCompute::PrepareForRun() {
impl_
=
&
ConvCompute
::
Conv2d1x1
;
}
else
if
(
pad_equal
)
{
kernel_func_names_
.
push_back
(
"im2col"
);
/* TODO(ysh329): CL_OUT_OF_MEMORY when use gemm_batched OpenCL kernel,
use gemm_batched_naive instead.
kernel_func_names_.push_back("gemm_batch");
*/
kernel_func_names_
.
push_back
(
"gemm_batch_naive"
);
kernel_func_paths_
.
push_back
(
"buffer/im2col_kernel.cl"
);
kernel_func_paths_
.
push_back
(
"buffer/fc_kernel.cl"
);
build_options_
.
push_back
(
"-DCL_DTYPE_float"
);
...
...
@@ -258,8 +266,14 @@ void ConvCompute::GemmBatched(cl::Kernel& kernel,
const
int
m
,
const
int
n
,
const
int
k
)
{
auto
global_work_size
=
cl
::
NDRange
{
static_cast
<
size_t
>
((
m
+
7
)
/
8
),
static_cast
<
size_t
>
((
n
+
3
)
/
4
),
/* TODO(ysh329): CL_OUT_OF_MEMORY when use gemm_batch OpenCL kernel,
use gemm_batch_naive instead.
auto global_work_size = cl::NDRange{static_cast<size_t>((m + 7) / 8),
static_cast<size_t>((n + 3) / 4),
static_cast<size_t>(batch_size)};
*/
auto
global_work_size
=
cl
::
NDRange
{
static_cast
<
size_t
>
(
m
),
static_cast
<
size_t
>
(
n
),
static_cast
<
size_t
>
(
batch_size
)};
auto
local_work_size
=
cl
::
NDRange
{
16
,
16
};
// cl::NullRange;
...
...
lite/kernels/opencl/conv_buffer_compute_test.cc
浏览文件 @
312239cc
...
...
@@ -168,7 +168,7 @@ void PrintData(std::string name,
// buffer
// #define PRINT_RESULT
#define LOOP_TEST
//
#define LOOP_TEST
TEST
(
conv2d
,
compute_conv2d_1x1
)
{
// conv2d 1x1 note
// kernel/filter size = 1x1, group = 1, pad = 0, stride = 1, dilation = 1
...
...
@@ -199,7 +199,7 @@ TEST(conv2d, compute_conv2d_1x1) {
// output_dims:1 64 112 112
// filter_dims:64 32 1 1
const
bool
bias_flag
=
true
;
const
bool
relu_flag
=
true
;
const
std
::
string
relu_flag
=
"relu"
;
const
int
batch_size
=
8
;
const
int
oc
=
64
;
const
int
ih
=
112
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录