Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c3949f56
P
Paddle
项目概览
PaddlePaddle
/
Paddle
12 个月 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c3949f56
编写于
5月 20, 2019
作者:
L
liuwei1031
提交者:
GitHub
5月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove two useless flags: enable_subgraph_optimize, memory_optimize_debug, test=develop (#17491)
上级
f82e4d75
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
113 deletion
+4
-113
paddle/fluid/framework/ir/memory_optimize_pass/inplace_op_pass.cc
...luid/framework/ir/memory_optimize_pass/inplace_op_pass.cc
+0
-9
paddle/fluid/framework/ir/memory_optimize_pass/memory_optimize_pass.cc
...framework/ir/memory_optimize_pass/memory_optimize_pass.cc
+0
-100
python/paddle/fluid/__init__.py
python/paddle/fluid/__init__.py
+4
-4
未找到文件。
paddle/fluid/framework/ir/memory_optimize_pass/inplace_op_pass.cc
浏览文件 @
c3949f56
...
...
@@ -48,8 +48,6 @@ DEFINE_bool(
"Such as scale, elementwise_add"
"By default, it's turned off"
);
DECLARE_string
(
memory_optimize_debug
);
namespace
paddle
{
namespace
framework
{
namespace
ir
{
...
...
@@ -461,13 +459,6 @@ void InplacePass::ApplyImpl(ir::Graph *graph) const {
continue
;
}
// Debug Interface. Which would be skipped by the pass.
if
(
out_arg
==
FLAGS_memory_optimize_debug
)
{
VLOG
(
4
)
<<
"Skiped var by force. FLAGS_memory_optimize_debug="
<<
out_node
->
Name
();
continue
;
}
VLOG
(
4
)
<<
"Rename "
<<
out_node
->
Name
()
<<
" with "
<<
in_node
->
Name
()
<<
" in "
<<
op_type
;
RenameInOut
(
op_node
,
in_node
,
out_node
);
...
...
paddle/fluid/framework/ir/memory_optimize_pass/memory_optimize_pass.cc
浏览文件 @
c3949f56
...
...
@@ -31,15 +31,6 @@
#include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/ir/graph_helper.h"
DEFINE_bool
(
enable_subgraph_optimize
,
false
,
"SubGraph also reuse global graph variables, it will reduce the "
"memory occupation"
"but a higher risk of memory reuse error. default disabled."
);
DEFINE_string
(
memory_optimize_debug
,
""
,
"debug the operator output variable when do the variable reuse."
"memory reuse pass."
"only for debug, default disabled."
);
namespace
paddle
{
namespace
framework
{
namespace
ir
{
...
...
@@ -57,15 +48,6 @@ void MemoryOptimizePass::ApplyImpl(ir::Graph* graph) const {
auto
*
op_desc
=
op
->
Op
();
// some op in graph has no op desc
if
(
op_desc
==
nullptr
)
continue
;
if
(
OpHasSubBlock
(
op_desc
))
{
if
(
FLAGS_enable_subgraph_optimize
)
{
SubGraphOptimize
(
op_desc
);
}
else
{
VLOG
(
3
)
<<
op
->
Name
()
<<
" has subblock, but disable subgraph optimize. skipped."
;
continue
;
}
}
for
(
auto
&
var
:
op
->
outputs
)
{
if
(
var
->
IsVar
()
&&
!
var
->
IsCtrlVar
()
&&
skip_set_
.
count
(
var
->
Name
()))
{
...
...
@@ -82,13 +64,6 @@ void MemoryOptimizePass::ApplyImpl(ir::Graph* graph) const {
<<
"replace it again. Skip this candidate."
;
cache
=
pool_
.
FindNextBestFitNode
(
var
,
cache
);
}
if
(
var
->
Name
()
==
FLAGS_memory_optimize_debug
)
{
VLOG
(
3
)
<<
"start match var "
<<
DebugString
(
var
)
<<
" of op "
<<
op
->
Name
();
VLOG
(
3
)
<<
pool_
.
ToString
();
VLOG
(
3
)
<<
"matched in pool : "
<<
((
cache
==
nullptr
)
?
"False"
:
"True"
);
}
if
(
cache
!=
nullptr
)
{
int
node_idx_in_pool
=
pool_
.
GetNodeIndexInPool
(
cache
);
...
...
@@ -128,81 +103,6 @@ void MemoryOptimizePass::ApplyImpl(ir::Graph* graph) const {
graph
->
ResolveHazard
(
var_nodes_
);
}
void
MemoryOptimizePass
::
SubGraphOptimize
(
OpDesc
*
op_desc
)
const
{
// conditional block, while op and their grad op
auto
*
sub_block_desc
=
AttrReader
(
op_desc
->
GetAttrMap
()).
Get
<
BlockDesc
*>
(
"sub_block"
);
// create a mirror block to construct an IR Graph.
ProgramDesc
prog
;
auto
*
copy_block
=
prog
.
MutableBlock
(
0
);
for
(
auto
*
op
:
sub_block_desc
->
AllOps
())
{
auto
*
copy_op
=
copy_block
->
AppendOp
();
copy_op
->
CopyFrom
(
*
op
);
copy_op
->
Flush
();
}
for
(
auto
*
var
:
sub_block_desc
->
AllVars
())
{
auto
*
copy_var
=
copy_block
->
Var
(
var
->
Name
());
copy_var
->
SetDataType
(
var
->
GetDataType
());
// only lod tensor can be reused. So ignore the multiple dims case.
copy_var
->
SetType
(
var
->
GetType
());
copy_var
->
SetShape
(
var
->
GetShape
());
copy_var
->
SetPersistable
(
var
->
Persistable
());
}
ir
::
Graph
sub_graph
(
prog
);
std
::
unordered_set
<
ir
::
Node
*>
sub_graph_all_ops
;
FilterVariables
(
sub_graph
.
Nodes
(),
[
&
](
ir
::
Node
*
var
)
{
// sub_graph_all_ops.emplace(var);
if
(
var
->
IsVar
()
&&
!
var
->
IsCtrlVar
())
{
sub_graph_all_ops
.
emplace
(
var
);
}
});
int
sub_reuse_id
=
0
;
// subgraph nodes is unordered, reuse need to follow the desc order.
// find the right op node through the descs
for
(
auto
*
sub_op_desc
:
sub_block_desc
->
AllOps
())
{
ir
::
Node
*
sub_op
=
nullptr
;
for
(
auto
*
node
:
sub_graph_all_ops
)
{
if
(
node
->
Op
()
==
sub_op_desc
)
{
sub_op
=
node
;
break
;
}
}
PADDLE_ENFORCE
(
sub_op
!=
nullptr
);
for
(
auto
*
var
:
sub_op
->
outputs
)
{
if
(
NodeCanReused
(
var
))
{
ir
::
Node
*
cache
=
pool_
.
FindBestFitNode
(
var
);
if
(
cache
!=
nullptr
)
{
if
(
var
->
Var
()
->
GetDataType
()
!=
cache
->
Var
()
->
GetDataType
())
{
continue
;
}
int
node_idx_in_pool
=
pool_
.
GetNodeIndexInPool
(
cache
);
VLOG
(
3
)
<<
string
::
Sprintf
(
"!!! %s, %s => %s, cache idx %d, pool size %d"
,
std
::
to_string
(
sub_reuse_id
++
),
DebugString
(
var
),
DebugString
(
cache
),
node_idx_in_pool
,
static_cast
<
int
>
(
pool_
.
size
()));
// NOTE(dzh): subblock is not in IR graph. Modify the block_desc
// immediately to make the subblock variable reuse strategy take
// effect. Because it is a single op in graph. No need to
// update the ir nodes.
// FIXME(liuwei1031): Graph is not aware of the existence of
// BlockDescs and ProgramDescs.
// The operations related to BlockDesc or ProgramDesc should perform
// on Graph or Node directly!
sub_op_desc
->
Rename
(
var
->
Name
(),
cache
->
Name
());
if
(
sub_op_desc
->
Block
()
!=
nullptr
&&
sub_op_desc
->
Block
()
->
HasVar
(
var
->
Name
()))
{
sub_op_desc
->
Block
()
->
RemoveVar
(
var
->
Name
());
}
}
}
}
}
}
void
MemoryOptimizePass
::
CollectSkipVarsSet
(
ir
::
Graph
*
graph
)
const
{
// fill skip_set_
PADDLE_ENFORCE
(
graph
->
Has
(
kMemOptSkipVars
));
...
...
python/paddle/fluid/__init__.py
浏览文件 @
c3949f56
...
...
@@ -139,8 +139,8 @@ def __bootstrap__():
'allocator_strategy'
,
'reader_queue_speed_test_mode'
,
'print_sub_graph_dir'
,
'pe_profile_fname'
,
'inner_op_parallelism'
,
'enable_parallel_graph'
,
'fuse_parameter_groups_size'
,
'multiple_of_cupti_buffer_size'
,
'
enable_subgraph_optim
ize'
,
'
fuse_parameter_memory_size'
,
'
tracer_profile_fname'
'multiple_of_cupti_buffer_size'
,
'
fuse_parameter_memory_s
ize'
,
'tracer_profile_fname'
]
if
'Darwin'
not
in
sysstr
:
read_env_flags
.
append
(
'use_pinned_memory'
)
...
...
@@ -182,8 +182,8 @@ def __bootstrap__():
'fraction_of_gpu_memory_to_use'
,
'initial_gpu_memory_in_mb'
,
'reallocate_gpu_memory_in_mb'
,
'cudnn_deterministic'
,
'enable_cublas_tensor_op_math'
,
'conv_workspace_size_limit'
,
'cudnn_exhaustive_search'
,
'
memory_optimize_debug'
,
'selected_gpus
'
,
'
sync_nccl_allreduce'
,
'
limit_of_tmp_allocation'
,
'cudnn_exhaustive_search'
,
'
selected_gpus'
,
'sync_nccl_allreduce
'
,
'limit_of_tmp_allocation'
,
'times_excess_than_required_tmp_allocation'
,
'enable_inplace_whitelist'
,
'cudnn_batchnorm_spatial_persistent'
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录