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

Function dot41

pocs/vdot/vdot.cpp:141–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141inline double dot41(int n, const block_q4_1* x, const float* y) {
142 const static float kValues[16] = {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f};
143 constexpr uint32_t kMask1 = 0x0f0f0f0f;
144 uint32_t u1, u2;
145 auto q1 = (const uint8_t*)&u1;
146 auto q2 = (const uint8_t*)&u2;
147 double sum = 0;
148 for (int i=0; i<n; ++i) {
149 auto u = (const uint32_t*)x->qs;
150 float s = 0, s1 = 0;
151 for (int k=0; k<4; ++k) {
152 u1 = u[k] & kMask1;
153 u2 = (u[k] >> 4) & kMask1;
154 s += y[0]*kValues[q1[0]] + y[1]*kValues[q2[0]] +
155 y[2]*kValues[q1[1]] + y[3]*kValues[q2[1]] +
156 y[4]*kValues[q1[2]] + y[5]*kValues[q2[2]] +
157 y[6]*kValues[q1[3]] + y[7]*kValues[q2[3]];
158 s1 += y[0] + y[1] + y[2] + y[3] + y[4] + y[5] + y[6] + y[7];
159 y += 8;
160 }
161 sum += s*x->d + s1*x->m;
162 ++x;
163 }
164 return sum;
165}
166
167// Copy-pasted from ggml.c
168static void quantize_row_q8_0_reference(const float *x, block_q8_0 *y, int k) {

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected