MCPcopy Create free account
hub / github.com/microsoft/BitNet / QuantizedDataType

Class QuantizedDataType

utils/convert.py:79–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78@dataclass(frozen=True)
79class QuantizedDataType(DataType):
80 block_size: int
81 quantized_dtype: np.dtype[Any]
82 ggml_type: gguf.GGMLQuantizationType
83
84 def quantize(self, arr: NDArray) -> NDArray:
85 raise NotImplementedError(f'Quantization for {self.name} not implemented')
86
87 def elements_to_bytes(self, n_elements: int) -> int:
88 assert n_elements % self.block_size == 0, f'Invalid number of elements {n_elements} for {self.name} with block size {self.block_size}'
89 return self.quantized_dtype.itemsize * (n_elements // self.block_size)
90
91
92@dataclass(frozen=True)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected