Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
4be0678b
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
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看板
提交
4be0678b
编写于
2月 26, 2020
作者:
alinag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine methods of reduce sum
test=develop
上级
0fcf3774
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
23 addition
and
57 deletion
+23
-57
lite/tests/kernels/reduce_sum_compute_test.cc
lite/tests/kernels/reduce_sum_compute_test.cc
+23
-57
未找到文件。
lite/tests/kernels/reduce_sum_compute_test.cc
浏览文件 @
4be0678b
...
@@ -119,55 +119,32 @@ void reduce_sum_w(const float* src,
...
@@ -119,55 +119,32 @@ void reduce_sum_w(const float* src,
}
}
}
}
void
reduce_sum_c
(
void
reduce_sum
(
const
float
*
src
,
float
*
dst
,
const
DDim
&
x_dim
,
int
dims
)
{
const
float
*
src
,
float
*
dst
,
int
channel_in
,
int
height_in
,
int
width_in
)
{
int
reduce_b
[
3
]
=
{
1
,
1
,
1
};
int
hw_size
=
height_in
*
width_in
;
reduce_b
[
dims
]
=
0
;
int
data_index
,
src_index
;
DDim
reduce_dim
{
x_dim
};
for
(
int
h
=
0
;
h
<
height_in
;
++
h
)
{
reduce_dim
[
dims
]
=
1
;
for
(
int
w
=
0
;
w
<
width_in
;
++
w
)
{
int
dim_size
=
1
;
data_index
=
h
*
width_in
+
w
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
dst
[
data_index
]
=
0.0
;
if
(
i
!=
dims
)
{
for
(
int
n
=
0
;
n
<
channel_in
;
++
n
)
{
dim_size
*=
x_dim
[
i
];
src_index
=
n
*
hw_size
+
data_index
;
dst
[
data_index
]
+=
static_cast
<
float
>
(
src
[
src_index
]);
}
}
}
}
for
(
int
i
=
0
;
i
<
dim_size
;
i
++
)
{
dst
[
i
]
=
0.0
;
}
}
}
for
(
int
i
=
0
;
i
<
x_dim
[
0
];
i
++
)
{
void
reduce_sum_h
(
for
(
int
j
=
0
;
j
<
x_dim
[
1
];
j
++
)
{
const
float
*
src
,
float
*
dst
,
int
channel_in
,
int
height_in
,
int
width_in
)
{
for
(
int
k
=
0
;
k
<
x_dim
[
2
];
k
++
)
{
int
hw_size
=
height_in
*
width_in
;
int
src_index
=
i
*
x_dim
[
1
]
*
x_dim
[
2
]
+
j
*
x_dim
[
2
]
+
k
;
int
data_index
,
src_index0
,
src_index
;
int
dst_index
=
i
*
reduce_dim
[
1
]
*
reduce_dim
[
2
]
*
reduce_b
[
0
]
+
for
(
int
c
=
0
;
c
<
channel_in
;
++
c
)
{
j
*
reduce_dim
[
2
]
*
reduce_b
[
1
]
+
k
*
reduce_b
[
2
];
for
(
int
w
=
0
;
w
<
width_in
;
++
w
)
{
dst
[
dst_index
]
+=
static_cast
<
float
>
(
src
[
src_index
]);
data_index
=
c
*
width_in
+
w
;
src_index0
=
c
*
hw_size
+
w
;
dst
[
data_index
]
=
0.0
;
for
(
int
h
=
0
;
h
<
height_in
;
++
h
)
{
src_index
=
src_index0
+
h
*
width_in
;
dst
[
data_index
]
+=
static_cast
<
float
>
(
src
[
src_index
]);
}
}
}
}
void
reduce_sum_w
(
const
float
*
src
,
float
*
dst
,
int
channel_in
,
int
height_in
,
int
width_in
)
{
int
hw_size
=
height_in
*
width_in
;
int
data_index
=
0
;
int
src_index0
=
0
;
int
src_index
=
0
;
for
(
int
c
=
0
;
c
<
channel_in
;
++
c
)
{
for
(
int
h
=
0
;
h
<
height_in
;
++
h
)
{
data_index
=
c
*
height_in
+
h
;
src_index0
=
c
*
hw_size
+
h
*
width_in
;
dst
[
data_index
]
=
0.0
;
for
(
int
w
=
0
;
w
<
width_in
;
++
w
)
{
src_index
=
src_index0
+
w
;
dst
[
data_index
]
+=
static_cast
<
float
>
(
src
[
src_index
]);
}
}
}
}
}
}
}
}
void
reduce_sum_all
(
const
float
*
src
,
void
reduce_sum_all
(
const
float
*
src
,
float
*
dst
,
float
*
dst
,
int
num_in
,
int
num_in
,
...
@@ -341,21 +318,10 @@ class ReduceSumComputeTester : public arena::TestCase {
...
@@ -341,21 +318,10 @@ class ReduceSumComputeTester : public arena::TestCase {
}
}
}
}
}
else
{
}
else
{
int
in_c
=
x_dims_
[
0
];
int
in_h
=
x_dims_
[
1
];
int
in_w
=
x_dims_
[
2
];
if
(
dim_
.
size
()
==
1
&&
!
reduce_all_
)
{
if
(
dim_
.
size
()
==
1
&&
!
reduce_all_
)
{
switch
(
dim_
[
0
])
{
if
(
dim_
[
0
]
<
x_dims_
.
size
())
{
case
0
:
reduce_sum
(
x_data
,
out_data
,
x_dims_
,
dim_
[
0
]);
reduce_sum_c
(
x_data
,
out_data
,
in_c
,
in_h
,
in_w
);
}
else
{
break
;
case
1
:
reduce_sum_h
(
x_data
,
out_data
,
in_c
,
in_h
,
in_w
);
break
;
case
2
:
reduce_sum_w
(
x_data
,
out_data
,
in_c
,
in_h
,
in_w
);
break
;
default:
LOG
(
FATAL
)
<<
"error!!!"
;
LOG
(
FATAL
)
<<
"error!!!"
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录