MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_hash_size

Function ggml_hash_size

ggml.c:15145–15169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15143////////////////////////////////////////////////////////////////////////////////
15144
15145static size_t ggml_hash_size(size_t min_sz) {
15146 // next primes after powers of two
15147 static const size_t primes[] = {
15148 2, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031,
15149 2053, 4099, 8209, 16411, 32771, 65537, 131101,
15150 262147, 524309, 1048583, 2097169, 4194319, 8388617,
15151 16777259, 33554467, 67108879, 134217757, 268435459,
15152 536870923, 1073741827, 2147483659
15153 };
15154 static const size_t n_primes = sizeof(primes)/sizeof(primes[0]);
15155
15156 // find the smallest prime that is larger or equal to min_sz
15157 size_t l = 0;
15158 size_t r = n_primes;
15159 while (l < r) {
15160 size_t m = (l + r)/2;
15161 if (primes[m] < min_sz) {
15162 l = m + 1;
15163 } else {
15164 r = m;
15165 }
15166 }
15167 size_t sz = l < n_primes ? primes[l] : min_sz | 1;
15168 return sz;
15169}
15170
15171static size_t ggml_hash(const void * p) {
15172 return (size_t)p;

Callers 3

ggml_hash_set_newFunction · 0.70
ggml_graph_nbytesFunction · 0.70
ggml_new_graph_customFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected