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

Method quant

lightx2v/utils/quant_utils.py:177–183  ·  view source on GitHub ↗
(self, tensor, scales, zeros, qmax, qmin)

Source from the content-addressed store, hash-verified

175 self.qmin = torch.tensor(self.qmin)
176
177 def quant(self, tensor, scales, zeros, qmax, qmin):
178 scaled_tensor = tensor / scales + zeros
179 scaled_tensor = torch.clip(scaled_tensor, self.qmin.cuda(), self.qmax.cuda())
180 org_dtype = scaled_tensor.dtype
181 q_tensor = _load_float_quantize()(scaled_tensor.float(), self.e_bits, self.m_bits, rounding="nearest")
182 q_tensor.to(org_dtype)
183 return q_tensor
184
185 def dequant(self, tensor, scales, zeros):
186 tensor = (tensor - zeros) * scales

Callers 2

quant_dequantMethod · 0.95
real_quant_tensorMethod · 0.45

Calls 3

_load_float_quantizeFunction · 0.85
cudaMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected