get_autocast_cpu_dtype
- paddle. get_autocast_cpu_dtype ( device_type: PlaceLike | None = None ) _DTypeLiteral [source]
-
Get the auto-mixed-precision dtype in the current context if autocast is enabled else default AMP dtype(float16).
- Parameters
-
device_type (PlaceLike, optional) – The device type to check. This argument is ignored for all devices sharing the same AMP state in paddlepaddle.
- Returns
-
The current AMP dtype.
- Return type
-
_DTypeLiteral
Examples
>>> >>> # 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