MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / get_lut

Method get_lut

csrc/cpu_ops.cpp:539–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537 }
538
539 const unsigned char* get_lut(const float* code) {
540 float fp[4];
541 compute_fingerprint(code, fp);
542 for (int i = 0; i < kLUTCacheSlots; ++i) {
543 if (cached_codes[i] == code && cached_fingerprints[i][0] == fp[0] && cached_fingerprints[i][1] == fp[1] &&
544 cached_fingerprints[i][2] == fp[2] && cached_fingerprints[i][3] == fp[3]) {
545 return luts[i];
546 }
547 }
548 // Cache miss: build and store in next slot (round-robin)
549 int slot = next_slot;
550 next_slot = (next_slot + 1) % kLUTCacheSlots;
551 build_quantize_lut(code, luts[slot]);
552 cached_codes[slot] = code;
553 for (int j = 0; j < 4; ++j)
554 cached_fingerprints[slot][j] = fp[j];
555 return luts[slot];
556 }
557};
558
559// Single global LUT cache (protected by mutex for thread safety during build)

Callers 1

get_global_lutFunction · 0.80

Calls 1

build_quantize_lutFunction · 0.85

Tested by

no test coverage detected