max — Model Optimizer 0.27.1 (original) (raw)
Calibrator that returns the absolute max of all collected tensors.
Classes
MaxCalibrator | Max calibrator, tracks the maximum value globally. |
---|
class MaxCalibrator
Bases: _Calibrator
Max calibrator, tracks the maximum value globally.
Parameters:
- calib_desc – A MaxCalibDescriptor.
- num_bits – An integer. Number of bits of quantization.
- axis – A tuple. see
QuantizerAttributeConfig
. - unsigned – A boolean. using unsigned quantization.
Readonly Properties:
amaxs: A list of amax. Numpy array is saved as it is likely to be used for some plot.
__init__(num_bits=8, axis=None, unsigned=False, track_amax=False)
Initialize.
property amaxs
Returns the list of amax`s collected so far.
collect(x)
Tracks the absolute max of all tensors.
Parameters:
x – A tensor
Raises:
RuntimeError – If amax shape changes
compute_amax()
Return the absolute max of all tensors collected.
reset()
Reset the collected absolute max.