(self, tensor, scales, zeros, qmax, qmin)
| 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 |
no test coverage detected