Public Member Functions | |
def | __init__ (self, num_bits, axis, unsigned, num_bins=2048, grow_method=None, skip_zeros=False) |
def | collect (self, x) |
def | reset (self) |
def | compute_amax (self, str method, *int stride=1, int start_bin=128, float percentile=99.99) |
def | __str__ (self) |
def | __repr__ (self) |
def | compute_amax (self, *args, **kwargs) |
Private Member Functions | |
def | _compute_amax_entropy (self, stride, start_bin) |
def | _compute_amax_mse (self, stride, start_bin) |
def | _compute_amax_percentile (self, percentile) |
Private Attributes | |
_num_bins | |
_skip_zeros | |
_calib_bin_edges | |
_calib_hist | |
_num_bits | |
_axis | |
_unsigned | |
Unified histogram calibrator Histogram will be only collected once. compute_amax() performs entropy, percentile, or mse calibration based on arguments Args: num_bits: An integer. Number of bits of quantization. axis: A tuple. see QuantDescriptor. unsigned: A boolean. using unsigned quantization. num_bins: An integer. Number of histograms bins. Default 2048. grow_method: A string. DEPRECATED. default None. skip_zeros: A boolean. If True, skips zeros when collecting data for histogram. Default False.
def pytorch_quantization.calib.histogram.HistogramCalibrator.__init__ | ( | self, | |
num_bits, | |||
axis, | |||
unsigned, | |||
num_bins = 2048 , |
|||
grow_method = None , |
|||
skip_zeros = False |
|||
) |
def pytorch_quantization.calib.histogram.HistogramCalibrator.collect | ( | self, | |
x | |||
) |
Collect histogram
Reimplemented from pytorch_quantization.calib.calibrator._Calibrator.
def pytorch_quantization.calib.histogram.HistogramCalibrator.reset | ( | self | ) |
Reset the collected histogram
Reimplemented from pytorch_quantization.calib.calibrator._Calibrator.
|
private |
Returns amax that minimizes KL-Divergence of the collected histogram
|
private |
Returns amax that minimizes MSE of the collected histogram
|
private |
Returns amax that clips the percentile fraction of collected data
def pytorch_quantization.calib.histogram.HistogramCalibrator.compute_amax | ( | self, | |
str | method, | ||
*int | stride = 1 , |
||
int | start_bin = 128 , |
||
float | percentile = 99.99 |
||
) |
Compute the amax from the collected histogram Args: method: A string. One of ['entropy', 'mse', 'percentile'] Keyword Arguments: stride: An integer. Default 1 start_bin: An integer. Default 128 percentils: A float number between [0, 100]. Default 99.99. Returns: amax: a tensor
def pytorch_quantization.calib.histogram.HistogramCalibrator.__str__ | ( | self | ) |
def pytorch_quantization.calib.histogram.HistogramCalibrator.__repr__ | ( | self | ) |
Reimplemented from pytorch_quantization.calib.calibrator._Calibrator.
|
inherited |
Abstract method: compute the amax from the collected data Returns: amax: a tensor
|
private |
|
private |
|
private |
|
private |
|
privateinherited |
|
privateinherited |
|
privateinherited |