From f67fd716740894b88928f7df53f8075916c2781f Mon Sep 17 00:00:00 2001 From: cryoco Date: Sun, 27 Sep 2020 19:39:10 +0800 Subject: [PATCH] 2.0 api unique_name --- .../paddle/fluid/unique_name/generate_cn.rst | 8 ++++---- .../api/paddle/fluid/unique_name/guard_cn.rst | 20 +++++++++---------- .../paddle/fluid/unique_name/switch_cn.rst | 16 +++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/paddle/api/paddle/fluid/unique_name/generate_cn.rst b/doc/paddle/api/paddle/fluid/unique_name/generate_cn.rst index 4eb8a68c0..355a7133d 100644 --- a/doc/paddle/api/paddle/fluid/unique_name/generate_cn.rst +++ b/doc/paddle/api/paddle/fluid/unique_name/generate_cn.rst @@ -3,7 +3,7 @@ generate ------------------------------- -.. py:function:: paddle.fluid.unique_name.generate(key) +.. py:function:: paddle.utils.unique_name.generate(key) @@ -21,9 +21,9 @@ generate .. code-block:: python - import paddle.fluid as fluid - name1 = fluid.unique_name.generate('fc') - name2 = fluid.unique_name.generate('fc') + import paddle + name1 = paddle.utils.unique_name.generate('fc') + name2 = paddle.utils.unique_name.generate('fc') print(name1, name2) # fc_0, fc_1 diff --git a/doc/paddle/api/paddle/fluid/unique_name/guard_cn.rst b/doc/paddle/api/paddle/fluid/unique_name/guard_cn.rst index 7c457eb15..e324527de 100644 --- a/doc/paddle/api/paddle/fluid/unique_name/guard_cn.rst +++ b/doc/paddle/api/paddle/fluid/unique_name/guard_cn.rst @@ -3,7 +3,7 @@ guard ------------------------------- -.. py:function:: paddle.fluid.unique_name.guard(new_generator=None) +.. py:function:: paddle.utils.unique_name.guard(new_generator=None) @@ -19,17 +19,17 @@ guard .. code-block:: python - import paddle.fluid as fluid - with fluid.unique_name.guard(): - name_1 = fluid.unique_name.generate('fc') - with fluid.unique_name.guard(): - name_2 = fluid.unique_name.generate('fc') + import paddle + with paddle.utils.unique_name.guard(): + name_1 = paddle.utils.unique_name.generate('fc') + with paddle.utils.unique_name.guard(): + name_2 = paddle.utils.unique_name.generate('fc') print(name_1, name_2) # fc_0, fc_0 - with fluid.unique_name.guard('A'): - name_1 = fluid.unique_name.generate('fc') - with fluid.unique_name.guard('B'): - name_2 = fluid.unique_name.generate('fc') + with paddle.utils.unique_name.guard('A'): + name_1 = paddle.utils.unique_name.generate('fc') + with paddle.utils.unique_name.guard('B'): + name_2 = paddle.utils.unique_name.generate('fc') print(name_1, name_2) # Afc_0, Bfc_0 diff --git a/doc/paddle/api/paddle/fluid/unique_name/switch_cn.rst b/doc/paddle/api/paddle/fluid/unique_name/switch_cn.rst index 93da7cc1d..510c887e2 100644 --- a/doc/paddle/api/paddle/fluid/unique_name/switch_cn.rst +++ b/doc/paddle/api/paddle/fluid/unique_name/switch_cn.rst @@ -3,7 +3,7 @@ switch ------------------------------- -.. py:function:: paddle.fluid.unique_name.switch(new_generator=None) +.. py:function:: paddle.utils.unique_name.switch(new_generator=None) @@ -21,15 +21,15 @@ switch .. code-block:: python - import paddle.fluid as fluid - name1 = fluid.unique_name.generate('fc') - name2 = fluid.unique_name.generate('fc') + import paddle + name1 = paddle.utils.unique_name.generate('fc') + name2 = paddle.utils.unique_name.generate('fc') print(name1, name2) # fc_0, fc_1 - pre_generator = fluid.unique_name.switch() # 切换到新命名空间 - name2 = fluid.unique_name.generate('fc') + pre_generator, pre_dygraph_name_checker = paddle.utils.unique_name.switch() # 切换到新命名空间 + name2 = paddle.utils.unique_name.generate('fc') print(name2) # fc_0 - fluid.unique_name.switch(pre_generator) # 切换回原命名空间 - name3 = fluid.unique_name.generate('fc') + paddle.utils.unique_name.switch(pre_generator, pre_dygraph_name_checker) # 切换回原命名空间 + name3 = paddle.utils.unique_name.generate('fc') print(name3) # fc_2, 因为原命名空间已生成fc_0, fc_1 -- GitLab