MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_hash_insert

Function ggml_hash_insert

external/ggml/src/ggml-impl.h:279–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

ggml_graph_cpyFunction · 0.85
graph_copy_dup_tensorFunction · 0.85

Calls 3

ggml_hashFunction · 0.85
ggml_bitset_getFunction · 0.85
ggml_bitset_setFunction · 0.85

Tested by

no test coverage detected