MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / load_unquantized

Function load_unquantized

tokenizer/convert/convert.py:625–638  ·  view source on GitHub ↗
(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False)

Source from the content-addressed store, hash-verified

623
624
625def load_unquantized(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False) -> NDArray:
626 tensor = lazy_tensor.load()
627 assert isinstance(tensor, UnquantizedTensor)
628
629 # double-check:
630 actual_shape = list(tensor.ndarray.shape)
631 assert actual_shape == lazy_tensor.shape, (actual_shape, lazy_tensor.shape)
632 if expected_dtype is not None and expected_dtype != tensor.ndarray.dtype:
633 if convert:
634 tensor.ndarray = tensor.ndarray.astype(expected_dtype)
635 else:
636 raise ValueError(f'expected this tensor to have dtype {expected_dtype}, got {tensor.ndarray.dtype}')
637
638 return tensor.ndarray
639
640
641GGMLCompatibleTensor = UnquantizedTensor

Callers 1

loadFunction · 0.85

Calls 2

loadMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected