Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions docs/api/paddle/cuda/Event_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. _cn_api_paddle_cuda_Event:

Event
-------------------------------

.. py:class:: paddle.cuda.Event(enable_timing=False, blocking=False, interprocess=False)

event 的句柄。

参数
::::::::::::

- **enable_timing** (bool,可选) - event 是否需要统计时间。默认值为 False。
- **blocking** (bool,可选) - wait()函数是否被阻塞。默认值为 False。
- **interprocess** (bool,可选) - event 是否能在进程间共享。默认值为 False。

返回
::::::::::::
None

代码示例
::::::::::::

COPY-FROM: paddle.cuda.Event


方法
::::::::::::
record(stream=None)
'''''''''

记录 event 到给定的 stream。

**参数**

- **stream** (paddle.cuda.Stream,可选) - stream 的句柄。如果为 None,stream 为当前的 stream。默认值为 None。

**代码示例**

COPY-FROM: paddle.cuda.Event.record

query()
'''''''''

查询 event 的状态。

**返回**

一个 boolean 变量,用于标识当前 event 获取的所有任务是否被完成。

**代码示例**

COPY-FROM: paddle.cuda.Event.query


synchronize()
'''''''''

等待当前 event 完成。

**代码示例**

COPY-FROM: paddle.cuda.Event.synchronize
3 changes: 3 additions & 0 deletions docs/api/paddle/cuda/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ PyTorch 兼容函数
" :ref:`max_memory_allocated <cn_api_paddle_cuda_max_memory_allocated>` ", "获取最大内存分配量"
" :ref:`reset_peak_memory_stats <cn_api_paddle_cuda_reset_peak_memory_stats>` ", "重置峰值内存统计"
" :ref:`get_device_capability <cn_api_paddle_cuda_get_device_capability>` ", "返回指定设备的计算能力"
" :ref:`is_bf16_supported <_cn_api_paddle_cuda_is_bf16_supported>` ", "判断当前设备是否支持 BF16 类型运算"
" :ref:`StreamContext <_cn_api_paddle_cuda_StreamContext>` ", "CUDA 流上下文类"
" :ref:`Event <_cn_api_paddle_cuda_Event>` ", "CUDA 事件类"
16 changes: 16 additions & 0 deletions docs/api/paddle/cuda/StreamContext_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. _cn_api_paddle_cuda_StreamContext:

StreamContext
-------------

.. py:class:: paddle.cuda.StreamContext(stream)

该上下文管理器用于临时切换当前 CUDA 流,离开上下文后自动恢复之前的流。

参数:
::::::::::::
- **stream** (paddle.cuda.Stream) - 要切换到的 CUDA 流对象

代码示例
::::::::::::
COPY-FROM: paddle.cuda.StreamContext
20 changes: 20 additions & 0 deletions docs/api/paddle/cuda/is_bf16_supported_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. _cn_api_paddle_cuda_is_bf16_supported:

is_bf16_supported
-----------------

.. py:function:: paddle.cuda.is_bf16_supported(including_emulation: bool = True)

该函数用于检查当前 CUDA 设备是否支持 bfloat16 计算。

参数
:::::::::
- **including_emulation** (bool) - 是否包括模拟支持。默认为 True。True 表示包括模拟支持,False 表示不包括模拟支持。

返回:
::::::::::::
- bool - 如果设备支持 bfloat16 计算则返回 True,否则返回 False

代码示例
::::::::::::
COPY-FROM: paddle.cuda.is_bf16_supported
3 changes: 1 addition & 2 deletions docs/api/paddle/device/Event_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
Event
-------------------------------

.. py:class:: paddle.device.Event(device=None, enable_timing=False, blocking=False, interprocess=False)
.. py:class:: paddle.device.Event(enable_timing=False, blocking=False, interprocess=False)

event 的句柄。

参数
::::::::::::

- **device** (paddle.CUDAPlace|paddle.CustomPlace|str) - 希望分配 event 的设备或设备类型。如果为 None,则为当前期望的 place。默认值为 None。
- **enable_timing** (bool,可选) - event 是否需要统计时间。默认值为 False。
- **blocking** (bool,可选) - wait()函数是否被阻塞。默认值为 False。
- **interprocess** (bool,可选) - event 是否能在进程间共享。默认值为 False。
Expand Down
2 changes: 2 additions & 0 deletions docs/api/paddle/device/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ paddle.device 目录下包含 cuda 目录和 xpu 目录, cuda 目录中存放
" :ref:`device <_cn_api_paddle_device_device>` ", "临时使用设备"
" :ref:`get_device_name <cn_api_paddle_device_get_device_name>` ", "返回指定设备的名称"
" :ref:`manual_seed <_cn_api_paddle_device_manual_seed>` ", "设置当前设备的随机数种子"
" :ref:`is_bf16_supported <_cn_api_paddle_device_is_bf16_supported>` ", "判断当前设备是否具有 BF16 类型运算的硬件加速能力"
" :ref:`get_stream_from_external <_cn_api_paddle_device_get_stream_from_external>` ", "从外部获取一个 Stream 对象,并返回一个 Paddle Stream 对象"
.. _cn_device_compile:

编译环境检测
Expand Down
21 changes: 21 additions & 0 deletions docs/api/paddle/device/get_stream_from_external_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _cn_api_paddle_device_get_stream_from_external:

get_stream_from_external
------------------------

.. py:function:: paddle.device.get_stream_from_external(data_ptr, device=None)

从外部创建的 CUDA 流创建 Paddle 流对象。

参数
::::::::::::
- **data_ptr** (int) - 外部 CUDA 流的指针值
- **device** (int, 可选) - 设备 ID,默认为 None

返回
::::::::::::
paddle.device.Stream: 包装后的 Paddle 流对象

代码示例
::::::::::::
COPY-FROM: paddle.device.get_stream_from_external
20 changes: 20 additions & 0 deletions docs/api/paddle/device/is_bf16_supported_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. _cn_api_paddle_device_is_bf16_supported:

is_bf16_supported
-----------------

.. py:function:: paddle.device.is_bf16_supported(including_emulation: bool = True)

该函数用于检查当前 CUDA 设备是否支持 bfloat16 计算。

参数
:::::::::
- **including_emulation** (bool) - 是否包括模拟支持。默认为 True。True 表示包括模拟支持,False 表示不包括模拟支持。

返回:
::::::::::::
- bool - 如果设备支持 bfloat16 计算则返回 True,否则返回 False

代码示例
::::::::::::
COPY-FROM: paddle.device.is_bf16_supported