You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add pure fp16 major function in auto_cast & tracer
* support master weight in dygraph for pure fp16
* check mix dtype of fp16&fp32 for check_finite_and_unscale op
* change pure fp16 funtion name
* refine some bug in auto_cast
* refine auto_cast interface logic
* add param _casted_by_pure_fp16 for class Layer
* support state_dict hook for save model by user appointed dtype in pure_fp16_decorator
* refine pure_fp16_decorator as decorator
* add unittest
* add comment
* add comment
* support recompute
* add comment for auto_cast and decorator
* support to_static_state_dict for paddle.jit.save
* unlimite models num and optimizers num
* add lookup_table in black_list
* fix momentum and layer state_dict
* fix bug in layer state_dict
* fix bug in layer state_dict_helper
* refine unittest
* refine test_momentun_op
* refine interface and some code
* refine amp_decorator interface
* refine pure fp16 interface
* refine master weight interface
custom_black_list(set|list|tuple, optional): The custom black_list. The set of ops that support fp16
35
39
calculation and are considered numerically-dangerous and whose effects may also be
36
40
observed in downstream ops. These ops will not be converted to fp16.
41
+
level(str, optional): Auto mixed precision level. Accepted values are "O1" and "O2": O1 represent mixed precision, the input data type of each operator will be casted by white_list and black_list;
42
+
O2 represent Pure fp16, all operators parameters and input data will be casted to fp16, except operators in black_list, don't support fp16 kernel and batchnorm. Default is O1(amp)
Decorate models and optimizers for auto-mixed-precision. When level is O1(amp), the decorate will do nothing.
86
+
When level is O2(pure fp16), the decorate will cast all parameters of models to FP16, except BatchNorm and LayerNorm.
87
+
88
+
Commonly, it is used together with `auto_cast` to achieve Pure fp16 in imperative mode.
89
+
90
+
Args:
91
+
models(Layer|list of Layer, optional): The defined models by user, models must be either a single model or a list of models. Default is None.
92
+
optimizers(Optimizer|list of Optimizer, optional): The defined optimizers by user, optimizers must be either a single optimizer or a list of optimizers. Default is None.
93
+
level(str, optional): Auto mixed precision level. Accepted values are "O1" and "O2": O1 represent mixed precision, the decorator will do nothing;
94
+
O2 represent Pure fp16, the decorator will cast all parameters of models to FP16, except BatchNorm and LayerNorm. Default is O1(amp)
95
+
master_weight(bool, optinal): For level='O2', whether to use multi-precision during weight updating. If master_weight is None, in O2 level optimizer will use multi-precision. Default is None.
96
+
save_dtype(float, optional): The save model parameter dtype when use `paddle.save` or `paddle.jit.save`,it should be float16, float32, float64 or None.
97
+
The save_dtype will not change model parameters dtype, it just change the state_dict dtype. When save_dtype is None, the save dtype is same as model dtype. Default is None.
98
+
99
+
Examples:
100
+
101
+
.. code-block:: python
102
+
103
+
# required: gpu
104
+
# Demo1: single model and optimizer:
105
+
import paddle
106
+
107
+
model = paddle.nn.Conv2D(3, 2, 3, bias_attr=False)
0 commit comments