MCPcopy Index your code
hub / github.com/microsoft/BitNet / load_unquantized

Function load_unquantized

utils/convert-ms-to-gguf-bitnet.py:811–824  ·  view source on GitHub ↗
(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False)

Source from the content-addressed store, hash-verified

809
810
811def load_unquantized(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False) -> NDArray:
812 tensor = lazy_tensor.load()
813 assert isinstance(tensor, UnquantizedTensor)
814
815 # double-check:
816 actual_shape = list(tensor.ndarray.shape)
817 assert actual_shape == lazy_tensor.shape, (actual_shape, lazy_tensor.shape)
818 if expected_dtype is not None and expected_dtype != tensor.ndarray.dtype:
819 if convert:
820 tensor.ndarray = tensor.ndarray.astype(expected_dtype)
821 else:
822 raise ValueError(f'expected this tensor to have dtype {expected_dtype}, got {tensor.ndarray.dtype}')
823
824 return tensor.ndarray
825
826
827GGMLCompatibleTensor = UnquantizedTensor

Callers 1

loadFunction · 0.70

Calls 2

loadMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected