Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9415a6af
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看板
未验证
提交
9415a6af
编写于
1月 09, 2023
作者:
Z
zhangbo9674
提交者:
GitHub
1月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add build strategy for infer program of dy2st (#49641)
* add build strategy for infer program of dy2st * refine code * fix bug
上级
52638c1f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
34 deletion
+47
-34
python/paddle/jit/dy2static/partial_program.py
python/paddle/jit/dy2static/partial_program.py
+47
-34
未找到文件。
python/paddle/jit/dy2static/partial_program.py
浏览文件 @
9415a6af
...
...
@@ -347,12 +347,7 @@ class PartialProgramLayer:
program
=
self
.
_train_forward_backward_program
return
program
[
0
]
else
:
if
_in_amp_guard
():
return
self
.
_infer_amp_program
elif
_in_pure_fp16_guard
():
return
self
.
_infer_pure_fp16_program
else
:
return
self
.
_infer_program
return
self
.
infer_program
@
property
def
backward_program
(
self
):
...
...
@@ -637,7 +632,7 @@ class PartialProgramLayer:
elif
_in_pure_fp16_guard
():
infer_program
=
self
.
_infer_pure_fp16_program
else
:
infer_program
=
self
.
infer_program
infer_program
=
self
.
_
infer_program
return
infer_program
.
desc
.
block
(
0
).
op_size
()
def
__call__
(
self
,
inputs
):
...
...
@@ -750,11 +745,27 @@ class PartialProgramLayer:
@
property
def
infer_program
(
self
):
if
_in_amp_guard
():
return
self
.
_infer_amp_program
program
=
self
.
_infer_amp_program
elif
_in_pure_fp16_guard
():
return
self
.
_infer_pure_fp16_program
program
=
self
.
_infer_pure_fp16_program
else
:
return
self
.
_infer_program
program
=
self
.
_infer_program
return
self
.
_build_infer_program
(
program
,
program
.
desc
.
block
(
0
).
op_size
()
)
@
switch_to_static_graph
def
_build_infer_program
(
self
,
infer_program
,
forward_end_op_index
):
forward_skip_vars
=
self
.
_parse_skip_gc_vars
(
infer_program
)
builded_infer_program
=
add_build_strategy_for
(
infer_program
,
0
,
forward_end_op_index
,
self
.
_build_strategy
,
forward_skip_vars
,
)
self
.
_apply_inplace_pass
(
builded_infer_program
,
None
)
return
builded_infer_program
@
switch_to_static_graph
def
_get_forward_backward_program_form
(
...
...
@@ -808,30 +819,32 @@ class PartialProgramLayer:
forward_program
,
backward_program
)
backward_mem_opt_skip_vars
=
self
.
_parse_skip_gc_vars
(
forward_program
)
attrs
=
{
"use_cuda"
:
use_cuda
,
"mem_opt_skip_vars"
:
forward_mem_opt_skip_vars
,
"for_partial_block"
:
True
,
}
_apply_pass
(
forward_program
,
empty_startup_program
,
"buffer_shared_inplace_pass"
,
attrs
,
attr_types
,
)
attrs
=
{
"use_cuda"
:
use_cuda
,
"mem_opt_skip_vars"
:
backward_mem_opt_skip_vars
,
"for_partial_block"
:
True
,
}
_apply_pass
(
backward_program
,
empty_startup_program
,
"buffer_shared_inplace_pass"
,
attrs
,
attr_types
,
)
if
forward_program
:
attrs
=
{
"use_cuda"
:
use_cuda
,
"mem_opt_skip_vars"
:
forward_mem_opt_skip_vars
,
"for_partial_block"
:
True
,
}
_apply_pass
(
forward_program
,
empty_startup_program
,
"buffer_shared_inplace_pass"
,
attrs
,
attr_types
,
)
if
backward_program
:
attrs
=
{
"use_cuda"
:
use_cuda
,
"mem_opt_skip_vars"
:
backward_mem_opt_skip_vars
,
"for_partial_block"
:
True
,
}
_apply_pass
(
backward_program
,
empty_startup_program
,
"buffer_shared_inplace_pass"
,
attrs
,
attr_types
,
)
@
LazyInitialized
def
_inout_var_names
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录