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__ | |
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:
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__init__ | ( | self, | |
num_bits = 8 , |
|||
name = None , |
|||
** | kwargs | ||
) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.num_bits | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.fake_quant | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.axis | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.amax | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.learn_amax | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.scale_amax | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.name | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.calib_method | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.unsigned | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.narrow_range | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__str__ | ( | self | ) |
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.__eq__ | ( | self, | |
rhs | |||
) |
Compare 2 descriptors
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.
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.
def pytorch_quantization.tensor_quant.ScaledQuantDescriptor.from_yaml | ( | cls, | |
yaml_str | |||
) |
Create descriptor from yaml str
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |