Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e3b208ce
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看板
提交
e3b208ce
编写于
2月 19, 2022
作者:
J
jim19930609
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Supported intermediate outputs for eager final state codegen
上级
b29c05c7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
23 addition
and
8 deletion
+23
-8
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
...er/auto_code_generator/final_state_generator/eager_gen.py
+23
-8
未找到文件。
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
浏览文件 @
e3b208ce
...
...
@@ -127,6 +127,10 @@ def ReadBwdFile(filepath):
######################
### Yaml Parsers ###
######################
def
ParseIntermediate
(
string
):
return
[
v
.
strip
()
for
v
in
string
.
split
(
","
)]
def
ParseYamlArgs
(
string
):
# Example: const Tensor& x, const Tensor& y, bool transpose_x, bool transpose_y
...
...
@@ -728,11 +732,11 @@ def GenerateNodeCreationCodes(fwd_api_name, bwd_api_name,
return
node_creation_str
def
GenerateForwardDefinition
(
fwd_api_name
,
bwd_api_name
,
forward_inputs_position_map
,
def
GenerateForwardDefinition
(
fwd_api_name
,
bwd_api_name
,
forward_inputs_position_map
,
forward_outputs_position_map
,
forward_attrs_list
,
backward_fwd_input_map
,
backward_grad_input_map
,
backward_grad_output_map
,
backward_attrs_list
):
backward_grad_output_map
,
backward_attrs_list
,
intermediate_outputs
):
# fwd_api_name = ""
# forward_inputs_position_map = { "name" : [type, fwd_position] }
# forward_outputs_position_map = { "name" : [type, fwd_position] }
...
...
@@ -776,13 +780,20 @@ def GenerateForwardDefinition(fwd_api_name, bwd_api_name,
inputs_call_args_str
=
", "
.
join
(
inputs_call_list
)
# Forward Full Logic
forward_call_str
=
f
"auto api_result = paddle::experimental::
{
fwd_api_name
}
(
{
inputs_call_args_str
}
);"
if
len
(
intermediate_outputs
)
==
0
:
function_name
=
fwd_api_name
else
:
function_name
=
fwd_api_name
+
"_intermediate"
forward_call_str
=
f
"auto api_result = paddle::experimental::
{
function_name
}
(
{
inputs_call_args_str
}
);"
# Get return type list & outputs
num_outputs
=
len
(
forward_outputs_position_map
.
keys
())
num_outputs
=
len
(
forward_outputs_position_map
.
keys
())
-
len
(
intermediate_outputs
)
returns_type_list
=
[
""
for
i
in
range
(
num_outputs
)]
returns_list
=
[
""
for
i
in
range
(
num_outputs
)]
for
name
,
(
rtype
,
pos
)
in
forward_outputs_position_map
.
items
():
if
name
in
intermediate_outputs
:
continue
if
num_outputs
==
1
:
returns_list
[
0
]
=
f
"api_result"
else
:
...
...
@@ -1001,6 +1012,10 @@ if __name__ == "__main__":
fwd_args_str
=
fwd_api
[
'args'
]
fwd_returns_str
=
fwd_api
[
'output'
]
intermediate_outputs
=
[]
if
'intermediate'
in
fwd_api
.
keys
():
intermediate_outputs
=
ParseIntermediate
(
fwd_api
[
'intermediate'
])
bwd_api_name
=
fwd_api
[
'backward'
]
assert
bwd_api_name
in
grad_api_dict
.
keys
()
bwd_api
=
grad_api_dict
[
bwd_api_name
]
...
...
@@ -1076,7 +1091,7 @@ if __name__ == "__main__":
fwd_api_name
,
bwd_api_name
,
forward_inputs_position_map
,
forward_outputs_position_map
,
forward_attrs_list
,
backward_fwd_input_map
,
backward_grad_input_map
,
backward_grad_output_map
,
backward_attrs_list
)
backward_grad_output_map
,
backward_attrs_list
,
intermediate_outputs
)
print
(
"Generated Forward Definition: "
,
forward_definition_str
)
print
(
"Generated Forward Declaration: "
,
forward_declaration_str
)
forward_definition_str
+=
definition_declaration_pair
[
0
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录