diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py b/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py index b860740f71b25e67c3c11a908bec5b01fd96a51a..aed482e4b22664848468764a512651c8940acae2 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py @@ -61,7 +61,7 @@ class FunctionCache(object): def __init__(self): # Caches the converted static functions. {dygraph_func: static_func} - self._converted_static_func_caches = dict() + self._converted_static_func_caches = weakref.WeakKeyDictionary() # Caches the converted ast node for same source code. {source_code: ast_root} self._code_to_ast_caches = dict() self._dygraph_to_static = DygraphToStaticAst()