Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
827e349a
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看板
提交
827e349a
编写于
3月 07, 2020
作者:
J
jameswu2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reshape2-format-modify
上级
6c9aa421
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
55 deletion
+53
-55
mobile/src/operators/kernel/fpga/V1/.fetch_kernel.cpp.swp
mobile/src/operators/kernel/fpga/V1/.fetch_kernel.cpp.swp
+0
-0
mobile/src/operators/kernel/fpga/V1/fetch_kernel.cpp
mobile/src/operators/kernel/fpga/V1/fetch_kernel.cpp
+1
-1
mobile/src/operators/kernel/fpga/V1/reshape2_kernel.cpp
mobile/src/operators/kernel/fpga/V1/reshape2_kernel.cpp
+52
-54
未找到文件。
mobile/src/operators/kernel/fpga/V1/.fetch_kernel.cpp.swp
已删除
100644 → 0
浏览文件 @
6c9aa421
文件已删除
mobile/src/operators/kernel/fpga/V1/fetch_kernel.cpp
浏览文件 @
827e349a
...
...
@@ -80,7 +80,7 @@ void FetchKernel<FPGA, float>::Compute(const FetchParam<FPGA> ¶m) {
auto
output
=
&
param
.
Out
()
->
at
(
col
);
if
(
input
->
type
()
==
type_id
<
float
>
())
{
output
->
ShareDataWith
(
*
input
);
// output dims
equal to
input dim
// output dims
==
input dim
output
->
Resize
(
input
->
dims
());
return
;
}
...
...
mobile/src/operators/kernel/fpga/V1/reshape2_kernel.cpp
浏览文件 @
827e349a
...
...
@@ -92,69 +92,67 @@ void reshape(LoDTensor *input, LoDTensor *output) {
fpga
::
fpga_flush
(
output_ptr
,
Hr
*
WCr_align
*
sizeof
(
half
));
}
static
inline
bool
reshape2_judge
(
const
framework
::
DDim
input_dims
,
const
framework
::
DDim
output_dims
){
int
input_dims_size
=
input_dims
.
size
();
int
output_dims_size
=
out
put_dims
.
size
();
bool
dims_flag2
=
true
;
auto
temp_dims
=
input_dims_size
>
output_dims_size
?
input_dims
:
output_dims
;
int
short_dims
=
input_dims_size
>
output_dims_size
?
output_dims_size
:
input_dims_size
;
for
(
int
i
=
0
;
i
<
temp_dims
.
size
();
++
i
){
if
(
i
<
short_dims
){
if
(
input_dims
[
i
]
!=
output_dims
[
i
]){
dims_flag2
=
false
;
break
;
}
}
else
{
if
(
temp_dims
[
i
]
!=
1
){
dims_flag2
=
false
;
break
;
}
}
}
return
dims_flag2
;
static
inline
bool
reshape2_judge
(
const
framework
::
DDim
input_dims
,
const
framework
::
DDim
output_dims
)
{
int
input_dims_size
=
in
put_dims
.
size
();
int
output_dims_size
=
output_dims
.
size
()
;
bool
dims_flag2
=
true
;
auto
temp_dims
=
input_dims_size
>
output_dims_size
?
input_dims
:
output_dims
;
int
short_dims
=
input_dims_size
>
output_dims_size
?
output_dims_size
:
input_dims_size
;
for
(
int
i
=
0
;
i
<
temp_dims
.
size
();
++
i
)
{
if
(
i
<
short_dims
)
{
if
(
input_dims
[
i
]
!=
output_dims
[
i
])
{
dims_flag2
=
false
;
break
;
}
}
else
{
if
(
temp_dims
[
i
]
!=
1
)
{
dims_flag2
=
false
;
break
;
}
}
}
return
dims_flag2
;
}
template
<
>
void
Reshape2Kernel
<
FPGA
,
float
>::
Compute
(
const
Reshape2Param
<
FPGA
>
&
param
)
{
auto
input
=
const_cast
<
LoDTensor
*>
(
param
.
InputX
());
auto
output
=
param
.
Out
();
auto
shape
=
param
.
Shape
();
auto
num_in
=
framework
::
product
(
input
->
dims
());
auto
num_shape
=
framework
::
product
(
framework
::
make_ddim
(
shape
));
PADDLE_MOBILE_ENFORCE
(
num_shape
!=
0
,
"0 index is not supported"
);
for
(
int
i
=
0
;
i
<
shape
.
size
();
i
++
)
{
if
(
shape
[
i
]
==
-
1
)
{
shape
[
i
]
=
static_cast
<
int
>
(
-
num_in
/
num_shape
);
break
;
auto
input
=
const_cast
<
LoDTensor
*>
(
param
.
InputX
());
auto
output
=
param
.
Out
();
auto
shape
=
param
.
Shape
();
auto
num_in
=
framework
::
product
(
input
->
dims
());
auto
num_shape
=
framework
::
product
(
framework
::
make_ddim
(
shape
));
PADDLE_MOBILE_ENFORCE
(
num_shape
!=
0
,
"0 index is not supported"
);
for
(
int
i
=
0
;
i
<
shape
.
size
();
i
++
)
{
if
(
shape
[
i
]
==
-
1
)
{
shape
[
i
]
=
static_cast
<
int
>
(
-
num_in
/
num_shape
);
break
;
}
}
}
output
->
Resize
(
framework
::
make_ddim
(
shape
));
output
->
Resize
(
framework
::
make_ddim
(
shape
));
auto
input_dims
=
input
->
dims
();
auto
output_dims
=
output
->
dims
();
auto
input_dims
=
input
->
dims
();
auto
output_dims
=
output
->
dims
();
bool
dims_flags
=
input_dims
==
output_dims
;
bool
dims_flag2
=
true
;
bool
dims_flags
=
input_dims
==
output_dims
;
bool
dims_flag2
=
true
;
if
(
!
dims_flags
){
dims_flag2
=
reshape2_judge
(
input_dims
,
output_dims
);
}
if
(
dims_flags
||
dims_flag2
)
{
DLOG
<<
"No need to reshape"
;
output
->
ShareDataWith
(
*
input
);
framework
::
LoD
lod
=
input
->
lod
();
output
->
set_lod
(
lod
);
return
;
}
if
(
!
dims_flags
)
{
dims_flag2
=
reshape2_judge
(
input_dims
,
output_dims
);
}
if
(
dims_flags
||
dims_flag2
)
{
DLOG
<<
"No need to reshape"
;
output
->
ShareDataWith
(
*
input
);
framework
::
LoD
lod
=
input
->
lod
();
output
->
set_lod
(
lod
);
return
;
}
reshape
(
input
,
output
);
reshape
(
input
,
output
);
//
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录