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 4eb8a68c09bf029f5363f04ff9461b5e5aa9ecff..355a7133d4df1fddd7838e1ee39367be1ffffb44 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 7c457eb15118baf6823be9e404fc2fa053b6a2f6..e324527de868b64c29abda1fe9047648ef287a76 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 93da7cc1dd97162fbc09b6ae811c2a8f0f11a958..510c887e29087e600f3e4d90c52bfe0f234a4c82 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