Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
d94a314d
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d94a314d
编写于
2月 18, 2019
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reference. test=develop
上级
591ad33e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
1 addition
and
29 deletion
+1
-29
paddle/fluid/framework/details/memory_optimize_pass.cc
paddle/fluid/framework/details/memory_optimize_pass.cc
+1
-28
paddle/fluid/framework/details/memory_optimize_pass.h
paddle/fluid/framework/details/memory_optimize_pass.h
+0
-1
未找到文件。
paddle/fluid/framework/details/memory_optimize_pass.cc
浏览文件 @
d94a314d
...
@@ -46,7 +46,6 @@ namespace details {
...
@@ -46,7 +46,6 @@ namespace details {
std
::
unique_ptr
<
ir
::
Graph
>
MemoryOptimizePass
::
ApplyImpl
(
std
::
unique_ptr
<
ir
::
Graph
>
MemoryOptimizePass
::
ApplyImpl
(
std
::
unique_ptr
<
ir
::
Graph
>
graph
)
const
{
std
::
unique_ptr
<
ir
::
Graph
>
graph
)
const
{
auto
nodes
=
graph
->
Nodes
();
auto
nodes
=
graph
->
Nodes
();
ClearControlDepVars
(
graph
.
get
());
CollectSkipVarsSet
(
nodes
);
CollectSkipVarsSet
(
nodes
);
cfg_
.
reset
(
new
details
::
ControlFlowGraph
(
*
graph
));
cfg_
.
reset
(
new
details
::
ControlFlowGraph
(
*
graph
));
...
@@ -79,7 +78,7 @@ std::unique_ptr<ir::Graph> MemoryOptimizePass::ApplyImpl(
...
@@ -79,7 +78,7 @@ std::unique_ptr<ir::Graph> MemoryOptimizePass::ApplyImpl(
ir
::
Node
*
cache
=
pool_
.
FindBestFitNode
(
var
);
ir
::
Node
*
cache
=
pool_
.
FindBestFitNode
(
var
);
while
(
cache
!=
nullptr
&&
var
->
Name
()
==
cache
->
Name
())
{
while
(
cache
!=
nullptr
&&
var
->
Name
()
==
cache
->
Name
())
{
VLOG
(
3
)
<<
"The same cache variable is cascade reused. "
VLOG
(
3
)
<<
"The same cache variable is cascade reused. "
<<
var
->
Name
()
<<
" is re-filled to the pool after
"
<<
cache
->
Name
()
<<
" is re-filled to the pool after
"
<<
"the reused op is finished. Current op can not "
<<
"the reused op is finished. Current op can not "
<<
"replace it again. Skip this candidate."
;
<<
"replace it again. Skip this candidate."
;
cache
=
pool_
.
FindNextBestFitNode
(
var
,
cache
);
cache
=
pool_
.
FindNextBestFitNode
(
var
,
cache
);
...
@@ -325,32 +324,6 @@ void MemoryOptimizePass::RenameVarInGraphNode(const std::string& var,
...
@@ -325,32 +324,6 @@ void MemoryOptimizePass::RenameVarInGraphNode(const std::string& var,
}
}
}
}
void
MemoryOptimizePass
::
ClearControlDepVars
(
ir
::
Graph
*
graph
)
const
{
for
(
auto
&
op
:
graph
->
Nodes
())
{
if
(
!
op
->
IsOp
())
continue
;
{
auto
&
nodes
=
op
->
inputs
;
nodes
.
erase
(
std
::
remove_if
(
nodes
.
begin
(),
nodes
.
end
(),
[
&
](
ir
::
Node
*
var
)
{
return
var
->
IsCtrlVar
();
}),
nodes
.
end
());
}
{
auto
&
nodes
=
op
->
outputs
;
nodes
.
erase
(
std
::
remove_if
(
nodes
.
begin
(),
nodes
.
end
(),
[
&
](
ir
::
Node
*
var
)
{
return
var
->
IsCtrlVar
();
}),
nodes
.
end
());
}
}
for
(
auto
&
node
:
graph
->
Nodes
())
{
if
(
node
->
IsCtrlVar
())
{
graph
->
RemoveNode
(
node
);
}
}
}
}
// namespace details
}
// namespace details
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
...
...
paddle/fluid/framework/details/memory_optimize_pass.h
浏览文件 @
d94a314d
...
@@ -48,7 +48,6 @@ class MemoryOptimizePass : public ir::Pass {
...
@@ -48,7 +48,6 @@ class MemoryOptimizePass : public ir::Pass {
void
RenameVarInGraphNode
(
const
std
::
string
&
var
,
void
RenameVarInGraphNode
(
const
std
::
string
&
var
,
const
std
::
string
&
cache_var
,
size_t
idx
,
const
std
::
string
&
cache_var
,
size_t
idx
,
ir
::
Graph
*
graph
)
const
;
ir
::
Graph
*
graph
)
const
;
void
ClearControlDepVars
(
ir
::
Graph
*
graph
)
const
;
void
SubGraphOptimize
(
OpDesc
*
op_desc
)
const
;
void
SubGraphOptimize
(
OpDesc
*
op_desc
)
const
;
// 1. scan op with subblock and collect the output/input vars.
// 1. scan op with subblock and collect the output/input vars.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录