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

Function ggml_hash_size

subprojects/llama.cpp/ggml/src/ggml.c:6124–6148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6122}
6123
6124size_t ggml_hash_size(size_t min_sz) {
6125 // next primes after powers of two
6126 static const size_t primes[] = {
6127 2, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031,
6128 2053, 4099, 8209, 16411, 32771, 65537, 131101,
6129 262147, 524309, 1048583, 2097169, 4194319, 8388617,
6130 16777259, 33554467, 67108879, 134217757, 268435459,
6131 536870923, 1073741827, 2147483659
6132 };
6133 static const size_t n_primes = sizeof(primes)/sizeof(primes[0]);
6134
6135 // find the smallest prime that is larger or equal than min_sz
6136 size_t l = 0;
6137 size_t r = n_primes;
6138 while (l < r) {
6139 size_t m = (l + r)/2;
6140 if (primes[m] < min_sz) {
6141 l = m + 1;
6142 } else {
6143 r = m;
6144 }
6145 }
6146 size_t sz = l < n_primes ? primes[l] : min_sz | 1;
6147 return sz;
6148}
6149
6150struct hash_map {
6151 struct ggml_hash_set set;

Callers 3

ggml_hash_set_newFunction · 0.85
ggml_graph_nbytesFunction · 0.85
ggml_new_graph_customFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected