Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
15d7e8b3
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看板
提交
15d7e8b3
编写于
2月 13, 2020
作者:
alinag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reduce Eigen transformation
test=develop
上级
5cf46e90
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
31 deletion
+31
-31
lite/kernels/x86/reduce_op_function.h
lite/kernels/x86/reduce_op_function.h
+31
-31
未找到文件。
lite/kernels/x86/reduce_op_function.h
浏览文件 @
15d7e8b3
...
...
@@ -46,40 +46,40 @@ void ReduceFunctor(const lite::Tensor& input,
lite
::
Tensor
*
output
,
const
std
::
vector
<
int
>&
dims
,
bool
keep_dim
)
{
auto
x
=
EigenTensor
<
T
,
D
>::
From
(
input
);
auto
reduce_dim
=
Eigen
::
array
<
int
,
R_D
>
();
auto
x_rank
=
static_cast
<
int
>
(
x
.
dimensions
().
size
());
for
(
size_t
i
=
0
;
i
<
dims
.
size
();
++
i
)
{
if
(
dims
[
i
]
<
0
)
{
reduce_dim
[
i
]
=
x_rank
+
dims
[
i
];
}
else
{
reduce_dim
[
i
]
=
dims
[
i
];
auto
te
=
strstr
(
typeid
(
Functor
).
name
(),
"SumFunctor"
);
if
(
D
==
3
&&
R_D
==
1
&&
te
!=
NULL
)
{
const
lite
::
DDim
&
input_dims
=
input
.
dims
();
const
T
*
input_data
=
input
.
data
<
T
>
();
T
*
output_data
=
output
->
mutable_data
<
T
>
();
for
(
int
i
=
0
;
i
<
input_dims
[
0
];
i
++
)
{
for
(
int
k
=
0
;
k
<
input_dims
[
2
];
k
++
)
{
int
out_d
=
i
*
input_dims
[
2
]
+
k
;
T
output_temp
=
0
;
for
(
int
j
=
0
;
j
<
input_dims
[
1
];
j
++
)
{
int
input_d
=
i
*
input_dims
[
1
]
*
input_dims
[
2
]
+
j
*
input_dims
[
2
]
+
k
;
output_temp
=
output_temp
+
input_data
[
input_d
];
}
output_data
[
out_d
]
=
output_temp
;
}
}
}
Functor
functor
;
if
(
D
==
1
)
{
auto
out
=
EigenScalar
<
T
>::
From
(
output
);
functor
(
&
x
,
&
out
,
reduce_dim
);
}
else
{
auto
te
=
strstr
(
typeid
(
Functor
).
name
(),
"SumFunctor"
);
if
(
D
==
3
&&
R_D
==
1
&&
te
!=
NULL
)
{
const
lite
::
DDim
&
input_dims
=
input
.
dims
();
const
T
*
input_data
=
input
.
data
<
T
>
();
T
*
output_data
=
output
->
mutable_data
<
T
>
();
for
(
int
i
=
0
;
i
<
input_dims
[
0
];
i
++
)
{
for
(
int
k
=
0
;
k
<
input_dims
[
2
];
k
++
)
{
int
out_d
=
i
*
input_dims
[
2
]
+
k
;
T
output_temp
=
0
;
for
(
int
j
=
0
;
j
<
input_dims
[
1
];
j
++
)
{
int
input_d
=
i
*
input_dims
[
1
]
*
input_dims
[
2
]
+
j
*
input_dims
[
2
]
+
k
;
output_temp
=
output_temp
+
input_data
[
input_d
];
}
output_data
[
out_d
]
=
output_temp
;
}
auto
x
=
EigenTensor
<
T
,
D
>::
From
(
input
);
auto
reduce_dim
=
Eigen
::
array
<
int
,
R_D
>
();
auto
x_rank
=
static_cast
<
int
>
(
x
.
dimensions
().
size
());
for
(
size_t
i
=
0
;
i
<
dims
.
size
();
++
i
)
{
if
(
dims
[
i
]
<
0
)
{
reduce_dim
[
i
]
=
x_rank
+
dims
[
i
];
}
else
{
reduce_dim
[
i
]
=
dims
[
i
];
}
}
Functor
functor
;
if
(
D
==
1
)
{
auto
out
=
EigenScalar
<
T
>::
From
(
output
);
functor
(
&
x
,
&
out
,
reduce_dim
);
}
else
{
auto
out
=
EigenTensor
<
T
,
(
D
-
R_D
)
>::
From
(
*
output
,
output
->
dims
());
functor
(
&
x
,
&
out
,
reduce_dim
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录