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

[Dy2St]Fix func.__self__ problem in FunctionSpec (#50404)

上级 86cc694f
...@@ -338,8 +338,10 @@ class ListWithCondNet(paddle.nn.Layer): ...@@ -338,8 +338,10 @@ class ListWithCondNet(paddle.nn.Layer):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
# Add *args to test function.__self__ in FunctionSpec.
# DO NOT remove *args.
@paddle.jit.to_static @paddle.jit.to_static
def forward(self, x, index): def forward(self, x, index, *args):
y = paddle.nn.functional.relu(x) y = paddle.nn.functional.relu(x)
a = [] a = []
......
...@@ -54,7 +54,7 @@ class FunctionSpec: ...@@ -54,7 +54,7 @@ class FunctionSpec:
# parse *args # parse *args
self.varargs_name = parse_varargs_name(function) self.varargs_name = parse_varargs_name(function)
if self.varargs_name is not None and isinstance( if self.varargs_name is not None and isinstance(
function.__self__, TranslatedLayer getattr(function, '__self__', None), TranslatedLayer
): ):
self._arg_names += function.__self__._input_args_names self._arg_names += function.__self__._input_args_names
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册