Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d341fccb
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看板
未验证
提交
d341fccb
编写于
7月 14, 2020
作者:
Y
ysh329
提交者:
GitHub
7月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[OPENCL] remove conv redundant's for opencl kernel. test=develop (#3924)
remove conv redundant's for opencl kernel.
上级
4780849f
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
867 addition
and
1433 deletion
+867
-1433
lite/backends/opencl/cl_context.cc
lite/backends/opencl/cl_context.cc
+2
-2
lite/backends/opencl/cl_context.h
lite/backends/opencl/cl_context.h
+2
-2
lite/backends/opencl/cl_kernel/image/conv2d_1x1_opt_kernel.cl
.../backends/opencl/cl_kernel/image/conv2d_1x1_opt_kernel.cl
+0
-4
lite/backends/opencl/cl_kernel/image/conv2d_3x3_kernel.cl
lite/backends/opencl/cl_kernel/image/conv2d_3x3_kernel.cl
+0
-2
lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl
.../backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl
+0
-4
lite/backends/opencl/cl_kernel/image/conv2d_5x5_kernel.cl
lite/backends/opencl/cl_kernel/image/conv2d_5x5_kernel.cl
+0
-2
lite/backends/opencl/cl_kernel/image/conv2d_5x5_opt_kernel.cl
.../backends/opencl/cl_kernel/image/conv2d_5x5_opt_kernel.cl
+1
-5
lite/backends/opencl/cl_kernel/image/conv2d_7x7_kernel.cl
lite/backends/opencl/cl_kernel/image/conv2d_7x7_kernel.cl
+0
-2
lite/backends/opencl/cl_kernel/image/conv2d_7x7_opt_kernel.cl
.../backends/opencl/cl_kernel/image/conv2d_7x7_opt_kernel.cl
+1
-5
lite/backends/opencl/cl_kernel/image/depthwise_conv2d_basic_kernel.cl
...s/opencl/cl_kernel/image/depthwise_conv2d_basic_kernel.cl
+0
-2
lite/backends/opencl/cl_kernel/image/depthwise_conv2d_kernel.cl
...ackends/opencl/cl_kernel/image/depthwise_conv2d_kernel.cl
+0
-4
lite/kernels/opencl/conv_image_compute.cc
lite/kernels/opencl/conv_image_compute.cc
+788
-1387
lite/kernels/opencl/conv_image_compute.h
lite/kernels/opencl/conv_image_compute.h
+73
-12
未找到文件。
lite/backends/opencl/cl_context.cc
浏览文件 @
d341fccb
...
...
@@ -119,7 +119,7 @@ cl::NDRange CLContext::DefaultWorkSize(const CLImage &image) {
}
}
cl
::
NDRange
CLContext
::
LocalWorkSizeTu
rn
(
cl
::
NDRange
global_work_size
,
cl
::
NDRange
CLContext
::
LocalWorkSizeTu
ne
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divisor
)
{
int
preferred_lws
=
0
;
...
...
@@ -157,7 +157,7 @@ cl::NDRange CLContext::LocalWorkSizeTurn(cl::NDRange global_work_size,
static_cast
<
size_t
>
(
gws0
)};
#endif
}
cl
::
NDRange
CLContext
::
LocalWorkSizeTu
rn
Reverse
(
cl
::
NDRange
global_work_size
,
cl
::
NDRange
CLContext
::
LocalWorkSizeTu
ne
Reverse
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divisor
)
{
int
preferred_lws
=
0
;
...
...
lite/backends/opencl/cl_context.h
浏览文件 @
d341fccb
...
...
@@ -62,10 +62,10 @@ class CLContext {
cl
::
NDRange
LocalWorkSize
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
);
cl
::
NDRange
LocalWorkSizeTu
rn
(
cl
::
NDRange
global_work_size
,
cl
::
NDRange
LocalWorkSizeTu
ne
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divitor
=
2
);
cl
::
NDRange
LocalWorkSizeTu
rn
Reverse
(
cl
::
NDRange
global_work_size
,
cl
::
NDRange
LocalWorkSizeTu
ne
Reverse
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divitor
=
2
);
bool
IsArmMali
();
...
...
lite/backends/opencl/cl_kernel/image/conv2d_1x1_opt_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -6,9 +6,7 @@ __kernel void conv2d_1x1_opt(
__private
const
int
global_size_dim2,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
#
ifdef
BATCH_NORM
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_biase,
...
...
@@ -284,9 +282,7 @@ __kernel void conv2d_1x1_simple(
__private
const
int
global_size_dim2,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter,
#if defined(BIASE_CH) || defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
#
ifdef
BATCH_NORM
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_biase,
...
...
lite/backends/opencl/cl_kernel/image/conv2d_3x3_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -19,9 +19,7 @@ __kernel void conv2d_3x3(__private const int global_size_dim0,
__private
const
int
global_size_dim2,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
__write_only
image2d_t
output_image,
__private
const
int
stride,
__private
const
int
offset,
...
...
lite/backends/opencl/cl_kernel/image/conv2d_3x3_opt_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -19,9 +19,7 @@ __kernel void conv2d_3x3_opt(__private const int item_ch,
__private
const
int
item_h,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter_image,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
__write_only
image2d_t
output_image,
__private
const
int
stride,
__private
const
int
pad,
...
...
@@ -264,9 +262,7 @@ __kernel void conv2d_3x3_multi_batch(__private const int item_ch,
__private const int item_h,
__read_only image2d_t input_image,
__read_only image2d_t filter_image,
#if defined(BIASE_CH) || defined(BIASE_ELE)
__read_only image2d_t bias,
#endif
__write_only image2d_t output_image,
__private const int stride,
__private const int pad,
...
...
lite/backends/opencl/cl_kernel/image/conv2d_5x5_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -5,9 +5,7 @@ __kernel void conv2d_5x5(__private const int global_size_dim0,
__private
const
int
global_size_dim2,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter_image,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
#
ifdef
BATCH_NORM
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_biase,
...
...
lite/backends/opencl/cl_kernel/image/conv2d_5x5_opt_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -20,9 +20,7 @@ __kernel void conv2d_5x5_opt(__private const int item_ch,
__private
const
int
item_h,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter_image,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
__write_only
image2d_t
output_image,
__private
const
int
stride,
__private
const
int
pad,
...
...
@@ -268,9 +266,7 @@ __kernel void conv2d_5x5_multi_batch(__private const int item_ch,
__private const int item_h,
__read_only image2d_t input_image,
__read_only image2d_t filter_image,
#if defined(BIASE_CH) || defined(BIASE_ELE)
__read_only image2d_t bias,
#endif
__write_only image2d_t output_image,
__private const int stride,
__private const int pad,
...
...
@@ -513,4 +509,4 @@ __kernel void conv2d_5x5_multi_batch(__private const int item_ch,
(
int2
)(
out_w_base_id
+
out_w_id4,
item_h_id
)
,
output[4]
)
;
}
}
\ No newline at end of file
}
lite/backends/opencl/cl_kernel/image/conv2d_7x7_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -5,9 +5,7 @@ __kernel void conv2d_7x7(__private const int global_size_dim0,
__private
const
int
global_size_dim2,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter_image,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
#
ifdef
BATCH_NORM
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_biase,
...
...
lite/backends/opencl/cl_kernel/image/conv2d_7x7_opt_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -20,9 +20,7 @@ __kernel void conv2d_7x7_opt(__private const int item_ch,
__private
const
int
item_h,
__read_only
image2d_t
input_image,
__read_only
image2d_t
filter_image,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
__write_only
image2d_t
output_image,
__private
const
int
stride,
__private
const
int
pad,
...
...
@@ -268,9 +266,7 @@ __kernel void conv2d_7x7_multi_batch(__private const int item_ch,
__private const int item_h,
__read_only image2d_t input_image,
__read_only image2d_t filter_image,
#if defined(BIASE_CH) || defined(BIASE_ELE)
__read_only image2d_t bias,
#endif
__write_only image2d_t output_image,
__private const int stride,
__private const int pad,
...
...
@@ -513,4 +509,4 @@ __kernel void conv2d_7x7_multi_batch(__private const int item_ch,
(
int2
)(
out_w_base_id
+
out_w_id4,
item_h_id
)
,
output[4]
)
;
}
}
\ No newline at end of file
}
lite/backends/opencl/cl_kernel/image/depthwise_conv2d_basic_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -19,9 +19,7 @@ __kernel void depth_conv2d(__private const int global_size_dim0,
__private
const
int
global_size_dim2,
__read_only
image2d_t
input,
__read_only
image2d_t
filter,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
#
ifdef
BATCH_NORM
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_biase,
...
...
lite/backends/opencl/cl_kernel/image/depthwise_conv2d_kernel.cl
浏览文件 @
d341fccb
...
...
@@ -20,9 +20,7 @@ __kernel void depth_conv2d_3x3(
__private
const
int
global_size_dim2,
__read_only
image2d_t
input,
__read_only
image2d_t
filter,
#
if
defined
(
BIASE_CH
)
|
| defined(BIASE_ELE)
__read_only
image2d_t
bias,
#endif
__write_only
image2d_t
output_image,
__private
const
int
stride,
__private
const
int
offset,
...
...
@@ -249,9 +247,7 @@ __kernel void depth_conv2d_3x3s1(__private const int ou_ch_blk,
__private const int ou_nh,
__read_only image2d_t input,
__read_only image2d_t filter,
#if defined(BIASE_CH) || defined(BIASE_ELE)
__read_only image2d_t bias,
#endif
__write_only image2d_t output_image,
__private const int stride,
__private const int pad,
...
...
lite/kernels/opencl/conv_image_compute.cc
浏览文件 @
d341fccb
此差异已折叠。
点击以展开。
lite/kernels/opencl/conv_image_compute.h
浏览文件 @
d341fccb
...
...
@@ -33,6 +33,7 @@ namespace paddle {
namespace
lite
{
namespace
kernels
{
namespace
opencl
{
class
ConvImageCompute
:
public
KernelLite
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kImageDefault
)
>
{
...
...
@@ -42,8 +43,11 @@ class ConvImageCompute : public KernelLite<TARGET(kOpenCL),
void
PrepareForRun
()
override
;
void
ReInitWhenNeeded
()
override
;
void
Run
()
override
;
double
Turn
(
int
times
=
5
);
double
Tune
(
int
times
=
5
);
#ifdef LITE_WITH_PROFILE
void
SetProfileRuntimeKernelInfo
(
paddle
::
lite
::
profile
::
OpCharacter
*
ch
)
{
...
...
@@ -56,16 +60,20 @@ class ConvImageCompute : public KernelLite<TARGET(kOpenCL),
#endif
private:
void
Conv2d1x1opt
(
bool
is_turn
=
false
);
void
Conv2d3x3
(
bool
is_turn
=
false
);
void
Conv2d3x3opt
(
bool
is_turn
=
false
);
void
Conv2d5x5
(
bool
is_turn
=
false
);
void
Conv2d5x5opt
(
bool
is_turn
=
false
);
void
Conv2d7x7
(
bool
is_turn
=
false
);
void
Conv2d7x7opt
(
bool
is_turn
=
false
);
void
DepthwiseConv2d3x3s1
(
bool
is_turn
=
false
);
void
DepthwiseConv2d3x3
(
bool
is_turn
=
false
);
void
DepthwiseConv2d
(
bool
is_turn
=
false
);
void
PrintConvInfo
();
void
GetGlobalWorkSize
();
void
Conv2d1x1opt
(
bool
enable_tune
=
false
);
void
Conv2d3x3
(
bool
enable_tune
=
false
);
void
Conv2d3x3opt
(
bool
enable_tune
=
false
);
void
Conv2d5x5
(
bool
enable_tune
=
false
);
void
Conv2d5x5opt
(
bool
enable_tune
=
false
);
void
Conv2d7x7
(
bool
enable_tune
=
false
);
void
Conv2d7x7opt
(
bool
enable_tune
=
false
);
void
DepthwiseConv2d3x3s1
(
bool
enable_tune
=
false
);
void
DepthwiseConv2d3x3
(
bool
enable_tune
=
false
);
void
DepthwiseConv2d
(
bool
enable_tune
=
false
);
param_t
*
conv_param_
{
nullptr
};
kernel_t
impl_
;
std
::
vector
<
std
::
string
>
kernel_func_names_
{};
...
...
@@ -79,19 +87,72 @@ class ConvImageCompute : public KernelLite<TARGET(kOpenCL),
std
::
unique_ptr
<
Tensor
>
tensor_hold_bias_image_
{
nullptr
};
cl
::
NDRange
global_work_size_
=
cl
::
NDRange
{
static_cast
<
size_t
>
(
1
),
static_cast
<
size_t
>
(
1
),
static_cast
<
size_t
>
(
1
)};
// opencl kernel args
int
c_blk_
=
1
;
int
w_blk_
=
1
;
int
nh_blk_
=
1
;
const
cl
::
Image2D
*
input_image_p_
{
nullptr
};
const
cl
::
Image2D
*
filter_image_p_
{
nullptr
};
const
cl
::
Image2D
*
bias_image_p_
{
nullptr
};
const
cl
::
Image2D
*
output_image_p_
{
nullptr
};
int
stride_h_
{
-
1
};
int
stride_w_
{
-
1
};
int
dilation_h_
{
-
1
};
int
dilation_w_
{
-
1
};
int
pad_up_
{
-
1
};
int
pad_down_
{
-
1
};
int
pad_left_
{
-
1
};
int
pad_right_
{
-
1
};
int
offset_
{
-
1
};
int
groups_
{
-
1
};
bool
relu_fused_
{
false
};
bool
has_bias_
{
false
};
int
input_tensor_n_
{
-
1
};
int
input_tensor_c_
{
-
1
};
int
input_tensor_h_
{
-
1
};
int
input_tensor_w_
{
-
1
};
int
input_image_h_
{
-
1
};
int
input_image_w_
{
-
1
};
int
input_c_block_
{
-
1
};
int
output_tensor_n_
{
-
1
};
int
output_tensor_c_
{
-
1
};
int
output_tensor_h_
{
-
1
};
int
output_tensor_w_
{
-
1
};
int
output_image_h_
{
-
1
};
int
output_image_w_
{
-
1
};
int
filter_tensor_n_
{
-
1
};
int
filter_tensor_c_
{
-
1
};
int
filter_tensor_h_
{
-
1
};
int
filter_tensor_w_
{
-
1
};
int
filter_image_h_
{
-
1
};
int
filter_image_w_
{
-
1
};
int
bias_image_h_
{
-
1
};
int
bias_image_w_
{
-
1
};
int
default_c_blk_
=
1
;
int
default_w_blk_
=
1
;
int
default_nh_blk_
=
1
;
// =================
DDim
last_input_dims_
{};
bool
is_first_epoch_for_run_
{
true
};
cl
::
Kernel
kernel_
;
cl_int
status_
;
cl
::
NDRange
local_work_size_
=
cl
::
NDRange
{
static_cast
<
size_t
>
(
1
),
static_cast
<
size_t
>
(
1
),
static_cast
<
size_t
>
(
1
)};
bool
use_lws_
{
true
};
bool
use_tu
rn
_
{
false
};
bool
use_tu
ne
_
{
false
};
};
}
// namespace opencl
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录