(t: torch.Tensor)
| 324 | return t |
| 325 | |
| 326 | def quantize(t: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: |
| 327 | if dtype not in [torch.float32, torch.float16]: |
| 328 | if isinstance(metadata.quant, KQuant): |
| 329 | t = k_quantize(t.to(torch.float32), metadata.quant.name) |
| 330 | elif metadata.quant.block_size is None: |
| 331 | return per_tensor_quantize(t, dtype) |
| 332 | else: |
| 333 | quant_block_size = torch.tensor(metadata.quant.block_size) |
| 334 | return blockwise_quantize(t, quant_block_size, dtype) |
| 335 | return t.to(dtype), None |
| 336 | |
| 337 | def conv(weight_name: str, scale_name: str) -> Tuple[torch.Tensor, torch.Tensor]: |
| 338 | nonlocal progress |
no test coverage detected