TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
pytorch_quantization.tensor_quant.ScaledQuantDescriptor Class Reference

Public Member Functions

def __init__ (self, num_bits=8, name=None, **kwargs)
 
def num_bits (self)
 
def fake_quant (self)
 
def axis (self)
 
def amax (self)
 
def learn_amax (self)
 
def scale_amax (self)
 
def name (self)
 
def calib_method (self)
 
def unsigned (self)
 
def narrow_range (self)
 
def __str__ (self)
 
def __eq__ (self, rhs)
 
def dict (self)
 
def to_yaml (self)
 
def from_yaml (cls, yaml_str)
 

Private Attributes

 _num_bits
 
 _name
 
 _fake_quant
 
 _axis
 
 _learn_amax
 
 _amax
 
 _scale_amax
 
 _calib_method
 
 _unsigned
 
 _narrow_range
 
 __dict__
 

Detailed Description

Supportive descriptor of quantization

Describe how a tensor should be quantized. A QuantDescriptor and a tensor defines a quantized tensor.

Args:
    num_bits: An integer. Number of bits of quantization. It is used to calculate scaling factor. Default 8.
    name: Seems a nice thing to have

Keyword Arguments:
    fake_quant: A boolean. If True, use fake quantization mode. Default True.
    axis: None, int or tuple of int. axes which will have its own max for computing scaling factor.
        If None (the default), use per tensor scale.
        Must be in the range [-rank(input_tensor), rank(input_tensor)).
        e.g. For a KCRS weight tensor, quant_axis=(0) will yield per channel scaling.
        Default None.
    amax: A float or list/ndarray of floats of user specified absolute max range. If supplied,
        ignore quant_axis and use this to quantize. If learn_amax is True, will be used to initialize
        learnable amax. Default None.
    learn_amax: A boolean. If True, learn amax. Default False.
    scale_amax: A float. If supplied, multiply amax by scale_amax. Default None. It is useful for some
        quick experiment.
    calib_method: A string. One of ["max", "histogram"] indicates which calibration to use. Except the simple
        max calibration, other methods are all hisogram based. Default "max".
    unsigned: A Boolean. If True, use unsigned. Default False.

Raises:
    TypeError: If unsupported type is passed in.

Read-only properties:
    - fake_quant:
    - name:
    - learn_amax:
    - scale_amax:
    - axis:
    - calib_method:
    - num_bits:
    - amax:
    - unsigned:

Constructor & Destructor Documentation

◆ __init__()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__init__ (   self,
  num_bits = 8,
  name = None,
**  kwargs 
)

Member Function Documentation

◆ num_bits()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.num_bits (   self)

◆ fake_quant()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.fake_quant (   self)

◆ axis()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.axis (   self)

◆ amax()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.amax (   self)

◆ learn_amax()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.learn_amax (   self)

◆ scale_amax()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.scale_amax (   self)

◆ name()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.name (   self)

◆ calib_method()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.calib_method (   self)

◆ unsigned()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.unsigned (   self)

◆ narrow_range()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.narrow_range (   self)

◆ __str__()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__str__ (   self)

◆ __eq__()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__eq__ (   self,
  rhs 
)
Compare 2 descriptors

◆ dict()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.dict (   self)
Serialize to dict

The build-in __dict__ method returns all the attributes, which includes those have default value and have
protected prefix "_". This method only returns those have values other than the default one and don't have _ in
key. Construct a instance by dict returned by this method should get exactly the same instance.
Here is the caller graph for this function:

◆ to_yaml()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.to_yaml (   self)
Create yaml serialization
Some attributes need special treatment to have human readable form, including amax, axis.
Here is the call graph for this function:

◆ from_yaml()

def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.from_yaml (   cls,
  yaml_str 
)
Create descriptor from yaml str

Member Data Documentation

◆ _num_bits

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._num_bits
private

◆ _name

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._name
private

◆ _fake_quant

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._fake_quant
private

◆ _axis

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._axis
private

◆ _learn_amax

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._learn_amax
private

◆ _amax

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._amax
private

◆ _scale_amax

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._scale_amax
private

◆ _calib_method

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._calib_method
private

◆ _unsigned

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._unsigned
private

◆ _narrow_range

pytorch_quantization.tensor_quant.ScaledQuantDescriptor._narrow_range
private

◆ __dict__

pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__dict__
private

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