Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
as350144
Mace
提交
1e51497a
Mace
项目概览
as350144
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
2
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
1e51497a
编写于
9月 18, 2017
作者:
吴
吴承辉
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature_wuch' into 'master'
fix pooling op See merge request !45
上级
4ed6e236
ab17d3bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
52 deletion
+55
-52
mace/kernels/neon/max_pooling_neon_2x2.cc
mace/kernels/neon/max_pooling_neon_2x2.cc
+2
-1
mace/kernels/neon/max_pooling_neon_3x3.cc
mace/kernels/neon/max_pooling_neon_3x3.cc
+1
-1
mace/kernels/pooling.h
mace/kernels/pooling.h
+45
-44
mace/ops/pooling.h
mace/ops/pooling.h
+7
-6
未找到文件。
mace/kernels/neon/max_pooling_neon_2x2.cc
浏览文件 @
1e51497a
...
...
@@ -61,6 +61,8 @@ void PoolingMaxNeonK2x2S2x2(const float *input,
}
}
w
+=
num_vectors
<<
2
;
for
(;
num_vectors
>
0
;
--
num_vectors
)
{
float32x4_t
r00
=
vld1q_f32
(
r0
);
float32x4_t
r10
=
vld1q_f32
(
r1
);
...
...
@@ -79,7 +81,6 @@ void PoolingMaxNeonK2x2S2x2(const float *input,
outptr
+=
4
;
}
w
+=
num_vectors
<<
2
;
for
(;
w
<
out_width
;
++
w
)
{
float
max
=
std
::
numeric_limits
<
float
>::
lowest
();
for
(
int
kh
=
0
;
kh
<
2
;
++
kh
)
{
...
...
mace/kernels/neon/max_pooling_neon_3x3.cc
浏览文件 @
1e51497a
...
...
@@ -71,6 +71,7 @@ void PoolingMaxNeonK3x3S2x2(const float *input,
}
}
w
+=
num_vectors
<<
2
;
float32x4x2_t
row0
=
vld2q_f32
(
r0
);
float32x4x2_t
row1
=
vld2q_f32
(
r1
);
float32x4x2_t
row2
=
vld2q_f32
(
r2
);
...
...
@@ -105,7 +106,6 @@ void PoolingMaxNeonK3x3S2x2(const float *input,
outptr
+=
4
;
}
w
+=
num_vectors
<<
2
;
for
(;
w
<
out_width
;
++
w
)
{
float
max
=
std
::
numeric_limits
<
float
>::
lowest
();
for
(
int
kh
=
0
;
kh
<
3
;
++
kh
)
{
...
...
mace/kernels/pooling.h
浏览文件 @
1e51497a
...
...
@@ -39,10 +39,12 @@ class PoolingFunctor {
index_t
channels
=
output_shape
[
1
];
index_t
height
=
output_shape
[
2
];
index_t
width
=
output_shape
[
3
];
index_t
out_image_size
=
height
*
width
;
index_t
input_channels
=
input_shape
[
1
];
index_t
input_height
=
input_shape
[
2
];
index_t
input_width
=
input_shape
[
3
];
index_t
in_image_size
=
input_height
*
input_width
;
int
kernel_h
=
kernels_
[
0
];
int
kernel_w
=
kernels_
[
1
];
...
...
@@ -57,56 +59,55 @@ class PoolingFunctor {
int
padded_h_start
=
0
-
paddings_
[
0
]
/
2
;
int
padded_w_start
=
0
-
paddings_
[
1
]
/
2
;
if
(
pooling_type_
==
MAX
)
{
#pragma omp parallel for collapse(2)
for
(
int
n
=
0
;
n
<
batch
;
++
n
)
{
for
(
int
c
=
0
;
c
<
channels
;
++
c
)
{
index_t
out_offset
=
n
*
channels
*
height
*
width
+
c
*
height
*
width
;
index_t
in_offset
=
n
*
input_channels
*
input_height
*
input_width
+
c
*
input_height
*
input_width
;
for
(
int
h
=
0
;
h
<
height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
width
;
++
w
)
{
T
sum_or_max
=
0
;
switch
(
pooling_type_
)
{
case
AVG
:
break
;
case
MAX
:
sum_or_max
=
std
::
numeric_limits
<
T
>::
lowest
();
break
;
default:
MACE_CHECK
(
false
,
"Unsupported pooling type: "
,
pooling_type_
);
}
for
(
int
kh
=
0
;
kh
<
kernel_h
;
++
kh
)
{
for
(
int
kw
=
0
;
kw
<
kernel_w
;
++
kw
)
{
int
inh
=
padded_h_start
+
h
*
stride_h
+
dilation_h
*
kh
;
int
inw
=
padded_w_start
+
w
*
stride_w
+
dilation_w
*
kw
;
if
(
inh
>=
0
&&
inh
<
input_height
&&
inw
>=
0
&&
inw
<
input_width
)
{
index_t
input_offset
=
in_offset
+
inh
*
input_width
+
inw
;
switch
(
pooling_type_
)
{
case
AVG
:
sum_or_max
+=
input
[
input_offset
];
break
;
case
MAX
:
sum_or_max
=
std
::
max
(
sum_or_max
,
input
[
input_offset
]);
break
;
default:
MACE_CHECK
(
false
,
"Unsupported pooling type: "
,
pooling_type_
);
for
(
int
b
=
0
;
b
<
batch
;
++
b
)
{
for
(
int
c
=
0
;
c
<
channels
;
++
c
)
{
index_t
out_offset
=
(
b
*
channels
+
c
)
*
out_image_size
;
index_t
in_offset
=
(
b
*
input_channels
+
c
)
*
in_image_size
;
for
(
int
h
=
0
;
h
<
height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
width
;
++
w
)
{
T
max
=
std
::
numeric_limits
<
T
>::
lowest
();
for
(
int
kh
=
0
;
kh
<
kernel_h
;
++
kh
)
{
for
(
int
kw
=
0
;
kw
<
kernel_w
;
++
kw
)
{
int
inh
=
padded_h_start
+
h
*
stride_h
+
dilation_h
*
kh
;
int
inw
=
padded_w_start
+
w
*
stride_w
+
dilation_w
*
kw
;
if
(
inh
>=
0
&&
inh
<
input_height
&&
inw
>=
0
&&
inw
<
input_width
)
{
index_t
input_offset
=
in_offset
+
inh
*
input_width
+
inw
;
max
=
std
::
max
(
max
,
input
[
input_offset
]);
}
}
}
output
[
out_offset
]
=
max
;
out_offset
+=
1
;
}
switch
(
pooling_type_
)
{
case
AVG
:
output
[
out_offset
]
=
sum_or_max
/
(
kernel_h
*
kernel_w
);
break
;
case
MAX
:
output
[
out_offset
]
=
sum_or_max
;
break
;
default:
MACE_CHECK
(
false
,
"Unsupported pooling type: "
,
pooling_type_
);
}
}
}
}
else
if
(
pooling_type_
==
AVG
)
{
#pragma omp parallel for collapse(2)
for
(
int
b
=
0
;
b
<
batch
;
++
b
)
{
for
(
int
c
=
0
;
c
<
channels
;
++
c
)
{
index_t
out_offset
=
(
b
*
channels
+
c
)
*
out_image_size
;
index_t
in_offset
=
(
b
*
input_channels
+
c
)
*
in_image_size
;
for
(
int
h
=
0
;
h
<
height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
width
;
++
w
)
{
T
sum
=
0
;
for
(
int
kh
=
0
;
kh
<
kernel_h
;
++
kh
)
{
for
(
int
kw
=
0
;
kw
<
kernel_w
;
++
kw
)
{
int
inh
=
padded_h_start
+
h
*
stride_h
+
dilation_h
*
kh
;
int
inw
=
padded_w_start
+
w
*
stride_w
+
dilation_w
*
kw
;
if
(
inh
>=
0
&&
inh
<
input_height
&&
inw
>=
0
&&
inw
<
input_width
)
{
index_t
input_offset
=
in_offset
+
inh
*
input_width
+
inw
;
sum
+=
input
[
input_offset
];
}
}
}
output
[
out_offset
]
=
sum
/
(
kernel_h
*
kernel_w
);
out_offset
+=
1
;
}
out_offset
+=
1
;
}
}
}
...
...
mace/ops/pooling.h
浏览文件 @
1e51497a
...
...
@@ -24,16 +24,17 @@ class PoolingOp : public ConvPool2dOpBase<D, T> {
bool
Run
()
override
{
const
Tensor
*
input
=
this
->
Input
(
INPUT
);
Tensor
*
output
=
this
->
Output
(
OUTPUT
);
std
::
vector
<
index_t
>
in_shape
=
input
->
shape
();
std
::
vector
<
index_t
>
output_shape
(
4
);
std
::
vector
<
int
>
paddings
(
2
);
std
::
vector
<
index_t
>
filter_shape
=
std
::
vector
<
index_t
>
(
4
);
filter_shape
[
0
]
=
in
_shape
[
1
];
filter_shape
[
1
]
=
in
_shape
[
0
];
std
::
vector
<
index_t
>
filter_shape
(
4
);
filter_shape
[
0
]
=
in
put
->
shape
()
[
1
];
filter_shape
[
1
]
=
in
put
->
shape
()
[
0
];
filter_shape
[
2
]
=
kernels_
[
0
];
filter_shape
[
3
]
=
kernels_
[
1
];
kernels
::
CalcPaddingAndOutputSize
(
in_shape
.
data
(),
filter_shape
.
data
(),
kernels
::
CalcPaddingAndOutputSize
(
input
->
shape
().
data
(),
filter_shape
.
data
(),
this
->
dilations_
.
data
(),
this
->
strides_
.
data
(),
this
->
padding_
,
output_shape
.
data
(),
paddings
.
data
());
...
...
@@ -42,7 +43,7 @@ class PoolingOp : public ConvPool2dOpBase<D, T> {
auto
pooling_func
=
kernels
::
PoolingFunctor
<
D
,
T
>
(
pooling_type_
,
kernels_
.
data
(),
this
->
strides_
.
data
(),
paddings
.
data
(),
this
->
dilations_
.
data
());
pooling_func
(
input
->
data
<
float
>
(),
in
_shape
.
data
(),
pooling_func
(
input
->
data
<
float
>
(),
in
put
->
shape
()
.
data
(),
output
->
mutable_data
<
float
>
(),
output
->
shape
().
data
());
return
true
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录