Skip to content

Commit e5490df

Browse files
authored
add func_cn in Layer. (#5754)
1 parent d6d8a60 commit e5490df

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _cn_api_amp_is_bfloat16_supported:
2+
3+
is_bfloat16_supported
4+
-------------------------------
5+
6+
.. py:function:: paddle.amp.is_bfloat16_supported(device=None)
7+
8+
9+
在自动混合精度策略(AMP)场景下判断设备是否支持 bfloat16。
10+
11+
参数
12+
::::::::::::
13+
14+
- **device** (str|None, optional) - 指定要查询的设备,它可以是 cpu、 gpu、 xpu、gpu:x、xpu:x。其中,x 是 GPU、 XPU 的编号。如果 ``device`` 为 None, 则查询当前设备(与飞桨安装版本保持一致),默认为 None。
15+
16+
17+
代码示例
18+
:::::::::
19+
COPY-FROM: paddle.amp.is_bfloat16_supported
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _cn_api_amp_is_float16_supported:
2+
3+
is_float16_supported
4+
-------------------------------
5+
6+
.. py:function:: paddle.amp.is_float16_supported(device=None)
7+
8+
9+
在自动混合精度策略(AMP)场景下判断设备是否支持 float16。
10+
11+
参数
12+
::::::::::::
13+
14+
- **device** (str|None, optional) - 指定要查询的设备,它可以是 cpu、 gpu、 xpu、gpu:x、xpu:x。其中,x 是 GPU、 XPU 的编号。如果 ``device`` 为 None, 则查询当前设备(与飞桨安装版本保持一致), 默认为 None。
15+
16+
17+
代码示例
18+
:::::::::
19+
COPY-FROM: paddle.amp.is_float16_supported

docs/api/paddle/nn/Layer_cn.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,48 @@ to(device=None, dtype=None, blocking=None)
406406
**代码示例**
407407

408408
COPY-FROM: paddle.nn.Layer.to
409+
410+
float(excluded_layers=None)
411+
'''''''''
412+
413+
将所有浮点型的参数和通过 ``register_buffers()`` 注册的 Buffer 变量转换为 float 数据类型。
414+
415+
**参数**
416+
417+
- **excluded_layers** (list|nn.Layer|None,可选) - 不需要转换数据类型的层。如果 ``excluded_layers`` 为 None,则转换所有浮点参数和缓冲区,默认值:None。
418+
419+
**代码示例**
420+
421+
COPY-FROM: paddle.nn.Layer.float
422+
423+
float16(excluded_layers=None)
424+
'''''''''
425+
426+
将所有浮点型的参数和通过 ``register_buffers()`` 注册的 Buffer 变量转换为 float16 数据类型。
427+
428+
.. note::
429+
nn.BatchNorm 不支持 float16 类型的权重,默认不对其权重进行类型转换。
430+
431+
**参数**
432+
433+
- **excluded_layers** (list|nn.Layer|None,可选) - 不需要转换数据类型的层。如果 ``excluded_layers`` 为 None,则转换除 ``nn.BatchNorm`` 之外的所有浮点参数和缓冲区,默认值:None。
434+
435+
**代码示例**
436+
437+
COPY-FROM: paddle.nn.Layer.float16
438+
439+
bfloat16(excluded_layers=None)
440+
'''''''''
441+
442+
将所有浮点型的参数和通过 ``register_buffers()`` 注册的 Buffer 变量转换为 bfloat16 数据类型。
443+
444+
.. note::
445+
nn.BatchNorm 不支持 bfloat16 类型的权重,默认不对其权重进行类型转换。
446+
447+
**参数**
448+
449+
- **excluded_layers** (list|nn.Layer|None,可选) - 不需要转换数据类型的层。如果 ``excluded_layers`` 为 None,则转换除 ``nn.BatchNorm`` 之外的所有浮点参数和缓冲区,默认值:None。
450+
451+
**代码示例**
452+
453+
COPY-FROM: paddle.nn.Layer.bfloat16

0 commit comments

Comments
 (0)