Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c2852610
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
c2852610
编写于
5月 19, 2021
作者:
A
Aurelius84
提交者:
GitHub
5月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Dy2Stat]BugFix StaticAanlysis with gast.Subscript (#32969)
* BugFix StaticAanlysis with gast.Subscript * remove codes
上级
56008aa1
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
42 addition
and
0 deletion
+42
-0
python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py
...paddle/fluid/dygraph/dygraph_to_static/static_analysis.py
+3
-0
python/paddle/fluid/tests/unittests/dygraph_to_static/test_list.py
...ddle/fluid/tests/unittests/dygraph_to_static/test_list.py
+39
-0
未找到文件。
python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py
浏览文件 @
c2852610
...
@@ -368,5 +368,8 @@ class StaticAnalysisVisitor(object):
...
@@ -368,5 +368,8 @@ class StaticAnalysisVisitor(object):
if
isinstance
(
node
.
func
,
gast
.
Name
):
if
isinstance
(
node
.
func
,
gast
.
Name
):
return
self
.
var_env
.
get_var_type
(
node
.
func
.
id
)
return
self
.
var_env
.
get_var_type
(
node
.
func
.
id
)
if
isinstance
(
node
,
gast
.
Subscript
):
if
self
.
is_tensor_node
(
node
.
value
):
return
{
NodeVarType
.
TENSOR
}
return
{
NodeVarType
.
STATEMENT
}
return
{
NodeVarType
.
STATEMENT
}
python/paddle/fluid/tests/unittests/dygraph_to_static/test_list.py
浏览文件 @
c2852610
...
@@ -16,6 +16,7 @@ from __future__ import print_function
...
@@ -16,6 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
paddle
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid.dygraph.jit
import
declarative
from
paddle.fluid.dygraph.jit
import
declarative
...
@@ -61,6 +62,33 @@ def test_list_append_in_for_loop(x, iter_num):
...
@@ -61,6 +62,33 @@ def test_list_append_in_for_loop(x, iter_num):
return
a
[
0
]
return
a
[
0
]
paddle
.
jit
.
set_code_level
(
100
)
def
test_list_append_in_for_subscript
(
x
):
x
=
fluid
.
dygraph
.
to_variable
(
x
)
iter_num
=
paddle
.
shape
(
x
)[
0
]
a
=
[]
for
i
in
range
(
iter_num
):
x
=
x
+
1
a
.
append
(
x
)
out
=
paddle
.
concat
(
a
)
return
out
[
0
]
def
test_list_append_in_while_loop_subscript
(
x
):
x
=
fluid
.
dygraph
.
to_variable
(
x
)
iter_num
=
paddle
.
shape
(
x
)[
0
]
a
=
[]
i
=
0
while
i
<
iter_num
:
x
=
x
+
1
a
.
append
(
x
)
i
+=
1
out
=
paddle
.
concat
(
a
)
return
out
[
0
]
def
test_list_append_in_for_loop_with_concat
(
x
,
iter_num
):
def
test_list_append_in_for_loop_with_concat
(
x
,
iter_num
):
x
=
fluid
.
dygraph
.
to_variable
(
x
)
x
=
fluid
.
dygraph
.
to_variable
(
x
)
a
=
[]
a
=
[]
...
@@ -261,5 +289,16 @@ class TestListInForLoopWithConcat(TestListInWhileLoopWithStack):
...
@@ -261,5 +289,16 @@ class TestListInForLoopWithConcat(TestListInWhileLoopWithStack):
self
.
all_dygraph_funcs
=
[
test_list_append_in_for_loop_with_concat
,
]
self
.
all_dygraph_funcs
=
[
test_list_append_in_for_loop_with_concat
,
]
class
TestListInForLoopWithSubscript
(
TestListWithoutControlFlow
):
def
init_dygraph_func
(
self
):
self
.
all_dygraph_funcs
=
[
test_list_append_in_for_subscript
,
test_list_append_in_while_loop_subscript
]
def
init_data
(
self
):
self
.
input
=
np
.
random
.
random
((
3
,
4
)).
astype
(
'float32'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录