Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
74f5a329
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,发现更多精彩内容 >>
提交
74f5a329
编写于
4月 24, 2018
作者:
B
Bin Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize conv7x7 s1 s2 s3 armv7 neon
上级
6ad006d0
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
693 addition
and
1 deletion
+693
-1
mace/kernels/arm/conv_2d_neon.h
mace/kernels/arm/conv_2d_neon.h
+33
-0
mace/kernels/arm/conv_2d_neon_7x7.cc
mace/kernels/arm/conv_2d_neon_7x7.cc
+573
-0
mace/kernels/conv_2d.h
mace/kernels/conv_2d.h
+83
-0
mace/ops/conv_2d_benchmark.cc
mace/ops/conv_2d_benchmark.cc
+3
-0
mace/ops/conv_2d_test.cc
mace/ops/conv_2d_test.cc
+1
-1
未找到文件。
mace/kernels/arm/conv_2d_neon.h
浏览文件 @
74f5a329
...
...
@@ -51,6 +51,39 @@ extern void Conv2dNeonK3x3S2(const float *input,
const
index_t
out_channels
,
float
*
output
);
extern
void
Conv2dNeonK7x7S1
(
const
float
*
input
,
const
float
*
filter
,
const
index_t
batch
,
const
index_t
in_height
,
const
index_t
in_width
,
const
index_t
in_channels
,
const
index_t
out_height
,
const
index_t
out_width
,
const
index_t
out_channels
,
float
*
output
);
extern
void
Conv2dNeonK7x7S2
(
const
float
*
input
,
const
float
*
filter
,
const
index_t
batch
,
const
index_t
in_height
,
const
index_t
in_width
,
const
index_t
in_channels
,
const
index_t
out_height
,
const
index_t
out_width
,
const
index_t
out_channels
,
float
*
output
);
extern
void
Conv2dNeonK7x7S3
(
const
float
*
input
,
const
float
*
filter
,
const
index_t
batch
,
const
index_t
in_height
,
const
index_t
in_width
,
const
index_t
in_channels
,
const
index_t
out_height
,
const
index_t
out_width
,
const
index_t
out_channels
,
float
*
output
);
}
// namespace kernels
}
// namespace mace
...
...
mace/kernels/arm/conv_2d_neon_7x7.cc
0 → 100644
浏览文件 @
74f5a329
此差异已折叠。
点击以展开。
mace/kernels/conv_2d.h
浏览文件 @
74f5a329
...
...
@@ -224,6 +224,12 @@ struct Conv2dFunctor<DeviceType::CPU, float> : Conv2dFunctorBase {
&&
stride_h
==
2
&&
stride_w
==
2
&&
dilation_h
==
1
&&
dilation_w
==
1
;
bool
use_neon_1x1_s1
=
filter_h
==
1
&&
filter_w
==
1
&&
stride_h
==
1
&&
stride_w
==
1
&&
dilation_h
==
1
&&
dilation_w
==
1
;
bool
use_neon_7x7_s1
=
filter_h
==
7
&&
filter_w
==
7
&&
stride_h
==
1
&&
stride_w
==
1
&&
dilation_h
==
1
&&
dilation_w
==
1
;
bool
use_neon_7x7_s2
=
filter_h
==
7
&&
filter_w
==
7
&&
stride_h
==
2
&&
stride_w
==
2
&&
dilation_h
==
1
&&
dilation_w
==
1
;
bool
use_neon_7x7_s3
=
filter_h
==
7
&&
filter_w
==
7
&&
stride_h
==
3
&&
stride_w
==
3
&&
dilation_h
==
1
&&
dilation_w
==
1
;
std
::
vector
<
index_t
>
transformed_input_shape
;
std
::
vector
<
index_t
>
transformed_output_shape
;
...
...
@@ -288,6 +294,44 @@ struct Conv2dFunctor<DeviceType::CPU, float> : Conv2dFunctorBase {
if
(
extra_input_width
!=
padded_input_width
)
{
pad_right
+=
(
extra_input_width
-
padded_input_width
);
}
}
else
if
(
use_neon_7x7_s1
)
{
extra_output_height
=
height
;
extra_input_height
=
std
::
max
(
padded_input_height
,
extra_output_height
+
6
);
extra_output_width
=
RoundUp
<
index_t
>
(
width
,
4
);
extra_input_width
=
std
::
max
(
padded_input_width
,
extra_output_width
+
6
);
if
(
extra_input_height
!=
padded_input_height
)
{
pad_bottom
+=
(
extra_input_height
-
padded_input_height
);
}
if
(
extra_input_width
!=
padded_input_width
)
{
pad_right
+=
(
extra_input_width
-
padded_input_width
);
}
}
else
if
(
use_neon_7x7_s2
)
{
extra_output_height
=
height
;
extra_input_height
=
std
::
max
(
padded_input_height
,
(
extra_output_height
-
1
)
*
2
+
7
);
extra_output_width
=
RoundUp
<
index_t
>
(
width
,
4
);
extra_input_width
=
std
::
max
(
padded_input_width
,
(
extra_output_width
-
1
)
*
2
+
7
);
if
(
extra_input_height
!=
padded_input_height
)
{
pad_bottom
+=
(
extra_input_height
-
padded_input_height
);
}
if
(
extra_input_width
!=
padded_input_width
)
{
pad_right
+=
(
extra_input_width
-
padded_input_width
);
}
}
else
if
(
use_neon_7x7_s3
)
{
extra_output_height
=
height
;
extra_input_height
=
std
::
max
(
padded_input_height
,
(
extra_output_height
-
1
)
*
3
+
7
);
extra_output_width
=
RoundUp
<
index_t
>
(
width
,
4
);
extra_input_width
=
std
::
max
(
padded_input_width
,
(
extra_output_width
-
1
)
*
3
+
7
);
if
(
extra_input_height
!=
padded_input_height
)
{
pad_bottom
+=
(
extra_input_height
-
padded_input_height
);
}
if
(
extra_input_width
!=
padded_input_width
)
{
pad_right
+=
(
extra_input_width
-
padded_input_width
);
}
}
// decide scratch size before allocate it
...
...
@@ -413,6 +457,45 @@ struct Conv2dFunctor<DeviceType::CPU, float> : Conv2dFunctorBase {
channels
,
pad_output
);
};
}
else
if
(
use_neon_7x7_s1
)
{
conv_func
=
[
=
](
const
float
*
pad_input
,
float
*
pad_output
)
{
Conv2dNeonK7x7S1
(
pad_input
,
filter_data
,
batch
,
extra_input_height
,
extra_input_width
,
input_channels
,
extra_output_height
,
extra_output_width
,
channels
,
pad_output
);
};
}
else
if
(
use_neon_7x7_s2
)
{
conv_func
=
[
=
](
const
float
*
pad_input
,
float
*
pad_output
)
{
Conv2dNeonK7x7S2
(
pad_input
,
filter_data
,
batch
,
extra_input_height
,
extra_input_width
,
input_channels
,
extra_output_height
,
extra_output_width
,
channels
,
pad_output
);
};
}
else
if
(
use_neon_7x7_s3
)
{
conv_func
=
[
=
](
const
float
*
pad_input
,
float
*
pad_output
)
{
Conv2dNeonK7x7S3
(
pad_input
,
filter_data
,
batch
,
extra_input_height
,
extra_input_width
,
input_channels
,
extra_output_height
,
extra_output_width
,
channels
,
pad_output
);
};
}
else
{
conv_func
=
[
=
](
const
float
*
pad_input
,
float
*
pad_output
)
{
Conv2dGeneral
(
pad_input
,
...
...
mace/ops/conv_2d_benchmark.cc
浏览文件 @
74f5a329
...
...
@@ -152,6 +152,9 @@ BM_CONV_2D(1, 64, 32, 32, 5, 5, 1, 1, SAME, 128);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
5
,
5
,
1
,
1
,
SAME
,
128
);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
15
,
1
,
1
,
1
,
SAME
,
128
);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
1
,
15
,
1
,
1
,
SAME
,
128
);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
7
,
7
,
1
,
1
,
SAME
,
128
);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
7
,
7
,
2
,
1
,
SAME
,
128
);
BM_CONV_2D
(
1
,
64
,
32
,
31
,
7
,
7
,
3
,
1
,
SAME
,
128
);
// 3 channels input
BM_CONV_2D
(
1
,
3
,
480
,
480
,
1
,
1
,
1
,
1
,
VALID
,
3
);
...
...
mace/ops/conv_2d_test.cc
浏览文件 @
74f5a329
...
...
@@ -878,7 +878,7 @@ void TestArbitraryPadConvNxN(const std::vector<index_t> &shape,
1e-4
,
1e-4
);
};
for
(
int
kernel_size
:
{
3
,
5
})
{
for
(
int
kernel_size
:
{
3
,
5
,
7
})
{
for
(
int
stride
:
{
2
,
3
})
{
func
(
kernel_size
,
kernel_size
,
stride
,
stride
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录