Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
25f8d24c
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
338
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
25f8d24c
编写于
8月 05, 2020
作者:
J
jingqinghe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for three-dimentional input in reduce max test=develop
上级
d132b8f3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
161 addition
and
191 deletion
+161
-191
lite/backends/arm/math/reduce_max.cc
lite/backends/arm/math/reduce_max.cc
+36
-36
lite/backends/arm/math/reduce_max.h
lite/backends/arm/math/reduce_max.h
+8
-20
lite/kernels/arm/reduce_max_compute.cc
lite/kernels/arm/reduce_max_compute.cc
+50
-53
lite/tests/kernels/reduce_max_compute_test.cc
lite/tests/kernels/reduce_max_compute_test.cc
+67
-82
未找到文件。
lite/backends/arm/math/reduce_max.cc
浏览文件 @
25f8d24c
...
@@ -47,62 +47,62 @@ void reduce_n<float>(const float* src,
...
@@ -47,62 +47,62 @@ void reduce_n<float>(const float* src,
}
}
template
<
>
template
<
>
void
reduce_first_of_three
<
float
>
(
const
float
*
src
,
void
reduce_first_of_three
<
float
>
(
float
*
dst
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
int
first_in
,
for
(
int
i
=
0
;
i
<
second_in
;
i
++
)
{
int
second_in
,
for
(
int
j
=
0
;
j
<
third_in
;
j
++
)
{
int
third_in
){
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
third_in
+
j
];
for
(
int
i
=
0
;
i
<
second_in
;
i
++
){
for
(
int
k
=
1
;
k
<
first_in
;
k
++
)
{
for
(
int
j
=
0
;
j
<
third_in
;
j
++
){
dst
[
i
*
third_in
+
j
]
=
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
third_in
+
j
];
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
>
for
(
int
k
=
1
;
k
<
first_in
;
k
++
){
dst
[
i
*
third_in
+
j
]
dst
[
i
*
third_in
+
j
]
=
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
>
dst
[
i
*
third_in
+
j
]
?
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
:
dst
[
i
*
third_in
+
j
];
?
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
:
dst
[
i
*
third_in
+
j
];
}
}
}
}
}
}
}
}
template
<
>
template
<
>
void
reduce_second_of_three
<
float
>
(
const
float
*
src
,
void
reduce_second_of_three
<
float
>
(
float
*
dst
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
int
first_in
,
for
(
int
i
=
0
;
i
<
first_in
;
i
++
)
{
int
second_in
,
for
(
int
j
=
0
;
j
<
third_in
;
j
++
)
{
int
third_in
){
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
];
for
(
int
i
=
0
;
i
<
first_in
;
i
++
){
for
(
int
k
=
1
;
k
<
second_in
;
k
++
)
{
for
(
int
j
=
0
;
j
<
third_in
;
j
++
){
dst
[
i
*
third_in
+
j
]
=
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
];
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
>
for
(
int
k
=
1
;
k
<
second_in
;
k
++
){
dst
[
i
*
third_in
+
j
]
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
>
dst
[
i
*
third_in
+
j
]
?
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
:
dst
[
i
*
third_in
+
j
];
?
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
:
dst
[
i
*
third_in
+
j
];
}
}
}
}
}
}
}
}
template
<
>
template
<
>
void
reduce_third_of_three
<
float
>
(
const
float
*
src
,
void
reduce_third_of_three
<
float
>
(
float
*
dst
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
int
first_in
,
for
(
int
i
=
0
;
i
<
first_in
;
i
++
)
{
int
second_in
,
for
(
int
j
=
0
;
j
<
second_in
;
j
++
)
{
int
third_in
){
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
];
for
(
int
i
=
0
;
i
<
first_in
;
i
++
){
for
(
int
k
=
0
;
k
<
third_in
;
k
++
)
{
for
(
int
j
=
0
;
j
<
second_in
;
j
++
){
dst
[
i
*
second_in
+
j
]
=
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
];
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
>
for
(
int
k
=
0
;
k
<
third_in
;
k
++
){
dst
[
i
*
second_in
+
j
]
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
>
dst
[
i
*
second_in
+
j
]
?
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
:
dst
[
i
*
second_in
+
j
];
?
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
:
dst
[
i
*
second_in
+
j
];
}
}
}
}
}
}
}
}
template
<
>
template
<
>
void
reduce_all_of_three
<
float
>
(
const
float
*
src
,
void
reduce_all_of_three
<
float
>
(
float
*
dst
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
int
first_in
,
int
second_in
,
int
third_in
){
float
max
=
src
[
0
];
float
max
=
src
[
0
];
int
total_element
=
first_in
*
second_in
*
third_in
;
int
total_element
=
first_in
*
second_in
*
third_in
;
for
(
int
i
=
0
;
i
<
total_element
;
i
++
)
{
for
(
int
i
=
0
;
i
<
total_element
;
i
++
)
{
max
=
src
[
i
]
>
max
?
src
[
i
]
:
max
;
max
=
src
[
i
]
>
max
?
src
[
i
]
:
max
;
}
}
dst
[
0
]
=
max
;
dst
[
0
]
=
max
;
...
...
lite/backends/arm/math/reduce_max.h
浏览文件 @
25f8d24c
...
@@ -36,32 +36,20 @@ void reduce_c(const T* src,
...
@@ -36,32 +36,20 @@ void reduce_c(const T* src,
int
width_in
);
int
width_in
);
template
<
typename
T
>
template
<
typename
T
>
void
reduce_all_of_three
(
const
T
*
src
,
void
reduce_all_of_three
(
T
*
dst
,
const
T
*
src
,
T
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
);
int
first_in
,
int
second_in
,
int
third_in
);
template
<
typename
T
>
template
<
typename
T
>
void
reduce_first_of_three
(
const
T
*
src
,
void
reduce_first_of_three
(
T
*
dst
,
const
T
*
src
,
T
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
);
int
first_in
,
int
second_in
,
int
third_in
);
template
<
typename
T
>
template
<
typename
T
>
void
reduce_second_of_three
(
const
T
*
src
,
void
reduce_second_of_three
(
T
*
dst
,
const
T
*
src
,
T
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
);
int
first_in
,
int
second_in
,
int
third_in
);
template
<
typename
T
>
template
<
typename
T
>
void
reduce_third_of_three
(
const
T
*
src
,
void
reduce_third_of_three
(
T
*
dst
,
const
T
*
src
,
T
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
);
int
first_in
,
int
second_in
,
int
third_in
);
template
<
typename
T
>
template
<
typename
T
>
void
reduce_h
(
const
T
*
src
,
void
reduce_h
(
const
T
*
src
,
...
...
lite/kernels/arm/reduce_max_compute.cc
浏览文件 @
25f8d24c
...
@@ -25,7 +25,7 @@ void ReduceMaxCompute::Run() {
...
@@ -25,7 +25,7 @@ void ReduceMaxCompute::Run() {
auto
&
param
=
Param
<
operators
::
ReduceMaxParam
>
();
auto
&
param
=
Param
<
operators
::
ReduceMaxParam
>
();
const
float
*
input
=
param
.
X
->
data
<
float
>
();
const
float
*
input
=
param
.
X
->
data
<
float
>
();
auto
x_dims
=
param
.
X
->
dims
();
auto
x_dims
=
param
.
X
->
dims
();
int
x_rank
=
x_dims
.
size
();
int
x_rank
=
x_dims
.
size
();
float
*
output
=
param
.
Out
->
mutable_data
<
float
>
();
float
*
output
=
param
.
Out
->
mutable_data
<
float
>
();
bool
keep_dim
=
param
.
keep_dim
;
bool
keep_dim
=
param
.
keep_dim
;
...
@@ -39,37 +39,33 @@ void ReduceMaxCompute::Run() {
...
@@ -39,37 +39,33 @@ void ReduceMaxCompute::Run() {
}
}
}
}
if
(
x_dims
.
size
()
==
3
){
if
(
x_dims
.
size
()
==
3
)
{
if
(
dim
.
size
()
==
0
||
dim
.
size
()
==
3
){
if
(
dim
.
size
()
==
0
||
dim
.
size
()
==
3
)
{
lite
::
arm
::
math
::
reduce_all_of_three
(
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
lite
::
arm
::
math
::
reduce_all_of_three
(
}
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
else
if
(
dim
.
size
()
==
1
){
}
else
if
(
dim
.
size
()
==
1
)
{
switch
(
dim
[
0
])
switch
(
dim
[
0
])
{
{
case
0
:
case
0
:
lite
::
arm
::
math
::
reduce_first_of_three
(
lite
::
arm
::
math
::
reduce_first_of_three
(
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
break
;
break
;
case
1
:
case
1
:
lite
::
arm
::
math
::
reduce_second_of_three
(
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
lite
::
arm
::
math
::
reduce_second_of_three
(
break
;
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
break
;
case
2
:
case
2
:
lite
::
arm
::
math
::
reduce_third_of_three
(
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
lite
::
arm
::
math
::
reduce_third_of_three
(
break
;
input
,
output
,
x_dims
[
0
],
x_dims
[
1
],
x_dims
[
2
]);
default:
break
;
LOG
(
FATAL
)
<<
"error!!!"
;
default:
LOG
(
FATAL
)
<<
"error!!!"
;
}
}
}
}
else
if
(
dim
.
size
()
==
2
)
{
else
if
(
dim
.
size
()
==
2
){
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"dim size should not larger than 3!!!"
;
LOG
(
FATAL
)
<<
"dim size should not larger than 3!!!"
;
}
}
}
else
if
(
x_dims
.
size
()
==
4
)
{
}
else
if
(
x_dims
.
size
()
==
4
){
int
n_in
=
x_dims
[
0
];
int
n_in
=
x_dims
[
0
];
int
c_in
=
x_dims
[
1
];
int
c_in
=
x_dims
[
1
];
int
h_in
=
x_dims
[
2
];
int
h_in
=
x_dims
[
2
];
...
@@ -78,37 +74,38 @@ void ReduceMaxCompute::Run() {
...
@@ -78,37 +74,38 @@ void ReduceMaxCompute::Run() {
if
(
dim
.
size
()
==
0
)
{
if
(
dim
.
size
()
==
0
)
{
lite
::
arm
::
math
::
reduce_all
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_all
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
}
else
if
(
dim
.
size
()
==
1
)
{
}
else
if
(
dim
.
size
()
==
1
)
{
switch
(
dim
[
0
])
{
switch
(
dim
[
0
])
{
case
0
:
case
0
:
lite
::
arm
::
math
::
reduce_n
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_n
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
break
;
break
;
case
1
:
case
1
:
lite
::
arm
::
math
::
reduce_c
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_c
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
break
;
break
;
case
2
:
case
2
:
lite
::
arm
::
math
::
reduce_h
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_h
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
break
;
break
;
case
3
:
case
3
:
lite
::
arm
::
math
::
reduce_w
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_w
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
break
;
break
;
default:
default:
LOG
(
FATAL
)
<<
"error!!!"
;
LOG
(
FATAL
)
<<
"error!!!"
;
}
}
}
else
if
(
dim
.
size
()
==
2
)
{
}
else
if
(
dim
.
size
()
==
2
)
{
if
(
dim
[
0
]
==
0
&&
dim
[
1
]
==
1
)
{
if
(
dim
[
0
]
==
0
&&
dim
[
1
]
==
1
)
{
lite
::
arm
::
math
::
reduce_nc
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_nc
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
}
else
if
(
dim
[
0
]
==
1
&&
dim
[
1
]
==
2
)
{
}
else
if
(
dim
[
0
]
==
1
&&
dim
[
1
]
==
2
)
{
lite
::
arm
::
math
::
reduce_ch
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_ch
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
}
else
if
(
dim
[
0
]
==
2
&&
dim
[
1
]
==
3
)
{
}
else
if
(
dim
[
0
]
==
2
&&
dim
[
1
]
==
3
)
{
lite
::
arm
::
math
::
reduce_hw
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
lite
::
arm
::
math
::
reduce_hw
(
input
,
output
,
n_in
,
c_in
,
h_in
,
w_in
);
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"invalid dim!!"
;
LOG
(
FATAL
)
<<
"invalid dim!!"
;
}
}
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"dim's size over than 2, which is not supported now!!"
;
LOG
(
FATAL
)
<<
"dim's size over than 2, which is not supported now!!"
;
}
}
}
else
{
LOG
(
FATAL
)
<<
"only support input with 3&4 dimensions now!!"
;
}
}
}
}
}
// namespace arm
}
// namespace arm
...
...
lite/tests/kernels/reduce_max_compute_test.cc
浏览文件 @
25f8d24c
...
@@ -190,71 +190,64 @@ void reduce_hw(const float* src,
...
@@ -190,71 +190,64 @@ void reduce_hw(const float* src,
reduce_w
(
tmp_out
,
dst
,
num_in
,
channel_in
,
1
,
width_in
);
reduce_w
(
tmp_out
,
dst
,
num_in
,
channel_in
,
1
,
width_in
);
}
}
void
reduce_first_of_three
(
const
float
*
src
,
void
reduce_first_of_three
(
float
*
dst
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
int
first_in
,
for
(
int
i
=
0
;
i
<
second_in
;
i
++
)
{
int
second_in
,
for
(
int
j
=
0
;
j
<
third_in
;
j
++
)
{
int
third_in
){
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
third_in
+
j
];
for
(
int
k
=
1
;
k
<
first_in
;
k
++
)
{
for
(
int
i
=
0
;
i
<
second_in
;
i
++
){
dst
[
i
*
third_in
+
j
]
=
for
(
int
j
=
0
;
j
<
third_in
;
j
++
){
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
>
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
third_in
+
j
];
dst
[
i
*
third_in
+
j
]
for
(
int
k
=
1
;
k
<
first_in
;
k
++
){
?
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
dst
[
i
*
third_in
+
j
]
=
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
>
dst
[
i
*
third_in
+
j
]
?
src
[
k
*
second_in
*
third_in
+
i
*
third_in
+
j
]
:
dst
[
i
*
third_in
+
j
];
:
dst
[
i
*
third_in
+
j
];
}
}
}
}
}
}
}
}
void
reduce_second_of_three
(
void
reduce_second_of_three
(
const
float
*
src
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
float
*
dst
,
for
(
int
i
=
0
;
i
<
first_in
;
i
++
)
{
int
first_in
,
for
(
int
j
=
0
;
j
<
third_in
;
j
++
)
{
int
second_in
,
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
];
int
third_in
){
for
(
int
k
=
1
;
k
<
second_in
;
k
++
)
{
dst
[
i
*
third_in
+
j
]
=
for
(
int
i
=
0
;
i
<
first_in
;
i
++
){
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
>
for
(
int
j
=
0
;
j
<
third_in
;
j
++
){
dst
[
i
*
third_in
+
j
]
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
];
?
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
for
(
int
k
=
1
;
k
<
second_in
;
k
++
){
:
dst
[
i
*
third_in
+
j
];
dst
[
i
*
third_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
>
dst
[
i
*
third_in
+
j
]
?
src
[
i
*
second_in
*
third_in
+
third_in
*
k
+
j
]
:
dst
[
i
*
third_in
+
j
];
}
}
}
}
}
}
}
}
void
reduce_third_of_three
(
void
reduce_third_of_three
(
const
float
*
src
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
float
*
dst
,
for
(
int
i
=
0
;
i
<
first_in
;
i
++
)
{
int
first_in
,
for
(
int
j
=
0
;
j
<
second_in
;
j
++
)
{
int
second_in
,
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
];
int
third_in
){
for
(
int
k
=
0
;
k
<
third_in
;
k
++
)
{
dst
[
i
*
second_in
+
j
]
=
for
(
int
i
=
0
;
i
<
first_in
;
i
++
){
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
>
for
(
int
j
=
0
;
j
<
second_in
;
j
++
){
dst
[
i
*
second_in
+
j
]
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
];
?
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
for
(
int
k
=
0
;
k
<
third_in
;
k
++
){
:
dst
[
i
*
second_in
+
j
];
dst
[
i
*
second_in
+
j
]
=
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
>
dst
[
i
*
second_in
+
j
]
?
src
[
i
*
second_in
*
third_in
+
j
*
second_in
+
k
]
:
dst
[
i
*
second_in
+
j
];
}
}
}
}
}
}
}
}
void
reduce_all_of_three
(
void
reduce_all_of_three
(
const
float
*
src
,
const
float
*
src
,
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
)
{
float
*
dst
,
int
first_in
,
int
second_in
,
int
third_in
){
float
max
=
src
[
0
];
float
max
=
src
[
0
];
int
total_element
=
first_in
*
second_in
*
third_in
;
int
total_element
=
first_in
*
second_in
*
third_in
;
for
(
int
i
=
0
;
i
<
total_element
;
i
++
)
{
for
(
int
i
=
0
;
i
<
total_element
;
i
++
)
{
max
=
src
[
i
]
>
max
?
src
[
i
]
:
max
;
max
=
src
[
i
]
>
max
?
src
[
i
]
:
max
;
}
}
dst
[
0
]
=
max
;
dst
[
0
]
=
max
;
}
}
class
ReduceMaxComputeTester
:
public
arena
::
TestCase
{
class
ReduceMaxComputeTester
:
public
arena
::
TestCase
{
protected:
protected:
// common attributes for this op.
// common attributes for this op.
...
@@ -321,37 +314,36 @@ class ReduceMaxComputeTester : public arena::TestCase {
...
@@ -321,37 +314,36 @@ class ReduceMaxComputeTester : public arena::TestCase {
}
}
auto
*
out_data
=
out
->
mutable_data
<
float
>
();
auto
*
out_data
=
out
->
mutable_data
<
float
>
();
if
(
x_dims_
.
size
()
==
3
){
if
(
dim_
.
size
()
==
0
||
dim_
.
size
()
==
3
){
reduce_all_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
}
else
if
(
dim_
.
size
()
==
1
){
switch
(
dim_
[
0
])
{
case
0
:
reduce_first_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
break
;
case
1
:
reduce_second_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
break
;
case
2
:
if
(
x_dims_
.
size
()
==
3
)
{
reduce_third_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
if
(
dim_
.
size
()
==
0
||
dim_
.
size
()
==
3
)
{
break
;
reduce_all_of_three
(
default:
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
LOG
(
FATAL
)
<<
"error!!!"
;
}
else
if
(
dim_
.
size
()
==
1
)
{
switch
(
dim_
[
0
])
{
case
0
:
reduce_first_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
break
;
case
1
:
reduce_second_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
break
;
case
2
:
reduce_third_of_three
(
x_data
,
out_data
,
x_dims_
[
0
],
x_dims_
[
1
],
x_dims_
[
2
]);
break
;
default:
LOG
(
FATAL
)
<<
"error!!!"
;
}
}
}
}
else
if
(
dim_
.
size
()
==
2
)
{
else
if
(
dim_
.
size
()
==
2
){
LOG
(
FATAL
)
<<
"invalid dims_!!"
;
LOG
(
FATAL
)
<<
"invalid dims_!!"
;
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"dim size should not larger than 3!!!"
;
LOG
(
FATAL
)
<<
"dim size should not larger than 3!!!"
;
}
}
}
}
else
if
(
x_dims_
.
size
()
==
4
)
{
else
if
(
x_dims_
.
size
()
==
4
){
int
in_n
=
x_dims_
[
0
];
int
in_n
=
x_dims_
[
0
];
int
in_c
=
x_dims_
[
1
];
int
in_c
=
x_dims_
[
1
];
int
in_h
=
x_dims_
[
2
];
int
in_h
=
x_dims_
[
2
];
...
@@ -384,13 +376,9 @@ class ReduceMaxComputeTester : public arena::TestCase {
...
@@ -384,13 +376,9 @@ class ReduceMaxComputeTester : public arena::TestCase {
reduce_hw
(
x_data
,
out_data
,
in_n
,
in_c
,
in_h
,
in_w
);
reduce_hw
(
x_data
,
out_data
,
in_n
,
in_c
,
in_h
,
in_w
);
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"invalid dims_!!"
;
LOG
(
FATAL
)
<<
"invalid dims_!!"
;
}
}
}
}
}
}
}
}
void
PrepareOpDesc
(
cpp
::
OpDesc
*
op_desc
)
{
void
PrepareOpDesc
(
cpp
::
OpDesc
*
op_desc
)
{
...
@@ -434,26 +422,23 @@ void test_reduce_max(Place place) {
...
@@ -434,26 +422,23 @@ void test_reduce_max(Place place) {
}
}
void
test_reduce_max_for_three
(
Place
place
)
{
void
test_reduce_max_for_three
(
Place
place
)
{
std
::
vector
<
std
::
vector
<
int
>>
reduce_dim
{
std
::
vector
<
std
::
vector
<
int
>>
reduce_dim
{{
0
},
{
1
},
{
2
}};
{
0
},
{
1
},
{
2
}};
for
(
auto
f
:
{
1
,
3
})
{
for
(
auto
f
:
{
1
,
3
})
{
for
(
auto
s
:
{
1
,
2
})
{
for
(
auto
s
:
{
1
,
2
})
{
for
(
auto
t
:
{
1
,
3
})
{
for
(
auto
t
:
{
1
,
3
})
{
for
(
bool
keep_dim
:
{
false
,
true
})
{
for
(
bool
keep_dim
:
{
false
,
true
})
{
for
(
auto
dim
:
reduce_dim
)
{
for
(
auto
dim
:
reduce_dim
)
{
auto
x_dims
=
DDim
(
std
::
vector
<
int64_t
>
({
f
,
s
,
t
}));
auto
x_dims
=
DDim
(
std
::
vector
<
int64_t
>
({
f
,
s
,
t
}));
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
ReduceMaxComputeTester
(
new
ReduceMaxComputeTester
(
place
,
"def"
,
dim
,
keep_dim
,
x_dims
));
place
,
"def"
,
dim
,
keep_dim
,
x_dims
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
2e-5
);
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
2e-5
);
arena
.
TestPrecision
();
arena
.
TestPrecision
();
}
}
}
}
}
}
}
}
}
}
}
}
TEST
(
ReduceMax
,
precision
)
{
TEST
(
ReduceMax
,
precision
)
{
// #ifdef LITE_WITH_X86
// #ifdef LITE_WITH_X86
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录