MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / _pack_int8_to_int4

Function _pack_int8_to_int4

codegeex/quantization/quantize_oneflow.py:5–13  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

3from oneflow.nn.parameter import Parameter
4
5def _pack_int8_to_int4(x):
6 np_x = x.numpy()
7 l = np_x[..., 0::2]
8 r = np_x[..., 1::2]
9 l = np.left_shift(l, 4)
10 if x.dtype is np.int8:
11 even = np.bitwise_and(r, np.int8(0xF))
12 packed = torch.tensor(np.bitwise_or(l, r), device=x.device)
13 return packed
14
15
16def _quantize(num_bits, symmetric, x, group_dim, group_size, quant_type):

Callers 1

_quantizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected