Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
d709c5fc
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,发现更多精彩内容 >>
提交
d709c5fc
编写于
8月 07, 2018
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce arguments to make openmp happy
上级
a3075116
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
16 addition
and
24 deletion
+16
-24
mace/kernels/conv_2d.h
mace/kernels/conv_2d.h
+16
-24
未找到文件。
mace/kernels/conv_2d.h
浏览文件 @
d709c5fc
...
...
@@ -745,20 +745,13 @@ struct Conv2dFunctor<DeviceType::CPU, uint8_t> : Conv2dFunctorBase {
const
index_t
stride_w
,
const
T
zero_point
,
const
int
pad_height
,
const
int
pad_width
,
const
std
::
vector
<
index_t
>
&
out_shape
,
const
index_t
depth
,
T
*
im2col_data
)
{
const
index_t
batches
=
out_shape
[
0
];
const
index_t
out_height
=
out_shape
[
1
];
const
index_t
out_width
=
out_shape
[
2
];
const
index_t
column_len
=
depth
;
const
index_t
in_height
=
in_shape
[
1
];
const
index_t
in_width
=
in_shape
[
2
];
const
index_t
in_channels
=
in_shape
[
3
];
const
index_t
input_row_size
=
in_width
*
in_channels
;
const
index_t
patch_row_size
=
filter_w
*
in_channels
;
const
index_t
input_row_size
=
in_shape
[
2
]
*
in_shape
[
3
];
const
index_t
patch_row_size
=
filter_w
*
in_shape
[
3
];
#pragma omp parallel for collapse(3)
for
(
index_t
b
=
0
;
b
<
batches
;
++
b
)
{
for
(
index_t
h
=
0
;
h
<
out_
height
;
++
h
)
{
for
(
index_t
w
=
0
;
w
<
out_
width
;
++
w
)
{
for
(
index_t
b
=
0
;
b
<
out_shape
[
0
]
;
++
b
)
{
for
(
index_t
h
=
0
;
h
<
out_
shape
[
1
]
;
++
h
)
{
for
(
index_t
w
=
0
;
w
<
out_
shape
[
2
]
;
++
w
)
{
// Reshape a patch of input to column, which is corresponding to
// a column of output(:, column).
const
index_t
ih_begin
=
h
*
stride_h
-
(
pad_height
>>
1
);
...
...
@@ -767,15 +760,15 @@ struct Conv2dFunctor<DeviceType::CPU, uint8_t> : Conv2dFunctorBase {
const
index_t
iw_end
=
iw_begin
+
filter_w
;
// gate height and width to separate padding
const
index_t
ih_begin_gated
=
std
::
max
<
index_t
>
(
0
,
ih_begin
);
const
index_t
ih_end_gated
=
std
::
min
<
index_t
>
(
ih_end
,
in_
height
);
const
index_t
ih_end_gated
=
std
::
min
<
index_t
>
(
ih_end
,
in_
shape
[
1
]
);
const
index_t
iw_begin_gated
=
std
::
max
<
index_t
>
(
0
,
iw_begin
);
const
index_t
iw_end_gated
=
std
::
min
<
index_t
>
(
iw_end
,
in_
width
);
const
index_t
iw_end_gated
=
std
::
min
<
index_t
>
(
iw_end
,
in_
shape
[
2
]
);
const
index_t
pad_top
=
std
::
max
<
index_t
>
(
0
,
-
ih_begin
);
const
index_t
pad_bottom
=
ih_end
-
ih_end_gated
;
const
index_t
pad_left
=
std
::
max
<
index_t
>
(
0
,
-
iw_begin
);
const
index_t
pad_right
=
iw_end
-
iw_end_gated
;
index_t
im2col_column_offset
=
((
b
*
out_
height
+
h
)
*
out_width
+
w
)
*
column_len
;
((
b
*
out_
shape
[
1
]
+
h
)
*
out_shape
[
2
]
+
w
)
*
depth
;
// fill in padding top
if
(
pad_top
>
0
)
{
...
...
@@ -785,16 +778,15 @@ struct Conv2dFunctor<DeviceType::CPU, uint8_t> : Conv2dFunctorBase {
const
index_t
patch_row_size_gated
=
std
::
min
(
filter_w
-
pad_left
,
in_
width
-
iw_begin_gated
)
*
in_channels
;
in_
shape
[
2
]
-
iw_begin_gated
)
*
in_shape
[
3
]
;
MACE_CHECK
(
patch_row_size_gated
==
((
filter_w
-
(
pad_left
+
pad_right
))
*
in_
channels
));
const
index_t
pad_left_size
=
pad_left
*
in_
channels
;
const
index_t
pad_right_size
=
pad_right
*
in_
channels
;
((
filter_w
-
(
pad_left
+
pad_right
))
*
in_
shape
[
3
]
));
const
index_t
pad_left_size
=
pad_left
*
in_
shape
[
3
]
;
const
index_t
pad_right_size
=
pad_right
*
in_
shape
[
3
]
;
index_t
im2col_offset
=
im2col_column_offset
+
(
pad_top
*
filter_w
+
pad_left
)
*
in_channels
;
index_t
in_offset
=
((
b
*
in_height
+
ih_begin_gated
)
*
in_width
+
iw_begin_gated
)
*
in_channels
;
(
pad_top
*
filter_w
+
pad_left
)
*
in_shape
[
3
];
index_t
in_offset
=
((
b
*
in_shape
[
1
]
+
ih_begin_gated
)
*
in_shape
[
2
]
+
iw_begin_gated
)
*
in_shape
[
3
];
// fill in effective rows
for
(
index_t
ih
=
ih_begin_gated
;
ih
<
ih_end_gated
;
++
ih
)
{
...
...
@@ -820,7 +812,7 @@ struct Conv2dFunctor<DeviceType::CPU, uint8_t> : Conv2dFunctorBase {
if
(
pad_bottom
>
0
)
{
const
index_t
pad_bottom_size
=
pad_bottom
*
patch_row_size
;
const
index_t
bottom_offset
=
im2col_column_offset
+
column_len
-
pad_bottom_size
;
im2col_column_offset
+
depth
-
pad_bottom_size
;
std
::
fill_n
(
im2col_data
+
bottom_offset
,
pad_bottom_size
,
zero_point
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录