Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d26f581c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
d26f581c
编写于
5月 19, 2020
作者:
C
Chen Weihang
提交者:
GitHub
5月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some detail problems, test=develop (#24614)
上级
6b464f96
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
11 deletion
+9
-11
python/paddle/fluid/dygraph/dygraph_to_static/break_continue_transformer.py
...d/dygraph/dygraph_to_static/break_continue_transformer.py
+2
-2
python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py
...addle/fluid/dygraph/dygraph_to_static/loop_transformer.py
+2
-2
python/paddle/fluid/dygraph/dygraph_to_static/utils.py
python/paddle/fluid/dygraph/dygraph_to_static/utils.py
+5
-7
未找到文件。
python/paddle/fluid/dygraph/dygraph_to_static/break_continue_transformer.py
浏览文件 @
d26f581c
...
...
@@ -19,7 +19,7 @@ import gast
from
paddle.fluid
import
unique_name
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
get_constant_variable_node
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
index_in_list
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
ForNode
Parse
r
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
ForNode
Visito
r
from
paddle.fluid.dygraph.dygraph_to_static.variable_trans_func
import
create_fill_constant_node
__all__
=
[
'BreakContinueTransformer'
]
...
...
@@ -67,7 +67,7 @@ class ForToWhileTransformer(gast.NodeTransformer):
node
,
gast
.
For
),
"Input node is NOT gast.For in get_for_stmt_nodes"
# 1. parse current gast.For node
current_for_node_parser
=
ForNode
Parse
r
(
node
)
current_for_node_parser
=
ForNode
Visito
r
(
node
)
stmts_tuple
=
current_for_node_parser
.
parse
()
if
stmts_tuple
is
None
:
return
[
node
]
...
...
python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py
浏览文件 @
d26f581c
...
...
@@ -28,7 +28,7 @@ from paddle.fluid.dygraph.dygraph_to_static.utils import generate_name_node
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
get_constant_variable_node
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
get_attribute_full_name
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
is_control_flow_to_transform
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
ForNode
Parse
r
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
ForNode
Visito
r
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
RenameTransformer
from
paddle.fluid.dygraph.dygraph_to_static.variable_trans_func
import
create_static_variable_gast_node
from
paddle.fluid.dygraph.dygraph_to_static.variable_trans_func
import
to_static_variable_gast_node
...
...
@@ -374,7 +374,7 @@ class LoopTransformer(gast.NodeTransformer):
# 2). cond_stmt: node, condition node to judge whether continue loop
# 3). body_stmts: list[node], updated loop body, sometimes we should change
# the original statement in body, not just append new statement
current_for_node_parser
=
ForNode
Parse
r
(
node
)
current_for_node_parser
=
ForNode
Visito
r
(
node
)
stmts_tuple
=
current_for_node_parser
.
parse
()
if
stmts_tuple
is
None
:
return
[
node
]
...
...
python/paddle/fluid/dygraph/dygraph_to_static/utils.py
浏览文件 @
d26f581c
...
...
@@ -628,7 +628,7 @@ class IsControlFlowVisitor(gast.NodeVisitor):
class
NameNodeReplaceTransformer
(
gast
.
NodeTransformer
):
"""
This class
transform specfice gast.Name node to replace node
This class
replaces specified gast.Name node by replace_node.
"""
def
__init__
(
self
,
root_node
,
target_name
,
replace_node
):
...
...
@@ -644,9 +644,9 @@ class NameNodeReplaceTransformer(gast.NodeTransformer):
return
node
class
ForNode
Parse
r
(
object
):
class
ForNode
Visito
r
(
object
):
"""
This class parse python for statement, get transformed 3 statement components of for node
This class parse
s
python for statement, get transformed 3 statement components of for node
three key statements:
1). init_stmts: list[node], prepare nodes of for loop, may not only one
2). cond_stmt: node, condition node to judge whether continue loop
...
...
@@ -664,7 +664,7 @@ class ForNodeParser(object):
def
__init__
(
self
,
for_node
):
assert
isinstance
(
for_node
,
gast
.
For
),
"Input node for the initialization of ForNode
Parse
r is not gast.For node."
),
"Input node for the initialization of ForNode
Visito
r is not gast.For node."
# 1. original for node
self
.
node
=
for_node
...
...
@@ -806,9 +806,7 @@ class ForNodeParser(object):
],
value
=
self
.
iter_args
[
0
])
else
:
# TODO: slice bug, only support int32 index
index_init_node
=
get_constant_variable_node
(
self
.
iter_idx_name
,
0
,
dtype
=
'int32'
)
index_init_node
=
get_constant_variable_node
(
self
.
iter_idx_name
,
0
)
return
index_init_node
def
_build_var_shape_assign_node
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录