From d4b0d03b502cf1a9b3d185590aab98917a537a2d Mon Sep 17 00:00:00 2001 From: Ligoml <39876205+Ligoml@users.noreply.github.com> Date: Thu, 28 Oct 2021 09:39:23 +0800 Subject: [PATCH] fix device docs;test=document_fix (#36784) * fix device docs;test=document_fix * update __init__.py --- python/paddle/device/__init__.py | 13 +++++++------ python/paddle/fluid/framework.py | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python/paddle/device/__init__.py b/python/paddle/device/__init__.py index 0c53097d9f..84b08fcdd3 100644 --- a/python/paddle/device/__init__.py +++ b/python/paddle/device/__init__.py @@ -48,7 +48,7 @@ def is_compiled_with_npu(): .. code-block:: python import paddle - support_npu = paddle.is_compiled_with_npu() + support_npu = paddle.device.is_compiled_with_npu() """ return core.is_compiled_with_npu() @@ -63,7 +63,7 @@ def is_compiled_with_xpu(): .. code-block:: python import paddle - support_xpu = paddle.is_compiled_with_xpu() + support_xpu = paddle.device.is_compiled_with_xpu() """ return core.is_compiled_with_xpu() @@ -77,10 +77,11 @@ def XPUPlace(dev_id): Examples: .. code-block:: python + # required: xpu import paddle - place = paddle.XPUPlace(0) + place = paddle.device.XPUPlace(0) """ return core.XPUPlace(dev_id) @@ -98,7 +99,7 @@ def get_cudnn_version(): import paddle - cudnn_version = paddle.get_cudnn_version() + cudnn_version = paddle.device.get_cudnn_version() @@ -195,7 +196,7 @@ def set_device(device): import paddle - paddle.set_device("cpu") + paddle.device.set_device("cpu") x1 = paddle.ones(name='x1', shape=[1, 2], dtype='int32') x2 = paddle.zeros(name='x2', shape=[1, 2], dtype='int32') data = paddle.stack([x1,x2], axis=1) @@ -217,7 +218,7 @@ def get_device(): .. code-block:: python import paddle - device = paddle.get_device() + device = paddle.device.get_device() """ device = '' diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index a3cd34c32e..c8e7de4336 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -467,7 +467,7 @@ def is_compiled_with_cuda(): .. code-block:: python import paddle - support_gpu = paddle.is_compiled_with_cuda() + support_gpu = paddle.device.is_compiled_with_cuda() """ return core.is_compiled_with_cuda() @@ -482,7 +482,7 @@ def is_compiled_with_rocm(): .. code-block:: python import paddle - support_gpu = paddle.is_compiled_with_rocm() + support_gpu = paddle.device.is_compiled_with_rocm() """ return core.is_compiled_with_rocm() -- GitLab