(tensor: Tensor)
| 38 | |
| 39 | |
| 40 | def tensor_round(tensor: Tensor) -> Tensor: |
| 41 | if tensor.device.type == 'cpu' and tensor.dtype == torch.float16: |
| 42 | # CPU does not support FP16 round |
| 43 | return tensor.to(dtype=torch.float32).round_().to(dtype=torch.float16) |
| 44 | else: |
| 45 | return tensor.round_() |
| 46 | |
| 47 | |
| 48 | class Quantizer: |