DequantOps

Shared dequantization operations for GGUF and SafeTensors weight loading.

All functions are module-visible (internal) and stateless. They convert quantized byte payloads into FP32 float arrays.

Functions

Link copied to clipboard

Returns (bytesPerBlock, elemsPerBlock) for a given quantization type. Useful for chunked dequantization on single-threaded platforms (WASM).

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun dequantFromBytes(bytes: ByteArray, tensorType: GGMLQuantizationType, nElems: Int): FloatArray

Dispatch dequantization based on tensor type for byte arrays.

Link copied to clipboard
fun dequantFromList(raw: List<Any>, tensorType: GGMLQuantizationType, nElems: Int): FloatArray

Dispatch dequantization based on tensor type for List (in-memory GGUFReader).

Link copied to clipboard
fun dequantIQ4NL(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantIQ4XS(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ2K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ3K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ4_0(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ4_1(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ4K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ5_0(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ5_1(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ5K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ6K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ8_0(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ8_1(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantQ8K(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantTQ1_0(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun dequantTQ2_0(raw: List<Any>, nElems: Int): FloatArray
Link copied to clipboard
fun halfToFloat(hbits: Int): Float
Link copied to clipboard
fun toByteArray(raw: List<Any>, tensorName: String): ByteArray
Link copied to clipboard

Handle column-major to row-major conversion for GGUF tensors. Data layout is unchanged — only the shape interpretation changes.