Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7049af57
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
7049af57
编写于
7月 16, 2021
作者:
A
Aurelius84
提交者:
GitHub
7月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Dy2Stat]Add NoNeedBufferVarsInferer to reduce memory usage (#34177)
* Add NoNeedBufferVarsInferer * fix code style
上级
44bdbe93
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
3 deletion
+21
-3
paddle/fluid/framework/executor_cache.cc
paddle/fluid/framework/executor_cache.cc
+21
-3
未找到文件。
paddle/fluid/framework/executor_cache.cc
浏览文件 @
7049af57
...
@@ -77,6 +77,7 @@ void ParseSafeEagerDeletionSkipVars(
...
@@ -77,6 +77,7 @@ void ParseSafeEagerDeletionSkipVars(
const
std
::
vector
<
std
::
string
>
&
output_var_names
,
const
std
::
vector
<
std
::
string
>
&
output_var_names
,
std
::
vector
<
std
::
string
>
*
skip_eager_delete_vars
)
{
std
::
vector
<
std
::
string
>
*
skip_eager_delete_vars
)
{
auto
all_ops
=
program
.
Block
(
0
).
AllOps
();
auto
all_ops
=
program
.
Block
(
0
).
AllOps
();
auto
&
op_info_map
=
OpInfoMap
::
Instance
();
// NOTE: skip `shape` and `fill_constant` op created by
// NOTE: skip `shape` and `fill_constant` op created by
// fluid.backward.gradients, one forward output will generate one `shape`
// fluid.backward.gradients, one forward output will generate one `shape`
// and `fill_constant`.
// and `fill_constant`.
...
@@ -86,16 +87,33 @@ void ParseSafeEagerDeletionSkipVars(
...
@@ -86,16 +87,33 @@ void ParseSafeEagerDeletionSkipVars(
// step 2: parse the necessary variable of backward op
// step 2: parse the necessary variable of backward op
std
::
unordered_set
<
std
::
string
>
op_outputs
;
std
::
unordered_set
<
std
::
string
>
op_outputs
;
std
::
unordered_set
<
std
::
string
>
op_inputs
;
std
::
unordered_set
<
std
::
string
>
op_inputs
;
std
::
unordered_set
<
std
::
string
>
no_need_buffer_ins
;
for
(
auto
i
=
backward_op_start_index
;
i
<
all_ops
.
size
();
++
i
)
{
for
(
auto
i
=
backward_op_start_index
;
i
<
all_ops
.
size
();
++
i
)
{
framework
::
OpDesc
*
op
=
all_ops
[
i
];
framework
::
OpDesc
*
op
=
all_ops
[
i
];
for
(
const
std
::
string
&
in_arg_name
:
op
->
InputArgumentNames
())
{
// NOTE: skip NoNeedBufferVars of grad_op and GC its memory in advance.
op_inputs
.
emplace
(
in_arg_name
);
auto
&
op_info
=
op_info_map
.
Get
(
op
->
Type
());
auto
&
inferer
=
op_info
.
NoNeedBufferVarsInferer
();
no_need_buffer_ins
.
clear
();
if
(
inferer
!=
nullptr
)
{
no_need_buffer_ins
=
inferer
(
op
->
Inputs
(),
op
->
Outputs
(),
op
->
GetAttrMap
());
}
for
(
auto
&
in_names
:
op
->
Inputs
())
{
if
(
no_need_buffer_ins
.
count
(
in_names
.
first
)
==
0
)
{
for
(
auto
&
in_name
:
in_names
.
second
)
{
op_inputs
.
emplace
(
in_name
);
}
}
else
{
VLOG
(
2
)
<<
op
->
Type
()
<<
" has no_need_buffer_in: "
<<
in_names
.
first
<<
" , skip it."
;
}
}
}
for
(
const
std
::
string
&
out_arg_name
:
op
->
OutputArgumentNames
())
{
for
(
const
std
::
string
&
out_arg_name
:
op
->
OutputArgumentNames
())
{
op_outputs
.
emplace
(
out_arg_name
);
op_outputs
.
emplace
(
out_arg_name
);
}
}
}
}
// For the grad op input variables, if it is not output of grad_op, it may
// For the grad op input variables, if it is not output of grad_op, it may
// be output of forward op and we should set the variables as skip_var to
// be output of forward op and we should set the variables as skip_var to
// prevent it being deleted when grad op is called multiple times.
// prevent it being deleted when grad op is called multiple times.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录