TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
pytorch_quantization.calib.histogram.HistogramCalibrator Class Reference
Inheritance diagram for pytorch_quantization.calib.histogram.HistogramCalibrator:
Collaboration diagram for pytorch_quantization.calib.histogram.HistogramCalibrator:

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def pytorch_quantization.calib.histogram.HistogramCalibrator.__init__ (   self,
  num_bits,
  axis,
  unsigned,
  num_bins = 2048,
  grow_method = None,
  skip_zeros = False 
)

Member Function Documentation

◆ collect()

def pytorch_quantization.calib.histogram.HistogramCalibrator.collect (   self,
  x 
)
Collect histogram

Reimplemented from pytorch_quantization.calib.calibrator._Calibrator.

◆ reset()

def pytorch_quantization.calib.histogram.HistogramCalibrator.reset (   self)
Reset the collected histogram

Reimplemented from pytorch_quantization.calib.calibrator._Calibrator.

◆ _compute_amax_entropy()

def pytorch_quantization.calib.histogram.HistogramCalibrator._compute_amax_entropy (   self,
  stride,
  start_bin 
)
private
Returns amax that minimizes KL-Divergence of the collected histogram
Here is the caller graph for this function:

◆ _compute_amax_mse()

def pytorch_quantization.calib.histogram.HistogramCalibrator._compute_amax_mse (   self,
  stride,
  start_bin 
)
private
Returns amax that minimizes MSE of the collected histogram
Here is the caller graph for this function:

◆ _compute_amax_percentile()

def pytorch_quantization.calib.histogram.HistogramCalibrator._compute_amax_percentile (   self,
  percentile 
)
private
Returns amax that clips the percentile fraction of collected data
Here is the caller graph for this function:

◆ compute_amax() [1/2]

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
Here is the call graph for this function:

◆ __str__()

def pytorch_quantization.calib.histogram.HistogramCalibrator.__str__ (   self)

◆ __repr__()

def pytorch_quantization.calib.histogram.HistogramCalibrator.__repr__ (   self)

◆ compute_amax() [2/2]

def pytorch_quantization.calib.calibrator._Calibrator.compute_amax (   self,
args,
**  kwargs 
)
inherited
Abstract method: compute the amax from the collected data

Returns:
    amax: a tensor

Member Data Documentation

◆ _num_bins

pytorch_quantization.calib.histogram.HistogramCalibrator._num_bins
private

◆ _skip_zeros

pytorch_quantization.calib.histogram.HistogramCalibrator._skip_zeros
private

◆ _calib_bin_edges

pytorch_quantization.calib.histogram.HistogramCalibrator._calib_bin_edges
private

◆ _calib_hist

pytorch_quantization.calib.histogram.HistogramCalibrator._calib_hist
private

◆ _num_bits

pytorch_quantization.calib.calibrator._Calibrator._num_bits
privateinherited

◆ _axis

pytorch_quantization.calib.calibrator._Calibrator._axis
privateinherited

◆ _unsigned

pytorch_quantization.calib.calibrator._Calibrator._unsigned
privateinherited

The documentation for this class was generated from the following file: