MCPcopy Index your code
hub / github.com/microsoft/BitNet / forward_t

Function forward_t

utils/convert-ms-to-gguf-bitnet.py:946–951  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

944import torch
945
946def forward_t(x):
947 dtype = x.dtype
948 x = x.float()
949 s = 1.0 / x.abs().mean().clamp_(min=1e-5)
950 x = (x * s).round().clamp(-1, 1) / s
951 return x.to(dtype)
952
953def weight_quant(weight):
954 weight = torch.tensor(weight, dtype=torch.float32)

Callers 1

weight_quantFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected