|
|
|
@ -117,11 +117,15 @@ def enabled():
|
|
|
|
|
|
|
|
|
|
def enable_dygraph(place=None):
|
|
|
|
|
"""
|
|
|
|
|
This function enables dynamic graph mode.
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
Dynamic graph mode is turn ON by default since paddle 2.0.0
|
|
|
|
|
|
|
|
|
|
This API turn OFF static graph mode. You can turn ON static graph mode by `enable_static <./disable_dygraph_en.html>`_ .
|
|
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
place(fluid.CPUPlace or fluid.CUDAPlace, optional): Place to execute dygraph.
|
|
|
|
|
If None, the running place will be determined according to the way of paddle compilation. Default: None
|
|
|
|
|
place(paddle.CPUPlace|paddle.CUDAPlace, optional): Place to run dynamic graph. Default: None. Which means that the running place will be
|
|
|
|
|
determined according to the way of paddle compilation.
|
|
|
|
|
|
|
|
|
|
return:
|
|
|
|
|
None
|
|
|
|
@ -129,12 +133,15 @@ def enable_dygraph(place=None):
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
|
import paddle
|
|
|
|
|
print(paddle.in_dynamic_mode()) # True, dynamic mode is turn ON by default since paddle 2.0.0
|
|
|
|
|
|
|
|
|
|
paddle.enable_static()
|
|
|
|
|
print(paddle.in_dynamic_mode()) # False, Now we are in static mode
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
print(paddle.in_dynamic_mode()) # True, Now we are in dynamic mode
|
|
|
|
|
|
|
|
|
|
fluid.enable_dygraph() # Now we are in dygragh mode
|
|
|
|
|
print(fluid.in_dygraph_mode()) # True
|
|
|
|
|
fluid.disable_dygraph()
|
|
|
|
|
print(fluid.in_dygraph_mode()) # False
|
|
|
|
|
"""
|
|
|
|
|
global _functional_dygraph_context_manager
|
|
|
|
|
if _functional_dygraph_context_manager is None:
|
|
|
|
@ -147,7 +154,11 @@ def enable_dygraph(place=None):
|
|
|
|
|
|
|
|
|
|
def disable_dygraph():
|
|
|
|
|
"""
|
|
|
|
|
This function disables dynamic graph mode.
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
Dynamic graph mode is turn ON by default since paddle 2.0.0
|
|
|
|
|
|
|
|
|
|
This API turn ON static graph mode. You can turn ON static graph mode by `disable_static <./enable_dygraph_en.html>`_ .
|
|
|
|
|
|
|
|
|
|
return:
|
|
|
|
|
None
|
|
|
|
@ -155,12 +166,15 @@ def disable_dygraph():
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
|
import paddle
|
|
|
|
|
print(paddle.in_dynamic_mode()) # True, dynamic mode is turn ON by default since paddle 2.0.0
|
|
|
|
|
|
|
|
|
|
paddle.enable_static()
|
|
|
|
|
print(paddle.in_dynamic_mode()) # False, Now we are in static mode
|
|
|
|
|
|
|
|
|
|
paddle.disable_static()
|
|
|
|
|
print(paddle.in_dynamic_mode()) # True, Now we are in dynamic mode
|
|
|
|
|
|
|
|
|
|
fluid.enable_dygraph() # Now we are in dygragh mode
|
|
|
|
|
print(fluid.in_dygraph_mode()) # True
|
|
|
|
|
fluid.disable_dygraph()
|
|
|
|
|
print(fluid.in_dygraph_mode()) # False
|
|
|
|
|
"""
|
|
|
|
|
global _functional_dygraph_context_manager
|
|
|
|
|
if _functional_dygraph_context_manager is not None:
|
|
|
|
|