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

Function norm_to_lut_index

csrc/cpu_ops.cpp:569–572  ·  view source on GitHub ↗

Convert a normalized value in [-1, 1] to LUT index [0, 65535]

Source from the content-addressed store, hash-verified

567
568// Convert a normalized value in [-1, 1] to LUT index [0, 65535]
569static inline uint16_t norm_to_lut_index(float val) {
570 val = std::clamp(val, -1.0f, 1.0f);
571 return static_cast<uint16_t>((val + 1.0f) * 0.5f * (kLUTSize - 1) + 0.5f);
572}
573
574template <typename T>
575void quantize_cpu_impl(float* code, const T* A, float* absmax, unsigned char* out, long long blocksize, long long n) {

Callers 1

quantize_cpu_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected