Skip to content

Commit ea042e2

Browse files
committed
cuda_apis
1 parent 1f43849 commit ea042e2

File tree

8 files changed

+146
-2
lines changed

8 files changed

+146
-2
lines changed

docs/api/paddle/cuda/Event_cn.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.. _cn_api_paddle_cuda_Event:
2+
3+
Event
4+
-------------------------------
5+
6+
.. py:class:: paddle.cuda.Event(enable_timing=False, blocking=False, interprocess=False)
7+
8+
event 的句柄。
9+
10+
参数
11+
::::::::::::
12+
13+
- **enable_timing** (bool,可选) - event 是否需要统计时间。默认值为 False。
14+
- **blocking** (bool,可选) - wait()函数是否被阻塞。默认值为 False。
15+
- **interprocess** (bool,可选) - event 是否能在进程间共享。默认值为 False。
16+
17+
返回
18+
::::::::::::
19+
None
20+
21+
代码示例
22+
::::::::::::
23+
24+
COPY-FROM: paddle.cuda.Event
25+
26+
27+
方法
28+
::::::::::::
29+
record(stream=None)
30+
'''''''''
31+
32+
记录 event 到给定的 stream。
33+
34+
**参数**
35+
36+
- **stream** (paddle.cuda.Stream,可选) - stream 的句柄。如果为 None,stream 为当前的 stream。默认值为 None。
37+
38+
**代码示例**
39+
40+
COPY-FROM: paddle.cuda.Event.record
41+
42+
query()
43+
'''''''''
44+
45+
查询 event 的状态。
46+
47+
**返回**
48+
49+
一个 boolean 变量,用于标识当前 event 获取的所有任务是否被完成。
50+
51+
**代码示例**
52+
53+
COPY-FROM: paddle.cuda.Event.query
54+
55+
56+
synchronize()
57+
'''''''''
58+
59+
等待当前 event 完成。
60+
61+
**代码示例**
62+
63+
COPY-FROM: paddle.cuda.Event.synchronize

docs/api/paddle/cuda/Overview_cn.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ PyTorch 兼容函数
3838
" :ref:`max_memory_allocated <cn_api_paddle_cuda_max_memory_allocated>` ", "获取最大内存分配量"
3939
" :ref:`reset_peak_memory_stats <cn_api_paddle_cuda_reset_peak_memory_stats>` ", "重置峰值内存统计"
4040
" :ref:`get_device_capability <cn_api_paddle_cuda_get_device_capability>` ", "返回指定设备的计算能力"
41+
" :ref:`is_bf16_supported <_cn_api_paddle_cuda_is_bf16_supported>` ", "判断当前设备是否支持 BF16 类型运算"
42+
" :ref:`StreamContext <_cn_api_paddle_cuda_StreamContext>` ", "CUDA 流上下文类"
43+
" :ref:`Event <_cn_api_paddle_cuda_Event>` ", "CUDA 事件类"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. _cn_api_paddle_cuda_StreamContext:
2+
3+
StreamContext
4+
-------------
5+
6+
.. py:class:: paddle.cuda.StreamContext(stream)
7+
8+
该上下文管理器用于临时切换当前 CUDA 流,离开上下文后自动恢复之前的流。
9+
10+
参数:
11+
::::::::::::
12+
- **stream** (paddle.cuda.Stream) - 要切换到的 CUDA 流对象
13+
14+
代码示例
15+
::::::::::::
16+
COPY-FROM: paddle.cuda.StreamContext
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _cn_api_paddle_cuda_is_bf16_supported:
2+
3+
is_bf16_supported
4+
-----------------
5+
6+
.. py:function:: paddle.cuda.is_bf16_supported(including_emulation: bool = True)
7+
8+
该函数用于检查当前 CUDA 设备是否支持 bfloat16 计算。
9+
10+
参数
11+
:::::::::
12+
- **including_emulation** (bool) - 是否包括模拟支持。默认为 True。True 表示包括模拟支持,False 表示不包括模拟支持。
13+
14+
返回:
15+
::::::::::::
16+
- bool - 如果设备支持 bfloat16 计算则返回 True,否则返回 False
17+
18+
代码示例
19+
::::::::::::
20+
COPY-FROM: paddle.cuda.is_bf16_supported

docs/api/paddle/device/Event_cn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
Event
44
-------------------------------
55

6-
.. py:class:: paddle.device.Event(device=None, enable_timing=False, blocking=False, interprocess=False)
6+
.. py:class:: paddle.device.Event(enable_timing=False, blocking=False, interprocess=False)
77
88
event 的句柄。
99

1010
参数
1111
::::::::::::
1212

13-
- **device** (paddle.CUDAPlace|paddle.CustomPlace|str) - 希望分配 event 的设备或设备类型。如果为 None,则为当前期望的 place。默认值为 None。
1413
- **enable_timing** (bool,可选) - event 是否需要统计时间。默认值为 False。
1514
- **blocking** (bool,可选) - wait()函数是否被阻塞。默认值为 False。
1615
- **interprocess** (bool,可选) - event 是否能在进程间共享。默认值为 False。

docs/api/paddle/device/Overview_cn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ paddle.device 目录下包含 cuda 目录和 xpu 目录, cuda 目录中存放
4949
" :ref:`device <_cn_api_paddle_device_device>` ", "临时使用设备"
5050
" :ref:`get_device_name <cn_api_paddle_device_get_device_name>` ", "返回指定设备的名称"
5151
" :ref:`manual_seed <_cn_api_paddle_device_manual_seed>` ", "设置当前设备的随机数种子"
52+
" :ref:`is_bf16_supported <_cn_api_paddle_device_is_bf16_supported>` ", "判断当前设备是否具有 BF16 类型运算的硬件加速能力"
53+
" :ref:`get_stream_from_external <_cn_api_paddle_device_get_stream_from_external>` ", "从外部获取一个 Stream 对象,并返回一个 Paddle Stream 对象"
5254
.. _cn_device_compile:
5355

5456
编译环境检测
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _cn_api_paddle_device_get_stream_from_external:
2+
3+
get_stream_from_external
4+
------------------------
5+
6+
.. py:function:: paddle.device.get_stream_from_external(data_ptr, device=None)
7+
8+
从外部创建的 CUDA 流创建 Paddle 流对象。
9+
10+
参数
11+
::::::::::::
12+
- **data_ptr** (int) - 外部 CUDA 流的指针值
13+
- **device** (int, 可选) - 设备 ID,默认为 None
14+
15+
返回
16+
::::::::::::
17+
paddle.device.Stream: 包装后的 Paddle 流对象
18+
19+
代码示例
20+
::::::::::::
21+
COPY-FROM: paddle.device.get_stream_from_external
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _cn_api_paddle_device_is_bf16_supported:
2+
3+
is_bf16_supported
4+
-----------------
5+
6+
.. py:function:: paddle.device.is_bf16_supported(including_emulation: bool = True)
7+
8+
该函数用于检查当前 CUDA 设备是否支持 bfloat16 计算。
9+
10+
参数
11+
:::::::::
12+
- **including_emulation** (bool) - 是否包括模拟支持。默认为 True。True 表示包括模拟支持,False 表示不包括模拟支持。
13+
14+
返回:
15+
::::::::::::
16+
- bool - 如果设备支持 bfloat16 计算则返回 True,否则返回 False
17+
18+
代码示例
19+
::::::::::::
20+
COPY-FROM: paddle.device.is_bf16_supported

0 commit comments

Comments
 (0)