diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py b/python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py index b43c4e9d36d60190b551d0185993d98af4cbda9a..2ac1d6403c0f9b220c1196de18e6704dde1e9b0b 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py @@ -50,16 +50,7 @@ from paddle.fluid.dygraph.layers import Layer __all__ = ["convert_call"] -# TODO(liym27): A better way to do this. -BUILTIN_LIKELY_MODULES = [ - collections, - pdb, - copy, - inspect, - re, - numpy, - logging, -] + # The api(s) should be considered as plain function and convert # them into static layer code. PADDLE_NEED_CONVERT_APIS = [Sequential] @@ -99,6 +90,32 @@ def is_builtin(func, name=None): return False +def builtin_modules(): + """ + Return builtin modules. + """ + modules = [ + collections, + pdb, + copy, + inspect, + re, + numpy, + logging, + ] + try: + import six + + modules.append(six) + except ImportError: + pass # do nothing + + return modules + + +BUILTIN_LIKELY_MODULES = builtin_modules() + + def is_unsupported(func): """ Checks whether the func is supported by dygraph to static graph.