Sparse-random-index fallback for tokens not present in the enriched table. */
| 12133 | |
| 12134 | /* Sparse-random-index fallback for tokens not present in the enriched table. */ |
| 12135 | static void vs_fill_sparse_random(const char *token, float *out) { |
| 12136 | uint64_t seed = XXH3_64bits(token, strlen(token)); |
| 12137 | for (int i = 0; i < VS_SPARSE_NNZE; i++) { |
| 12138 | uint64_t h = XXH3_64bits_withSeed(&i, sizeof(i), seed + VS_RI_SEED); |
| 12139 | int pos = (int)(h % VS_VEC_DIM); |
| 12140 | float sign = (h & SKIP_ONE) ? CBM_STORE_UNIT_POS_F : -CBM_STORE_UNIT_POS_F; |
| 12141 | out[pos] += sign; |
| 12142 | } |
| 12143 | } |
| 12144 | |
| 12145 | /* Clamp one float into the int8 representable range. */ |
| 12146 | static int8_t vs_clamp_int8(float v) { |
no outgoing calls
no test coverage detected