get_autocast_dtype
获取当前上下文中自动混合精度的默认数据类型。
参数
device_type (str, 可选) - 设备类型,默认为 None。注意:在 PaddlePaddle 中所有设备共享同一套自动混合精度配置,实际返回值与设备类型无关。
返回
字符串,当前上下文中自动混合精度的默认数据类型。
代码示例
>>> # Demo1: Get default auto-mixed-precision dtype
>>> import paddle
>>> paddle.device.set_device('gpu')
>>> print(paddle.get_autocast_dtype())
float16
>>> # Demo2: Enable auto-mixed-precision and get the dtype
>>> with paddle.amp.auto_cast():
... print(paddle.get_autocast_dtype())
float16