Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
7ad87bee
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ad87bee
编写于
3月 02, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix activation opencl tuning key bug.
上级
5501056d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
11 deletion
+9
-11
mace/kernels/activation.h
mace/kernels/activation.h
+1
-0
mace/kernels/opencl/activation_opencl.cc
mace/kernels/opencl/activation_opencl.cc
+8
-11
未找到文件。
mace/kernels/activation.h
浏览文件 @
7ad87bee
...
...
@@ -135,6 +135,7 @@ class ActivationFunctor<DeviceType::OPENCL, T> {
T
relux_max_limit_
;
T
prelu_alpha_
;
cl
::
Kernel
kernel_
;
std
::
string
tuning_key_prefix_
;
};
}
// namespace kernels
...
...
mace/kernels/opencl/activation_opencl.cc
浏览文件 @
7ad87bee
...
...
@@ -22,7 +22,6 @@ void ActivationFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
const
index_t
channels
=
input
->
dim
(
3
);
const
index_t
channel_blocks
=
RoundUpDiv4
(
channels
);
std
::
string
tuning_key_prefix
;
if
(
kernel_
.
get
()
==
nullptr
)
{
auto
runtime
=
OpenCLRuntime
::
Global
();
...
...
@@ -35,23 +34,23 @@ void ActivationFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
built_options
.
emplace
(
"-DCMD_DATA_TYPE="
+
DtToUpstreamCLCMDDt
(
dt
));
switch
(
activation_
)
{
case
RELU
:
tuning_key_prefix
=
"relu_opencl_kernel_"
;
tuning_key_prefix
_
=
"relu_opencl_kernel_"
;
built_options
.
emplace
(
"-DUSE_RELU"
);
break
;
case
RELUX
:
tuning_key_prefix
=
"relux_opencl_kernel_"
;
tuning_key_prefix
_
=
"relux_opencl_kernel_"
;
built_options
.
emplace
(
"-DUSE_RELUX"
);
break
;
case
PRELU
:
tuning_key_prefix
=
"prelu_opencl_kernel_"
;
tuning_key_prefix
_
=
"prelu_opencl_kernel_"
;
built_options
.
emplace
(
"-DUSE_PRELU"
);
break
;
case
TANH
:
tuning_key_prefix
=
"tanh_opencl_kernel_"
;
tuning_key_prefix
_
=
"tanh_opencl_kernel_"
;
built_options
.
emplace
(
"-DUSE_TANH"
);
break
;
case
SIGMOID
:
tuning_key_prefix
=
"sigmoid_opencl_kernel_"
;
tuning_key_prefix
_
=
"sigmoid_opencl_kernel_"
;
built_options
.
emplace
(
"-DUSE_SIGMOID"
);
break
;
default:
...
...
@@ -60,12 +59,10 @@ void ActivationFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
kernel_
=
runtime
->
BuildKernel
(
"activation"
,
kernel_name
,
built_options
);
int
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
static_cast
<
float
>
(
relux_max_limit_
));
kernel_
.
setArg
(
idx
++
,
static_cast
<
float
>
(
prelu_alpha_
));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
())));
}
const
uint32_t
gws
[
3
]
=
{
static_cast
<
uint32_t
>
(
channel_blocks
),
...
...
@@ -73,7 +70,7 @@ void ActivationFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
static_cast
<
uint32_t
>
(
height
*
batch
)};
const
std
::
vector
<
uint32_t
>
lws
=
{
8
,
16
,
8
,
1
};
std
::
string
tuning_key
=
Concat
(
tuning_key_prefix
,
output
->
dim
(
0
),
output
->
dim
(
1
),
Concat
(
tuning_key_prefix
_
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录