Rate this Page

MappingType#

classtorch.ao.quantization.observer.MappingType(value)[source]#

How floating point number is mapped to integer number

symmetric mapping means floating point range is symmetrically mapped to integer rangelet’s say we have floating point range (-3.5, 10.2) and integer range (-8, 7) (int4)we’ll use (-10.2, 10.2) as the range for floating point and map that to (-8, 7)e.g. scale = (10.2 - (-10.2)) / (7 - (-8))

SYMMETRIC_NO_CLIPPING_ERR is a variant of symmetric mapping, where the scale is the max of sminand smax, where smin = min_val_neg / quant_min, and smax = max_val_pos / quant_max. By calculatingsmin and smax individually, there can be less round error on negative values, and no out-of-rangeof all floating point values.

asymmetric mapping means we just directly map the floating point range to integer range,for the above example, we will map (-3.5, 10.2) to (-8, 7) and calculate quantization parameterbased on this mappinge.g. scale = (10.2 - (-3.5)) / (7 - (-8))