(tensor, bits=8)
| 325 | |
| 326 | @staticmethod |
| 327 | def quantization(tensor, bits=8): |
| 328 | if bits == 8: |
| 329 | scale = 127.0 / tensor.abs().max().clamp(min=1e-8) |
| 330 | quantized = (tensor * scale).round() / scale |
| 331 | elif bits == 16: |
| 332 | quantized = tensor.half().float() |
| 333 | else: |
| 334 | quantized = tensor |
| 335 | |
| 336 | return quantized |
| 337 | |
| 338 | @staticmethod |
| 339 | def quat_geodesic_loss(q_pred, q_target): |