MCPcopy Create free account
hub / github.com/antirez/ds4 / weights_bind

Function weights_bind

ds4.c:4070–4106  ·  view source on GitHub ↗

Bind tensor names once into the fixed DS4 layer layout. This is the point * where stringly GGUF metadata becomes direct model-specific pointers. */

Source from the content-addressed store, hash-verified

4068 vld1_s8((const int8_t *)(iq2xxs_grid + aux8[1])));
4069 int8x16_t q2u1 = vcombine_s8(vld1_s8((const int8_t *)(iq2xxs_grid + aux8[2])),
4070 vld1_s8((const int8_t *)(iq2xxs_grid + aux8[3])));
4071 int8x16_t q2u2 = vcombine_s8(vld1_s8((const int8_t *)(iq2xxs_grid + aux8[8])),
4072 vld1_s8((const int8_t *)(iq2xxs_grid + aux8[9])));
4073 int8x16_t q2u3 = vcombine_s8(vld1_s8((const int8_t *)(iq2xxs_grid + aux8[10])),
4074 vld1_s8((const int8_t *)(iq2xxs_grid + aux8[11])));
4075
4076 const int8x16_t q2s0 = vcombine_s8(vld1_s8(iq2xxs_signs[(aux32[1] >> 0) & 127]),
4077 vld1_s8(iq2xxs_signs[(aux32[1] >> 7) & 127]));
4078 const int8x16_t q2s1 = vcombine_s8(vld1_s8(iq2xxs_signs[(aux32[1] >> 14) & 127]),
4079 vld1_s8(iq2xxs_signs[(aux32[1] >> 21) & 127]));
4080 const int8x16_t q2s2 = vcombine_s8(vld1_s8(iq2xxs_signs[(aux32[3] >> 0) & 127]),
4081 vld1_s8(iq2xxs_signs[(aux32[3] >> 7) & 127]));
4082 const int8x16_t q2s3 = vcombine_s8(vld1_s8(iq2xxs_signs[(aux32[3] >> 14) & 127]),
4083 vld1_s8(iq2xxs_signs[(aux32[3] >> 21) & 127]));
4084
4085 q2u0 = vmulq_s8(q2u0, q2s0);
4086 q2u1 = vmulq_s8(q2u1, q2s1);
4087 q2u2 = vmulq_s8(q2u2, q2s2);
4088 q2u3 = vmulq_s8(q2u3, q2s3);
4089
4090 const int32x4_t p1 = vdotq_s32(vdotq_s32(vdupq_n_s32(0), q2u0, q8b.val[0]), q2u1, q8b.val[1]);
4091 const int32x4_t p2 = vdotq_s32(vdotq_s32(vdupq_n_s32(0), q2u2, q8b.val[2]), q2u3, q8b.val[3]);
4092
4093 sumf1 += (float)vaddvq_s32(p1) * (0.5f + (float)(aux32[1] >> 28));
4094 sumf2 += (float)vaddvq_s32(p2) * (0.5f + (float)(aux32[3] >> 28));
4095 }
4096
4097 sumf += d * (sumf1 + sumf2);
4098 }
4099
4100 *s = 0.25f * sumf;
4101#else
4102 uint32_t aux32[2];
4103 const uint8_t *aux8 = (const uint8_t *)aux32;
4104 float sumf = 0.0f;
4105
4106 for (int i = 0; i < nb; i++) {
4107 const float d = f16_to_f32(x[i].d) * y[i].d;
4108 const uint16_t *q2 = x[i].qs;
4109 const int8_t *q8 = y[i].qs;

Callers 1

ds4_engine_openFunction · 0.85

Calls 6

ds4_dieFunction · 0.85
required_tensorFunction · 0.85
model_find_tensorFunction · 0.85
weights_bind_outputFunction · 0.85
weights_bind_layerFunction · 0.85
weights_validate_layoutFunction · 0.85

Tested by

no test coverage detected