MCPcopy
hub / github.com/city96/ComfyUI-GGUF / dequantize

Function dequantize

dequant.py:30–44  ·  view source on GitHub ↗

Dequantize tensor back to usable shape/dtype

(data, qtype, oshape, dtype=None)

Source from the content-addressed store, hash-verified

28 return torch.from_numpy(new).to(tensor.device, dtype=dtype)
29
30def dequantize(data, qtype, oshape, dtype=None):
31 """
32 Dequantize tensor back to usable shape/dtype
33 """
34 block_size, type_size = gguf.GGML_QUANT_SIZES[qtype]
35 dequantize_blocks = dequantize_functions[qtype]
36
37 rows = data.reshape(
38 (-1, data.shape[-1])
39 ).view(torch.uint8)
40
41 n_blocks = rows.numel() // type_size
42 blocks = rows.reshape((n_blocks, type_size))
43 blocks = dequantize_blocks(blocks, block_size, type_size, dtype)
44 return blocks.reshape(oshape)
45
46def to_uint32(x):
47 # no uint32 :(

Callers 1

dequantize_tensorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected