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

Function quantize_row_q8_0_reference

pocs/vdot/vdot.cpp:168–190  ·  view source on GitHub ↗

Copy-pasted from ggml.c

Source from the content-addressed store, hash-verified

166
167// Copy-pasted from ggml.c
168static void quantize_row_q8_0_reference(const float *x, block_q8_0 *y, int k) {
169 assert(k % QK8_0 == 0);
170 const int nb = k / QK8_0;
171
172 for (int i = 0; i < nb; i++) {
173 float amax = 0.0f; // absolute max
174
175 for (int l = 0; l < QK8_0; l++) {
176 const float v = x[i*QK8_0 + l];
177 amax = std::max(amax, fabsf(v));
178 }
179
180 const float d = amax / ((1 << 7) - 1);
181 const float id = d ? 1.0f/d : 0.0f;
182
183 y[i].d = d;
184
185 for (int l = 0; l < QK8_0; ++l) {
186 const float v = x[i*QK8_0 + l]*id;
187 y[i].qs[l] = roundf(v);
188 }
189 }
190}
191
192// Copy-pasted from ggml.c
193static void dot_q4_q8(const int n, float* s, const void* vx, const void* vy) {

Callers 1

mainFunction · 0.70

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected