Skip to content

Commit

Permalink
modify doc for in_dygraph_mode, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuancoder committed Sep 27, 2020
1 parent 09f1953 commit a565aff
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions python/paddle/fluid/framework.py
Expand Up @@ -180,27 +180,24 @@ def version_cmp(ver_a, ver_b):

def in_dygraph_mode():
"""
:alias_main: paddle.in_dygraph_mode
:alias: paddle.in_dygraph_mode
:old_api: paddle.fluid.framework.in_dygraph_mode
This function checks whether the program runs in dynamic graph mode or not.
You can enter dynamic graph mode with :ref:`api_fluid_dygraph_guard` api,
or enable and disable dynamic graph mode with :ref:`api_fluid_dygraph_enable`
and :ref:`api_fluid_dygraph_disable` api .
Starting with paddle2.0, the dynamic graph mode the default mode.
**Note**:
``paddle.in_dynamic_mode`` is the alias of ``fluid.in_dygraph_mode``, and
``paddle.in_dynamic_mode`` is recommended to use.
Returns:
bool: Whether the program is running in dynamic graph mode.
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle
fluid.enable_dygraph() # Now we are in dygragh mode
print(fluid.in_dygraph_mode()) # True
fluid.disable_dygraph()
print(fluid.in_dygraph_mode()) # False
print(paddle.in_dynamic_mode()) # True
paddle.enable_static()
print(paddle.in_dynamic_mode()) # False
"""
return _dygraph_tracer_ is not None

Expand Down

1 comment on commit a565aff

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on a565aff Sep 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍PR: #27620 Commit ID: a565aff contains failed CI.

Please sign in to comment.