Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ def dyfunc(x):
if is_builtin(func) or is_unsupported(func):
return func

if inspect.isgeneratorfunction(func):
# NOTE(xiongkun03): inspect.isfunction() will return True even though func is a generator function.
# If we don't deal generatorfunction here, we will regard it as normal function and get errors in some
# occasion.
number_of_stars = 30
translator_logger.warn(
"\n\n" + "*" * number_of_stars +
"\nYour function:`{}` doesn't support to transform to static function because it is a generator function, it will be run as-is."
.format(func.__name__) + "\n" + "*" * number_of_stars + "\n\n")
return func

if inspect.isfunction(func):
# TODO(liym27): If func is a lambda function, special conversion is needed.
if func.__name__ == '<lambda>':
Expand Down