Skip to content

Commit

Permalink
Fix device bugs (PaddlePaddle#3647)
Browse files Browse the repository at this point in the history
* update_device_api bugs

* fix device apis

* fix xpu docs

* fix xpu docs
  • Loading branch information
TCChenlong authored Jul 6, 2021
1 parent 8aed488 commit 3f8ec37
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 29 deletions.
12 changes: 2 additions & 10 deletions docs/api/paddle/device/XPUPlace_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
XPUPlace
-------------------------------

.. py:class:: paddle.XPUPlace
.. py:class:: paddle.device.XPUPlace
Expand All @@ -18,12 +18,4 @@ XPUPlace

**代码示例**

.. code-block:: python
import paddle
place = paddle.XPUPlace(0)
COPY-FROM: paddle.device.XPUPlace
4 changes: 2 additions & 2 deletions docs/api/paddle/device/get_cudnn_version_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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。
Expand All @@ -16,4 +16,4 @@ get_cudnn_version
import paddle
device = paddle.get_cudnn_version()
device = paddle.device.get_cudnn_version()
4 changes: 2 additions & 2 deletions docs/api/paddle/device/get_device_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`` 。
Expand All @@ -16,4 +16,4 @@ get_device
import paddle
device = paddle.get_device()
device = paddle.device.get_device()
4 changes: 2 additions & 2 deletions docs/api/paddle/device/is_compiled_with_cuda_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
is_compiled_with_cuda
-------------------------------

.. py:function:: paddle.is_compiled_with_cuda()
.. py:function:: paddle.device.is_compiled_with_cuda()
Expand All @@ -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()
5 changes: 3 additions & 2 deletions docs/api/paddle/device/is_compiled_with_npu_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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。
Expand All @@ -12,5 +13,5 @@ is_compiled_with_npu

**示例代码**

COPY-FROM: paddle.is_compiled_with_npu
COPY-FROM: paddle.device.is_compiled_with_npu

4 changes: 2 additions & 2 deletions docs/api/paddle/device/is_compiled_with_rocm_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
is_compiled_with_rocm
-------------------------------

.. py:function:: paddle.is_compiled_with_rocm()
.. py:function:: paddle.device.is_compiled_with_rocm()
Expand All @@ -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()
9 changes: 2 additions & 7 deletions docs/api/paddle/device/is_compiled_with_xpu_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
is_compiled_with_xpu
-------------------------------

.. py:function:: paddle.is_compiled_with_xpu()
.. py:function:: paddle.device.is_compiled_with_xpu()
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set_device
-------------------------------

.. py:function:: paddle.set_device(device)
.. py:function:: paddle.device.set_device(device)
Paddle支持包括CPU和GPU在内的多种设备运行,设备可以通过字符串标识符表示,此功能可以指定OP运行的全局设备。
Expand All @@ -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)
Expand Down

0 comments on commit 3f8ec37

Please sign in to comment.