From 3f8ec371017260eb7f2b7f3da808de1fac560903 Mon Sep 17 00:00:00 2001 From: Chen Long <1300851984@qq.com> Date: Tue, 6 Jul 2021 13:38:45 +0800 Subject: [PATCH] Fix device bugs (#3647) * update_device_api bugs * fix device apis * fix xpu docs * fix xpu docs --- docs/api/paddle/device/XPUPlace_cn.rst | 12 ++---------- docs/api/paddle/device/get_cudnn_version_cn.rst | 4 ++-- docs/api/paddle/device/get_device_cn.rst | 4 ++-- docs/api/paddle/device/is_compiled_with_cuda_cn.rst | 4 ++-- docs/api/paddle/device/is_compiled_with_npu_cn.rst | 5 +++-- docs/api/paddle/device/is_compiled_with_rocm_cn.rst | 4 ++-- docs/api/paddle/device/is_compiled_with_xpu_cn.rst | 9 ++------- docs/api/paddle/{ => device}/set_device_cn.rst | 4 ++-- 8 files changed, 17 insertions(+), 29 deletions(-) rename docs/api/paddle/{ => device}/set_device_cn.rst (91%) diff --git a/docs/api/paddle/device/XPUPlace_cn.rst b/docs/api/paddle/device/XPUPlace_cn.rst index b7fa4b75b7a..23d0aa37c07 100644 --- a/docs/api/paddle/device/XPUPlace_cn.rst +++ b/docs/api/paddle/device/XPUPlace_cn.rst @@ -3,7 +3,7 @@ XPUPlace ------------------------------- -.. py:class:: paddle.XPUPlace +.. py:class:: paddle.device.XPUPlace @@ -18,12 +18,4 @@ XPUPlace **代码示例** -.. code-block:: python - - import paddle - - place = paddle.XPUPlace(0) - - - - +COPY-FROM: paddle.device.XPUPlace diff --git a/docs/api/paddle/device/get_cudnn_version_cn.rst b/docs/api/paddle/device/get_cudnn_version_cn.rst index 03ef24cdf29..42d8f7e4f12 100644 --- a/docs/api/paddle/device/get_cudnn_version_cn.rst +++ b/docs/api/paddle/device/get_cudnn_version_cn.rst @@ -3,7 +3,7 @@ get_cudnn_version ------------------------------- -.. py:function:: paddle.get_cudnn_version() +.. py:function:: paddle.device.get_cudnn_version() 此函数返回cudnn的版本。 返回值是int,它表示cudnn版本。 例如,如果返回7600,则表示cudnn的版本为7.6。 @@ -16,4 +16,4 @@ get_cudnn_version import paddle - device = paddle.get_cudnn_version() + device = paddle.device.get_cudnn_version() diff --git a/docs/api/paddle/device/get_device_cn.rst b/docs/api/paddle/device/get_device_cn.rst index bf351ac2afc..08b549ab35e 100644 --- a/docs/api/paddle/device/get_device_cn.rst +++ b/docs/api/paddle/device/get_device_cn.rst @@ -3,7 +3,7 @@ get_device ------------------------------- -.. py:function:: paddle.get_device() +.. py:function:: paddle.device.get_device() 该功能返回当前程序运行的全局设备,返回的是一个类似于 ``cpu``、 ``gpu:x``、 ``xpu:x`` 或者 ``npu:x`` 字符串,如果没有设置全局设备,当cuda可用的时候返回 ``gpu:0`` ,当cuda不可用的时候返回 ``cpu`` 。 @@ -16,4 +16,4 @@ get_device import paddle - device = paddle.get_device() + device = paddle.device.get_device() diff --git a/docs/api/paddle/device/is_compiled_with_cuda_cn.rst b/docs/api/paddle/device/is_compiled_with_cuda_cn.rst index 3bbe4f90f1a..da8cd116e6d 100644 --- a/docs/api/paddle/device/is_compiled_with_cuda_cn.rst +++ b/docs/api/paddle/device/is_compiled_with_cuda_cn.rst @@ -3,7 +3,7 @@ is_compiled_with_cuda ------------------------------- -.. py:function:: paddle.is_compiled_with_cuda() +.. py:function:: paddle.device.is_compiled_with_cuda() @@ -19,6 +19,6 @@ is_compiled_with_cuda .. code-block:: python import paddle - support_gpu = paddle.is_compiled_with_cuda() + support_gpu = paddle.device.is_compiled_with_cuda() diff --git a/docs/api/paddle/device/is_compiled_with_npu_cn.rst b/docs/api/paddle/device/is_compiled_with_npu_cn.rst index 397a94e2950..b52a9904d27 100644 --- a/docs/api/paddle/device/is_compiled_with_npu_cn.rst +++ b/docs/api/paddle/device/is_compiled_with_npu_cn.rst @@ -3,7 +3,8 @@ is_compiled_with_npu ------------------------------- -.. py:function:: paddle.fluid.is_compiled_with_npu() +.. py:function:: paddle.device.is_compiled_with_npu() + 检查 ``whl`` 包是否可以被用来在 NPU 上运行模型。 返回:支持 NPU 则为True,否则为False。 @@ -12,5 +13,5 @@ is_compiled_with_npu **示例代码** -COPY-FROM: paddle.is_compiled_with_npu +COPY-FROM: paddle.device.is_compiled_with_npu diff --git a/docs/api/paddle/device/is_compiled_with_rocm_cn.rst b/docs/api/paddle/device/is_compiled_with_rocm_cn.rst index 35c26ba80cf..2bcabf49fb5 100644 --- a/docs/api/paddle/device/is_compiled_with_rocm_cn.rst +++ b/docs/api/paddle/device/is_compiled_with_rocm_cn.rst @@ -3,7 +3,7 @@ is_compiled_with_rocm ------------------------------- -.. py:function:: paddle.is_compiled_with_rocm() +.. py:function:: paddle.device.is_compiled_with_rocm() @@ -17,6 +17,6 @@ is_compiled_with_rocm .. code-block:: python import paddle - support_gpu = paddle.is_compiled_with_rocm() + support_rocm = paddle.device.is_compiled_with_rocm() diff --git a/docs/api/paddle/device/is_compiled_with_xpu_cn.rst b/docs/api/paddle/device/is_compiled_with_xpu_cn.rst index b1e87083c88..14105bb4fa4 100644 --- a/docs/api/paddle/device/is_compiled_with_xpu_cn.rst +++ b/docs/api/paddle/device/is_compiled_with_xpu_cn.rst @@ -3,7 +3,7 @@ is_compiled_with_xpu ------------------------------- -.. py:function:: paddle.is_compiled_with_xpu() +.. py:function:: paddle.device.is_compiled_with_xpu() @@ -14,9 +14,4 @@ is_compiled_with_xpu **示例代码** -.. code-block:: python - - import paddle - support_xpu = paddle.is_compiled_with_xpu() - - +COPY-FROM: paddle.device.is_compiled_with_xpu diff --git a/docs/api/paddle/set_device_cn.rst b/docs/api/paddle/device/set_device_cn.rst similarity index 91% rename from docs/api/paddle/set_device_cn.rst rename to docs/api/paddle/device/set_device_cn.rst index 45f16af525f..1602b49a73f 100644 --- a/docs/api/paddle/set_device_cn.rst +++ b/docs/api/paddle/device/set_device_cn.rst @@ -3,7 +3,7 @@ set_device ------------------------------- -.. py:function:: paddle.set_device(device) +.. py:function:: paddle.device.set_device(device) Paddle支持包括CPU和GPU在内的多种设备运行,设备可以通过字符串标识符表示,此功能可以指定OP运行的全局设备。 @@ -19,7 +19,7 @@ Paddle支持包括CPU和GPU在内的多种设备运行,设备可以通过字 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)