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 72d876cc72ed3..c9630bfe6fd95 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/program_translator.py @@ -247,7 +247,7 @@ def __init__(self, function, input_spec=None): self._function_spec = FunctionSpec(function, input_spec) self._program_cache = ProgramCache() self._descriptor_cache = weakref.WeakKeyDictionary() - # Note: Hold a reference to ProgramTranslator for switching `enable_static`. + # Note: Hold a reference to ProgramTranslator for switching `enable_to_static`. self._program_trans = ProgramTranslator() def __get__(self, instance, owner): @@ -300,11 +300,11 @@ def __call__(self, *args, **kwargs): """ # 1. call dygraph function directly if not enable `declarative` - if not self._program_trans.enable_static: + if not self._program_trans.enable_to_static: logging_utils.warn( "The decorator '@paddle.jit.to_static' does NOT work when setting ProgramTranslator.enable to False. " "We will just return dygraph output. If you would like to get static graph output, please call API " - "ProgramTranslator.enable_static(True)") + "ProgramTranslator.enable(True)") return self._call_dygraph_function(*args, **kwargs) if not in_dygraph_mode(): @@ -729,15 +729,15 @@ def __init__(self): return self._initialized = True self._program_cache = ProgramCache() - self.enable_static = True + self.enable_to_static = True - def enable(self, enable_static): + def enable(self, enable_to_static): """ Enable or disable the converting from imperative to declarative by ProgramTranslator globally. Args: - enable_static (bool): True or False to enable or disable declarative. + enable_to_static (bool): True or False to enable or disable declarative. Returns: None. @@ -766,9 +766,9 @@ def func(x): print(func(x).numpy()) # [[2. 2.]] """ - check_type(enable_static, "enable_static", bool, + check_type(enable_to_static, "enable_to_static", bool, "ProgramTranslator.enable") - self.enable_static = enable_static + self.enable_to_static = enable_to_static def get_output(self, dygraph_func, *args, **kwargs): """ @@ -809,7 +809,7 @@ def func(x): assert callable( dygraph_func ), "Input dygraph_func is not a callable in ProgramTranslator.get_output" - if not self.enable_static: + if not self.enable_to_static: warnings.warn( "The ProgramTranslator.get_output doesn't work when setting ProgramTranslator.enable to False. " "We will just return dygraph output. " @@ -876,7 +876,7 @@ def func(x): assert callable( dygraph_func ), "Input dygraph_func is not a callable in ProgramTranslator.get_func" - if not self.enable_static: + if not self.enable_to_static: warnings.warn( "The ProgramTranslator.get_func doesn't work when setting ProgramTranslator.enable to False. We will " "just return dygraph output. Please call ProgramTranslator.enable(True) if you would like to get static output." @@ -930,7 +930,7 @@ def func(x): assert callable( dygraph_func ), "Input dygraph_func is not a callable in ProgramTranslator.get_program" - if not self.enable_static: + if not self.enable_to_static: warnings.warn( "The ProgramTranslator.get_program doesn't work when setting ProgramTranslator.enable to False." "We will just return dygraph output. " diff --git a/python/paddle/fluid/dygraph/jit.py b/python/paddle/fluid/dygraph/jit.py index 66ec8f83fffa0..294ac40cd55a7 100644 --- a/python/paddle/fluid/dygraph/jit.py +++ b/python/paddle/fluid/dygraph/jit.py @@ -118,7 +118,7 @@ def func(x): # TODO: remove this decorator after we finalize training API def __impl__(*args, **kwargs): program_translator = ProgramTranslator() - if in_dygraph_mode() or not program_translator.enable_static: + if in_dygraph_mode() or not program_translator.enable_to_static: warnings.warn( "The decorator 'dygraph_to_static_func' doesn't work in " "dygraph mode or set ProgramTranslator.enable to False. " @@ -775,7 +775,7 @@ def get_inout_spec(all_vars, target_vars, return_name=False): # 1. input check prog_translator = ProgramTranslator() - if not prog_translator.enable_static: + if not prog_translator.enable_to_static: raise RuntimeError( "The paddle.jit.save doesn't work when setting ProgramTranslator.enable to False." ) diff --git a/python/paddle/hapi/model.py b/python/paddle/hapi/model.py index 5a7206a7f4b8a..c445977df1405 100644 --- a/python/paddle/hapi/model.py +++ b/python/paddle/hapi/model.py @@ -1689,7 +1689,7 @@ def get_inout_spec(all_vars, return_name=False): # 1. input check prog_translator = ProgramTranslator() - if not prog_translator.enable_static: + if not prog_translator.enable_to_static: raise RuntimeError( "save_inference_model doesn't work when setting ProgramTranslator.enable to False." )