MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / __init__

Method __init__

lightx2v/utils/quant_utils.py:116–131  ·  view source on GitHub ↗
(self, bit, symmetric, granularity, **kwargs)

Source from the content-addressed store, hash-verified

114
115class IntegerQuantizer(BaseQuantizer):
116 def __init__(self, bit, symmetric, granularity, **kwargs):
117 super().__init__(bit, symmetric, granularity, **kwargs)
118 if "int_range" in self.kwargs:
119 self.qmin = self.kwargs["int_range"][0]
120 self.qmax = self.kwargs["int_range"][1]
121 else:
122 if self.sym:
123 self.qmin = -(2 ** (self.bit - 1))
124 self.qmax = 2 ** (self.bit - 1) - 1
125 else:
126 self.qmin = 0.0
127 self.qmax = 2**self.bit - 1
128
129 self.qmin = torch.tensor(self.qmin)
130 self.qmax = torch.tensor(self.qmax)
131 self.dst_nbins = 2**bit
132
133 def quant(self, tensor, scales, zeros, qmax, qmin):
134 tensor = torch.clamp(torch.round(tensor / scales) + zeros, qmin, qmax)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected