MCPcopy Create free account
hub / github.com/microsoft/BitNet / quant_input

Method quant_input

gpu/model.py:79–81  ·  view source on GitHub ↗
(self, input)

Source from the content-addressed store, hash-verified

77class BitLinear(nn.Linear):
78 @torch.compile
79 def quant_input(self, input):
80 s = 127 / input.abs().max(dim=-1, keepdim=True).values.clamp_(min=1e-5)
81 return (input * s).round().clamp(-128, 127) / s
82
83 def forward(self, input):
84 input = self.quant_input(input)

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected