Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
8499b852
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,发现更多精彩内容 >>
提交
8499b852
编写于
11月 29, 2017
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove the if-clause at conv 3x3 opencl kernel.
上级
ad16a866
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
48 addition
and
49 deletion
+48
-49
mace/kernels/opencl/cl/conv_2d_3x3.cl
mace/kernels/opencl/cl/conv_2d_3x3.cl
+48
-49
未找到文件。
mace/kernels/opencl/cl/conv_2d_3x3.cl
浏览文件 @
8499b852
...
...
@@ -35,11 +35,34 @@ __kernel void conv_2d_3x3(__read_only image2d_t input, /* [c%4 * w * c/4, h * b]
out4
=
out0
;
#
endif
int
w0
=
out_w_blk
-
padding_left
;
int
w1
=
w0
+
out_w_blks
;
int
w2
=
w1
+
out_w_blks
;
int
w3
=
w2
+
out_w_blks
;
int
w4
=
w3
+
out_w_blks
;
#
define
DEFINE_IN_WIDTH
(
i
)
\
in_width##i[1]
=
in_width##i[0]
+
1
; \
in_width##i[2]
=
in_width##i[0]
+
2
; \
in_width##i[0]
=
(
in_width##i[0]
<
0
|
| in_width##i[0] >= in_width) ? (INT_MIN) : in_width##i[0]; \
in_width##i[1] = (in_width##i[1] < 0 || in_width##i[1] >= in_width) ? (INT_MIN) : in_width##i[1]; \
in_width##i[2] = (in_width##i[2] < 0 || in_width##i[2] >= in_width) ? (INT_MIN) : in_width##i[2];
int in_width0[3];
int in_width1[3];
int in_width2[3];
int in_width3[3];
int in_width4[3];
in_width0[0] = out_w_blk - padding_left;
in_width1[0] = in_width0[0] + out_w_blks;
in_width2[0] = in_width1[0] + out_w_blks;
in_width3[0] = in_width2[0] + out_w_blks;
in_width4[0] = in_width3[0] + out_w_blks;
DEFINE_IN_WIDTH(0);
DEFINE_IN_WIDTH(1);
DEFINE_IN_WIDTH(2);
DEFINE_IN_WIDTH(3);
DEFINE_IN_WIDTH(4);
#undef DEFINE_IN_WIDTH
const int batch_idx = out_hb / out_height;
const int height_idx = out_hb % out_height;
...
...
@@ -64,37 +87,12 @@ __kernel void conv_2d_3x3(__read_only image2d_t input, /* [c%4 * w * c/4, h * b]
in_idx
=
in_ch_blk
*
in_width
;
in_width_idx = w0 + width_idx;
//
Judge
the
width
border
for
padding
input.
if (in_width_idx < 0 || in_width_idx >= in_width) {
in0 = 0;
} else {
in0 = READ_IMAGET(input, sampler, (int2)(in_idx + in_width_idx, in_hb[hb_idx]));
}
in_width_idx = w1 + width_idx;
if (in_width_idx < 0 || in_width_idx >= in_width) {
in1 = 0;
} else {
in1 = READ_IMAGET(input, sampler, (int2)(in_idx + in_width_idx, in_hb[hb_idx]));
}
in_width_idx = w2 + width_idx;
if (in_width_idx < 0 || in_width_idx >= in_width) {
in2 = 0;
} else {
in2 = READ_IMAGET(input, sampler, (int2)(in_idx + in_width_idx, in_hb[hb_idx]));
}
in_width_idx = w3 + width_idx;
if (in_width_idx < 0 || in_width_idx >= in_width) {
in3 = 0;
} else {
in3 = READ_IMAGET(input, sampler, (int2)(in_idx + in_width_idx, in_hb[hb_idx]));
}
in_width_idx = w4 + width_idx;
if (in_width_idx < 0 |
|
in_width_idx
>=
in_width
)
{
in4
=
0
;
}
else
{
in4
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width_idx,
in_hb[hb_idx]
))
;
}
in0
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width0[width_idx],
in_hb[hb_idx]
))
;
in1
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width1[width_idx],
in_hb[hb_idx]
))
;
in2
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width2[width_idx],
in_hb[hb_idx]
))
;
in3
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width3[width_idx],
in_hb[hb_idx]
))
;
in4
=
READ_IMAGET
(
input,
sampler,
(
int2
)(
in_idx
+
in_width4[width_idx],
in_hb[hb_idx]
))
;
int
filter_idx
=
(
in_ch_blk
<<
2
)
+
(
hb_idx
*
3
+
width_idx
)
*
rounded_in_ch
;
weights0
=
READ_IMAGET
(
filter,
sampler,
(
int2
)(
filter_idx
+
0
,
out_ch_blk
))
;
...
...
@@ -134,31 +132,32 @@ __kernel void conv_2d_3x3(__read_only image2d_t input, /* [c%4 * w * c/4, h * b]
}
const
int
out_x_base
=
out_ch_blk
*
out_width
;
int
w
=
out_w_blk
;
WRITE_IMAGET
(
output,
(
int2
)(
out_x_base
+
w
0
+
padding_left
,
out_hb
)
,
(
int2
)(
out_x_base
+
w,
out_hb
)
,
out0
)
;
w
1
+=
padding_left
;
if
(
w
1
>=
out_width
)
return
;
w
+=
out_w_blks
;
if
(
w
>=
out_width
)
return
;
WRITE_IMAGET
(
output,
(
int2
)(
out_x_base
+
w
1
,
out_hb
)
,
(
int2
)(
out_x_base
+
w,
out_hb
)
,
out1
)
;
w
2
+=
padding_left
;
if
(
w
2
>=
out_width
)
return
;
w
+=
out_w_blks
;
if
(
w
>=
out_width
)
return
;
WRITE_IMAGET
(
output,
(
int2
)(
out_x_base
+
w
2
,
out_hb
)
,
(
int2
)(
out_x_base
+
w,
out_hb
)
,
out2
)
;
w
3
+=
padding_left
;
if
(
w
3
>=
out_width
)
return
;
w
+=
out_w_blks
;
if
(
w
>=
out_width
)
return
;
WRITE_IMAGET
(
output,
(
int2
)(
out_x_base
+
w
3
,
out_hb
)
,
(
int2
)(
out_x_base
+
w,
out_hb
)
,
out3
)
;
w
4
+=
padding_left
;
if
(
w
4
>=
out_width
)
return
;
w
+=
out_w_blks
;
if
(
w
>=
out_width
)
return
;
WRITE_IMAGET
(
output,
(
int2
)(
out_x_base
+
w
4
,
out_hb
)
,
(
int2
)(
out_x_base
+
w,
out_hb
)
,
out4
)
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录