Skip to content

Commit

Permalink
[Dy2St]Fix func.__self__ problem in FunctionSpec (#50404)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius84 authored Feb 10, 2023
1 parent 86cc694 commit 3374600
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,10 @@ class ListWithCondNet(paddle.nn.Layer):
def __init__(self):
super().__init__()

# Add *args to test function.__self__ in FunctionSpec.
# DO NOT remove *args.
@paddle.jit.to_static
def forward(self, x, index):
def forward(self, x, index, *args):
y = paddle.nn.functional.relu(x)
a = []

Expand Down
2 changes: 1 addition & 1 deletion python/paddle/jit/dy2static/function_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, function, input_spec=None):
# parse *args
self.varargs_name = parse_varargs_name(function)
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

Expand Down

0 comments on commit 3374600

Please sign in to comment.