Ejemplo n.º 1
0
 def __init__(self,
              float_to_int_impl: Module,
              bit_width_impl: Module,
              quant_delay_steps: int = 0):
     super(TruncIntQuant, self).__init__()
     self.msb_clamp_bit_width_impl = bit_width_impl
     self.float_to_int_impl = float_to_int_impl
     self.delay_wrapper = DelayWrapper(quant_delay_steps)
Ejemplo n.º 2
0
 def __init__(self,
              scaling_impl: Module,
              threshold: float,
              quant_delay_steps: int = None):
     super(TernaryQuant, self).__init__()
     self.scaling_impl = scaling_impl
     self.threshold = threshold
     self.bit_width = BitWidthConst(2)
     self.zero_point = StatelessBuffer(torch.tensor(0.0))
     self.delay_wrapper = DelayWrapper(quant_delay_steps)
Ejemplo n.º 3
0
 def __init__(
         self,
         scaling_impl: Module,
         tensor_clamp_impl: Module = TensorClamp(),
         quant_delay_steps: int = 0):
     super(ClampedBinaryQuant, self).__init__()
     self.scaling_impl = scaling_impl
     self.bit_width = BitWidthConst(1)
     self.zero_point = StatelessBuffer(torch.tensor(0.0))
     self.delay_wrapper = DelayWrapper(quant_delay_steps)
     self.tensor_clamp_impl = tensor_clamp_impl
Ejemplo n.º 4
0
 def __init__(self,
              narrow_range: bool,
              signed: bool,
              float_to_int_impl: Module = RoundSte(),
              tensor_clamp_impl: Module = TensorClamp(),
              quant_delay_steps: int = 0):
     super(IntQuant, self).__init__()
     self.float_to_int_impl = float_to_int_impl
     self.tensor_clamp_impl = tensor_clamp_impl
     self.signed = signed
     self.narrow_range = narrow_range
     self.delay_wrapper = DelayWrapper(quant_delay_steps)