pub struct Requantizer {
pub multiplier: i32,
pub shift: i32,
pub zero_point: i8,
pub qmin: i8,
pub qmax: i8,
}Expand description
Rescales an i32 accumulator to int8 storage (C++ Requantizer<int32_t, int8_t>).
multiplier (Q0.31) and shift encode the ratio
input_scale * weight_scale / output_scale, and a negative shift means the
ratio is above one. zero_point is the output tensor’s, and the result
saturates to [qmin, qmax] (usually [-128, 127]; raise qmin to the zero
point to fuse a ReLU). Build one from float scales with
calibration::build_requantizer on the host (std feature), or write the
five integers out as constants.
Fields§
§multiplier: i32Q0.31 fixed-point multiplier, normally in [2^30, 2^31).
shift: i32Power-of-two exponent: positive divides, negative multiplies. tinymind (C++)’s
contract is -31..=31 (what calibration::quantize_multiplier returns);
outside it the result is still defined (see the module docs).
zero_point: i8Output tensor zero point.
qmin: i8Lowest output value.
qmax: i8Highest output value.