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

Function compress_int2_to_int8

gpu/pack_weight.py:46–53  ·  view source on GitHub ↗
(int2_weight)

Source from the content-addressed store, hash-verified

44
45
46def compress_int2_to_int8(int2_weight):
47 int8_weight = np.zeros(
48 (*int2_weight.shape[:-1], int2_weight.shape[-1] // 4), dtype=np.int8
49 )
50 for j in range(int2_weight.shape[-1] // 4):
51 for k in range(4):
52 int8_weight[:, :, :, j] |= int2_weight[:, :, :, j * 4 + k] << (k * 2)
53 return int8_weight
54
55
56def interleave_weight_int8(qweight, nbits=2):\

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected