| 271 | } |
| 272 | |
| 273 | static size_t ggml_hash_insert(struct ggml_hash_set * hash_set, struct ggml_tensor * key) { |
| 274 | size_t h = ggml_hash(key) % hash_set->size; |
| 275 | |
| 276 | // linear probing |
| 277 | size_t i = h; |
| 278 | do { |
| 279 | if (!ggml_bitset_get(hash_set->used, i)) { |
| 280 | ggml_bitset_set(hash_set->used, i); |
| 281 | hash_set->keys[i] = key; |
| 282 | return i; |
| 283 | } |
| 284 | if (hash_set->keys[i] == key) { |
| 285 | return GGML_HASHSET_ALREADY_EXISTS; |
| 286 | } |
| 287 | i = (i + 1) % hash_set->size; |
| 288 | } while (i != h); |
| 289 | |
| 290 | // visited all hash table entries -> not found |
| 291 | GGML_ABORT("fatal error"); |
| 292 | } |
| 293 | |
| 294 | static size_t ggml_hash_find_or_insert(struct ggml_hash_set * hash_set, struct ggml_tensor * key) { |
| 295 | size_t h = ggml_hash(key) % hash_set->size; |
no test coverage detected