Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1d0f70ae
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1d0f70ae
编写于
7月 30, 2020
作者:
Y
ysh329
提交者:
GitHub
7月 30, 2020
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add opencl tune api for user. test=develop (#4016)
上级
9bd739fb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
42 addition
and
9 deletion
+42
-9
lite/api/paddle_api.cc
lite/api/paddle_api.cc
+12
-0
lite/api/paddle_api.h
lite/api/paddle_api.h
+5
-0
lite/backends/opencl/cl_context.h
lite/backends/opencl/cl_context.h
+2
-0
lite/backends/opencl/cl_runtime.h
lite/backends/opencl/cl_runtime.h
+6
-0
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
+1
-0
lite/kernels/opencl/conv_image_compute.cc
lite/kernels/opencl/conv_image_compute.cc
+15
-8
lite/kernels/opencl/conv_image_compute.h
lite/kernels/opencl/conv_image_compute.h
+1
-1
未找到文件。
lite/api/paddle_api.cc
浏览文件 @
1d0f70ae
...
...
@@ -244,6 +244,18 @@ ConfigBase::ConfigBase(PowerMode mode, int threads) {
#endif
}
void
ConfigBase
::
set_opencl_tune
(
bool
enable_tune
)
{
#ifdef LITE_WITH_OPENCL
if
(
paddle
::
lite_api
::
IsOpenCLBackendValid
())
{
enable_opencl_tune_
=
enable_tune
;
paddle
::
lite
::
CLRuntime
::
Global
()
->
set_auto_tune
(
enable_opencl_tune_
);
#ifdef LITE_WITH_OPENCL
LOG
(
INFO
)
<<
"auto_tune:"
<<
paddle
::
lite
::
CLRuntime
::
Global
()
->
auto_tune
();
#endif
}
#endif
}
void
ConfigBase
::
set_power_mode
(
paddle
::
lite_api
::
PowerMode
mode
)
{
#ifdef LITE_WITH_ARM
lite
::
DeviceInfo
::
Global
().
SetRunMode
(
mode
,
threads_
);
...
...
lite/api/paddle_api.h
浏览文件 @
1d0f70ae
...
...
@@ -124,6 +124,8 @@ class LITE_API ConfigBase {
std
::
string
model_dir_
;
int
threads_
{
1
};
PowerMode
mode_
{
LITE_POWER_NO_BIND
};
// gpu
bool
enable_opencl_tune_
{
false
};
// to save subgraph model for npu/xpu/...
std
::
string
subgraph_model_cache_dir_
{
""
};
int
device_id_
{
0
};
...
...
@@ -139,6 +141,9 @@ class LITE_API ConfigBase {
// set Power_mode
void
set_power_mode
(
PowerMode
mode
);
PowerMode
power_mode
()
const
{
return
mode_
;
}
// set GPU opencl tune
void
set_opencl_tune
(
bool
enable_tune
);
bool
opencl_tune
()
const
{
return
enable_opencl_tune_
;
}
// set subgraph_model_dir
void
set_subgraph_model_cache_dir
(
std
::
string
subgraph_model_cache_dir
)
{
subgraph_model_cache_dir_
=
subgraph_model_cache_dir
;
...
...
lite/backends/opencl/cl_context.h
浏览文件 @
1d0f70ae
...
...
@@ -65,9 +65,11 @@ class CLContext {
cl
::
NDRange
LocalWorkSizeTune
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divitor
=
2
);
cl
::
NDRange
LocalWorkSizeTuneReverse
(
cl
::
NDRange
global_work_size
,
size_t
max_work_size
,
int
divitor
=
2
);
bool
IsArmMali
();
// cl::NDRange LocalWorkSizeConv1x1(cl::NDRange global_work_size,
// size_t max_work_size);
...
...
lite/backends/opencl/cl_runtime.h
浏览文件 @
1d0f70ae
...
...
@@ -91,6 +91,10 @@ class CLRuntime {
return
is_device_avaliable_for_opencl_
;
}
void
set_auto_tune
(
bool
enable_tune
)
{
auto_tune_
=
enable_tune
;
}
bool
auto_tune
()
{
return
auto_tune_
;
}
bool
Init
();
cl
::
Platform
&
platform
();
...
...
@@ -195,6 +199,8 @@ class CLRuntime {
bool
is_cl_runtime_initialized_
{
false
};
bool
is_platform_device_init_success_
{
false
};
bool
auto_tune_
{
false
};
};
}
// namespace lite
...
...
lite/demo/cxx/mobile_light/mobilenetv1_light_api.cc
浏览文件 @
1d0f70ae
...
...
@@ -92,6 +92,7 @@ void RunModel(std::string model_dir,
if (is_opencl_backend_valid) {
// give opencl nb model dir
config.set_model_from_file(model_dir);
config.set_opencl_tune(false); // default is false
} else {
std::cout << "Unsupport opencl nb model." << std::endl;
exit(1);
...
...
lite/kernels/opencl/conv_image_compute.cc
浏览文件 @
1d0f70ae
...
...
@@ -32,16 +32,24 @@ namespace opencl {
void
ConvImageCompute
::
PrepareForRun
()
{
ReInitWhenNeeded
();
auto
&
context
=
ctx_
->
As
<
OpenCLContext
>
();
CHECK
(
context
.
cl_context
()
!=
nullptr
);
const
bool
is_mali
=
context
.
cl_context
()
->
IsArmMali
();
use_tune_
=
CLRuntime
::
Global
()
->
auto_tune
();
if
(
!
is_mali
)
{
use_tune_
=
false
;
}
#ifdef LITE_WITH_LOG
LOG
(
INFO
)
<<
"use_tune_"
<<
use_tune_
;
#endif
auto
filter_dims
=
conv_param_
->
filter
->
dims
();
filter_tensor_n_
=
filter_dims
[
0
];
filter_tensor_c_
=
filter_dims
[
1
];
filter_tensor_h_
=
filter_dims
[
2
];
filter_tensor_w_
=
filter_dims
[
3
];
auto
&
context
=
ctx_
->
As
<
OpenCLContext
>
();
CHECK
(
context
.
cl_context
()
!=
nullptr
);
const
bool
is_mali
=
context
.
cl_context
()
->
IsArmMali
();
auto
paddings
=
*
conv_param_
->
paddings
;
pad_up_
=
paddings
[
0
];
pad_down_
=
paddings
[
1
];
...
...
@@ -65,6 +73,7 @@ void ConvImageCompute::PrepareForRun() {
bool
stride_equal
=
stride_h_
==
stride_w_
;
bool
dilation_equal
=
dilation_h_
==
dilation_w_
;
#ifdef LITE_WITH_LOG
VLOG
(
3
)
<<
"Is arm mali / "
<<
(
is_mali
?
"Yes"
:
"No"
);
VLOG
(
3
)
<<
"Is relu fused? / "
<<
(
relu_fused_
?
"Yes"
:
"No"
);
VLOG
(
3
)
<<
"groups:"
<<
groups_
<<
" stride_h_:"
<<
stride_h_
...
...
@@ -83,6 +92,8 @@ void ConvImageCompute::PrepareForRun() {
VLOG
(
3
)
<<
"dilation_equal:"
<<
dilation_equal
;
VLOG
(
3
)
<<
"padding :"
<<
pad_up_
<<
" "
<<
pad_down_
<<
" "
<<
pad_left_
<<
" "
<<
pad_right_
;
#endif
CHECK
(
pad_equal
&&
stride_equal
&&
dilation_equal
);
CHECK_GE
(
conv_param_
->
dilations
->
size
(),
2
);
CHECK
(
dilation_h_
==
dilation_w_
);
...
...
@@ -91,10 +102,6 @@ void ConvImageCompute::PrepareForRun() {
CHECK_GE
(
conv_param_
->
strides
.
size
(),
2
);
CHECK
(
stride_h_
==
stride_w_
);
if
(
!
is_mali
)
{
use_tune_
=
false
;
}
/*********************************************
* Upload filter, bias to opencl device
*********************************************/
...
...
lite/kernels/opencl/conv_image_compute.h
浏览文件 @
1d0f70ae
...
...
@@ -152,7 +152,7 @@ class ConvImageCompute : public KernelLite<TARGET(kOpenCL),
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_tune_
{
tru
e
};
bool
use_tune_
{
fals
e
};
};
}
// namespace opencl
...
...
saxon_zh
@saxon_zh
mentioned in commit
dd3150a4
·
9月 28, 2020
mentioned in commit
dd3150a4
mentioned in commit dd3150a4c89e8b65f4a7ff71b3c4cf038f91c7e7
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录