(self, input)
| 67 | |
| 68 | @torch.compile |
| 69 | def quant_input(self, input): |
| 70 | s = 127 / input.abs().max(dim=-1, keepdim=True).values.clamp_(min=1e-5) |
| 71 | return (input * s).round().clamp(-128, 127).to(torch.int8), s |
| 72 | |
| 73 | def forward(self, input): |
| 74 | input, s = self.quant_input(input) |