Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
977a66fc
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看板
未验证
提交
977a66fc
编写于
9月 20, 2019
作者:
Z
Zhaolong Xing
提交者:
GitHub
9月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. the split op's bug will triger memory optimize pass failed. (#2070)
test=develop
上级
eef7ea0f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
32 deletion
+27
-32
lite/core/mir/memory_optimize_pass.cc
lite/core/mir/memory_optimize_pass.cc
+26
-32
lite/operators/split_op.cc
lite/operators/split_op.cc
+1
-0
未找到文件。
lite/core/mir/memory_optimize_pass.cc
浏览文件 @
977a66fc
...
...
@@ -49,7 +49,9 @@ void MemoryOptimizePass::CollectLifeCycleByDevice(
"equal"
,
"lod_reset"
,
"concat"
,
"graph_op"
};
"graph_op"
,
"feed"
,
"fetch"
};
for
(
auto
*
tmp
:
node
->
inlinks
)
{
CHECK
(
tmp
->
IsStmt
());
std
::
string
op_type
=
tmp
->
AsStmt
().
op_info
()
->
Type
();
...
...
@@ -76,36 +78,23 @@ void MemoryOptimizePass::CollectLifeCycleByDevice(
std
::
vector
<
Node
*>
requires
(
inputs
.
begin
(),
inputs
.
end
());
requires
.
insert
(
requires
.
end
(),
outputs
.
begin
(),
outputs
.
end
());
auto
&
stmt
=
op_node
->
AsStmt
();
// The feed and fetch op's inputs and outputs will not be reused.
if
(
stmt
.
op_info
()
->
Type
()
==
"feed"
||
stmt
.
op_info
()
->
Type
()
==
"fetch"
)
{
for
(
auto
*
node
:
op_node
->
outlinks
)
{
CHECK
(
node
->
IsArg
());
std
::
string
var_name
=
node
->
AsArg
().
name
;
TargetType
target_type
=
node
->
AsArg
().
type
->
target
();
if
(
is_host
(
target_type
))
target_type
=
TARGET
(
kHost
);
(
*
lifecycles
)[
TargetToStr
(
target_type
)].
emplace
(
var_name
,
std
::
make_pair
(
0
,
std
::
numeric_limits
<
int
>::
max
()));
}
}
else
{
for
(
Node
*
node
:
requires
)
{
CHECK
(
node
->
IsArg
());
auto
&
arg
=
node
->
AsArg
();
if
(
arg
.
is_weight
||
arg
.
is_persist
)
continue
;
if
(
!
valid_var
(
node
))
continue
;
std
::
string
var_name
=
arg
.
name
;
TargetType
target_type
=
node
->
AsArg
().
type
->
target
();
if
(
is_host
(
target_type
))
target_type
=
TARGET
(
kHost
);
for
(
Node
*
node
:
requires
)
{
CHECK
(
node
->
IsArg
());
auto
&
arg
=
node
->
AsArg
();
if
(
arg
.
is_weight
||
arg
.
is_persist
)
continue
;
if
(
!
valid_var
(
node
))
continue
;
std
::
string
var_name
=
arg
.
name
;
TargetType
target_type
=
node
->
AsArg
().
type
->
target
();
if
(
is_host
(
target_type
))
target_type
=
TARGET
(
kHost
);
if
(
!
(
*
lifecycles
)[
TargetToStr
(
target_type
)].
count
(
var_name
))
{
(
*
lifecycles
)[
TargetToStr
(
target_type
)].
emplace
(
var_name
,
std
::
make_pair
(
max_lifecycle_
,
max_lifecycle_
));
}
else
{
int
cur_life
=
(
*
lifecycles
)[
TargetToStr
(
target_type
)][
var_name
].
second
;
(
*
lifecycles
)[
TargetToStr
(
target_type
)][
var_name
].
second
=
std
::
max
(
max_lifecycle_
,
cur_life
);
}
if
(
!
(
*
lifecycles
)[
TargetToStr
(
target_type
)].
count
(
var_name
))
{
(
*
lifecycles
)[
TargetToStr
(
target_type
)].
emplace
(
var_name
,
std
::
make_pair
(
max_lifecycle_
,
max_lifecycle_
));
}
else
{
int
cur_life
=
(
*
lifecycles
)[
TargetToStr
(
target_type
)][
var_name
].
second
;
(
*
lifecycles
)[
TargetToStr
(
target_type
)][
var_name
].
second
=
std
::
max
(
max_lifecycle_
,
cur_life
);
}
}
++
max_lifecycle_
;
...
...
@@ -167,6 +156,7 @@ void MemoryOptimizePass::MakeReusePlan(
void
MemoryOptimizePass
::
PerformReusePlan
(
SSAGraph
*
graph
,
const
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
reuse_table
)
{
int
node_append_idx
=
0
;
for
(
auto
&
op_node
:
graph
->
StmtTopologicalOrder
())
{
if
(
!
op_node
->
IsStmt
())
continue
;
auto
&
stmt
=
op_node
->
AsStmt
();
...
...
@@ -190,7 +180,9 @@ void MemoryOptimizePass::PerformReusePlan(
std
::
string
name
=
input_node
->
AsArg
().
name
;
if
(
reuse_table
.
count
(
name
)
&&
reuse_table
.
at
(
name
)
!=
name
)
{
auto
replace_name
=
reuse_table
.
at
(
name
);
input_node
->
AsArg
().
name
=
replace_name
;
input_node
->
AsArg
().
name
=
replace_name
+
"("
+
std
::
to_string
(
node_append_idx
)
+
")"
;
node_append_idx
++
;
}
}
...
...
@@ -212,7 +204,9 @@ void MemoryOptimizePass::PerformReusePlan(
std
::
string
name
=
out_node
->
AsArg
().
name
;
if
(
reuse_table
.
count
(
name
)
&&
reuse_table
.
at
(
name
)
!=
name
)
{
auto
replace_name
=
reuse_table
.
at
(
name
);
out_node
->
AsArg
().
name
=
replace_name
;
out_node
->
AsArg
().
name
=
replace_name
+
"("
+
std
::
to_string
(
node_append_idx
)
+
")"
;
node_append_idx
++
;
}
}
...
...
lite/operators/split_op.cc
浏览文件 @
977a66fc
...
...
@@ -69,6 +69,7 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
auto
input
=
opdesc
.
Input
(
"X"
).
front
();
auto
outs
=
opdesc
.
Output
(
"Out"
);
param_
.
x
=
scope
->
FindVar
(
input
)
->
GetMutable
<
lite
::
Tensor
>
();
param_
.
output
.
clear
();
for
(
auto
var
:
outs
)
{
param_
.
output
.
push_back
(
scope
->
FindVar
(
var
)
->
GetMutable
<
lite
::
Tensor
>
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录