未验证 提交 3b58a68f 编写于 作者: N Nyakku Shigure 提交者: GitHub

[Dy2St] fix `func_self` maybe a callable empty list (#55554)

上级 4df00939
...@@ -339,6 +339,6 @@ def convert_call(func): ...@@ -339,6 +339,6 @@ def convert_call(func):
) )
return func return func
if func_self: if func_self is not None:
converted_call = functools.partial(converted_call, func_self) converted_call = functools.partial(converted_call, func_self)
return converted_call return converted_call
...@@ -25,6 +25,11 @@ class CallNotExist(paddle.nn.Layer): ...@@ -25,6 +25,11 @@ class CallNotExist(paddle.nn.Layer):
return paddle.nn.not_exist_api return paddle.nn.not_exist_api
class CallableList(list):
def __call__(self, x):
return x
class ForwardNotExist(paddle.nn.Layer): class ForwardNotExist(paddle.nn.Layer):
def forward(self): def forward(self):
return 0 return 0
...@@ -51,6 +56,14 @@ class TestConvertCall(unittest.TestCase): ...@@ -51,6 +56,14 @@ class TestConvertCall(unittest.TestCase):
with self.assertRaises(AttributeError): with self.assertRaises(AttributeError):
forward_not_exist() forward_not_exist()
def test_callable_list(self):
@paddle.jit.to_static
def callable_list(x, y):
callable_list = CallableList()
return callable_list(x) + y
self.assertEqual(callable_list(1, 2), 3)
class TestConvertShapeCompare(unittest.TestCase): class TestConvertShapeCompare(unittest.TestCase):
def test_non_variable(self): def test_non_variable(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册