未验证 提交 ef2ee5e5 编写于 作者: A Aurelius84 提交者: GitHub

[cherry-pick] BugFix StaticAanlysis with gast.Subscript (#32969) (#32903) (#32986)

* [Custom Op]Remove PADDLE_WITH_MKLDNN in custom_op  (#32903)

* [Dy2Stat]BugFix StaticAanlysis with gast.Subscript (#32969)

* BugFix StaticAanlysis with gast.Subscript

* remove codes
上级 c7848aca
......@@ -368,5 +368,8 @@ class StaticAnalysisVisitor(object):
if isinstance(node.func, gast.Name):
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}
......@@ -16,6 +16,7 @@ from __future__ import print_function
import unittest
import paddle
import numpy as np
import paddle.fluid as fluid
from paddle.fluid.dygraph.jit import declarative
......@@ -61,6 +62,33 @@ def test_list_append_in_for_loop(x, iter_num):
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):
x = fluid.dygraph.to_variable(x)
a = []
......@@ -261,5 +289,16 @@ class TestListInForLoopWithConcat(TestListInWhileLoopWithStack):
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__':
unittest.main()
......@@ -469,10 +469,6 @@ def normalize_extension_kwargs(kwargs, use_cuda=False):
########################### -- END -- ###########################
add_compile_flag(extra_compile_args, ['-w']) # disable warning
# Note(Aurelius84): This marco will impact memory layout of `Tensor`.
# We align it automatically with pre-installed Paddle.
if core.is_compiled_with_mkldnn():
add_compile_flag(extra_compile_args, ['-DPADDLE_WITH_MKLDNN'])
if use_cuda:
extra_link_args.append('-lcudart')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册