| 77 | |
| 78 | @dataclass(frozen=True) |
| 79 | class 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) |
nothing calls this directly
no outgoing calls
no test coverage detected