MCPcopy Create free account
hub / github.com/Niko1221/Strata / dequant_q2_0

Function dequant_q2_0

engine/src/quant/dequant.cpp:25–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void dequant_q2_0(const block_q2_0* STRATA_RESTRICT x, float* STRATA_RESTRICT y, int64_t k) {
26 static const int qk = QK2_0;
27
28 assert(k % qk == 0);
29
30 const int nb = k / qk;
31
32 for (int i = 0; i < nb; i++) {
33 const float d = fp16_to_fp32(x[i].d);
34
35 for (int j = 0; j < qk; ++j) {
36 const int byte_index = j / 4;
37 const int bit_offset = (j % 4) * 2;
38 const uint8_t q = (x[i].qs[byte_index] >> bit_offset) & 0x03;
39 // 00=-1, 01=0, 10=+1, 11=+2
40 y[i*qk + j] = ((int)q - 1) * d;
41 }
42 }
43}
44
45void dequant_q4_0(const block_q4_0* STRATA_RESTRICT x, float* STRATA_RESTRICT y, int64_t k) {
46 static const int qk = QK4_0;

Callers 1

dequant_rowFunction · 0.85

Calls 1

fp16_to_fp32Function · 0.70

Tested by

no test coverage detected