MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_quantize_q5_1

Function ggml_quantize_q5_1

ggml.c:19181–19209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19179}
19180
19181size_t ggml_quantize_q5_1(const float * src, void * dst, int n, int k, int64_t * hist) {
19182 assert(k % QK5_1 == 0);
19183 const int nb = k / QK5_1;
19184
19185 for (int b = 0; b < n; b += k) {
19186 block_q5_1 * restrict y = (block_q5_1 *)dst + b/QK5_1;
19187
19188 quantize_row_q5_1_reference(src + b, y, k);
19189
19190 for (int i = 0; i < nb; i++) {
19191 uint32_t qh;
19192 memcpy(&qh, &y[i].qh, sizeof(qh));
19193
19194 for (int j = 0; j < QK5_1; j += 2) {
19195 const uint8_t vh0 = ((qh & (1u << (j + 0 ))) >> (j + 0 )) << 4;
19196 const uint8_t vh1 = ((qh & (1u << (j + 16))) >> (j + 12));
19197
19198 // cast to 16 bins
19199 const uint8_t vi0 = ((y[i].qs[j/2] & 0x0F) | vh0) / 2;
19200 const uint8_t vi1 = ((y[i].qs[j/2] >> 4) | vh1) / 2;
19201
19202 hist[vi0]++;
19203 hist[vi1]++;
19204 }
19205 }
19206 }
19207
19208 return (n/QK5_1*sizeof(block_q5_1));
19209}
19210
19211size_t ggml_quantize_q8_0(const float * src, void * dst, int n, int k, int64_t * hist) {
19212 assert(k % QK8_0 == 0);

Callers 2

ggml_quantize_chunkFunction · 0.85
clip_model_quantizeFunction · 0.85

Calls 1

Tested by

no test coverage detected