MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / ggml_hash_insert

Function ggml_hash_insert

subprojects/llama.cpp/ggml/src/ggml-impl.h:273–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273static 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
294static 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;

Callers 2

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