Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6871e57b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6871e57b
编写于
9月 29, 2020
作者:
Z
Zhou Wei
提交者:
GitHub
9月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix in_dynamic_mode of paddle,test=document_fix (#27671)
上级
abb32bbc
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
44 addition
and
27 deletion
+44
-27
python/paddle/fluid/dygraph/base.py
python/paddle/fluid/dygraph/base.py
+28
-14
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+16
-13
未找到文件。
python/paddle/fluid/dygraph/base.py
浏览文件 @
6871e57b
...
@@ -117,11 +117,15 @@ def enabled():
...
@@ -117,11 +117,15 @@ def enabled():
def
enable_dygraph
(
place
=
None
):
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:
Parameters:
place(
fluid.CPUPlace or fluid.CUDAPlace, optional): Place to execute dygraph.
place(
paddle.CPUPlace|paddle.CUDAPlace, optional): Place to run dynamic graph. Default: None. Which means that the running place will be
If None, the running place will be determined according to the way of paddle compilation. Default: None
determined according to the way of paddle compilation.
return:
return:
None
None
...
@@ -129,12 +133,15 @@ def enable_dygraph(place=None):
...
@@ -129,12 +133,15 @@ def enable_dygraph(place=None):
Examples:
Examples:
.. code-block:: python
.. 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
global
_functional_dygraph_context_manager
if
_functional_dygraph_context_manager
is
None
:
if
_functional_dygraph_context_manager
is
None
:
...
@@ -147,7 +154,11 @@ def enable_dygraph(place=None):
...
@@ -147,7 +154,11 @@ def enable_dygraph(place=None):
def
disable_dygraph
():
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:
return:
None
None
...
@@ -155,12 +166,15 @@ def disable_dygraph():
...
@@ -155,12 +166,15 @@ def disable_dygraph():
Examples:
Examples:
.. code-block:: python
.. 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
global
_functional_dygraph_context_manager
if
_functional_dygraph_context_manager
is
not
None
:
if
_functional_dygraph_context_manager
is
not
None
:
...
...
python/paddle/fluid/framework.py
浏览文件 @
6871e57b
...
@@ -180,27 +180,30 @@ def require_version(min_version, max_version=None):
...
@@ -180,27 +180,30 @@ def require_version(min_version, max_version=None):
def
in_dygraph_mode
():
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.
.. note::
You can enter dynamic graph mode with :ref:`api_fluid_dygraph_guard` api,
Dynamic graph mode is turn ON by default since paddle 2.0.0
or enable and disable dynamic graph mode with :ref:`api_fluid_dygraph_enable`
and :ref:`api_fluid_dygraph_disable` api .
This API checks whether paddle runs in dynamic graph mode.
You can turn ON static graph mode by `enable_static <../dygraph/base/disable_dygraph_en.html>`_ ,
and turn OFF static graph mode by `disable_static <../dygraph/base/enable_dygraph_en.html>`_ .
Returns:
Returns:
bool: Whether
the program is running
in dynamic graph mode.
bool: Whether
paddle runs
in dynamic graph mode.
Examples:
Examples:
.. code-block:: python
.. 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
"""
"""
return
_dygraph_tracer_
is
not
None
return
_dygraph_tracer_
is
not
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录