#[derive(Clone, Debug)]
pub struct FakeQuantConfig {
pub bits: usize,
pub symmetric: bool,
pub qmin: i32,
pub qmax: i32,
}
impl FakeQuantConfig {
pub fn symmetric(bits: usize) -> Self {
let qmax = (1 << (bits - 1)) - 1; let qmin = -qmax;
Self { bits, symmetric: true, qmin, qmax }
}
pub fn asymmetric(bits: usize) -> Self {
let qmax = (1 << bits) - 1; Self { bits, symmetric: false, qmin: 0, qmax }
}
pub fn q4_symmetric() -> Self {
Self::symmetric(4)
}
pub fn q8_symmetric() -> Self {
Self::symmetric(8)
}
}
impl Default for FakeQuantConfig {
fn default() -> Self {
Self::q8_symmetric()
}
}