MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / load_unquantized

Function load_unquantized

convert-dense.py:483–496  ·  view source on GitHub ↗
(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False)

Source from the content-addressed store, hash-verified

481
482
483def load_unquantized(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False) -> NDArray:
484 tensor = lazy_tensor.load()
485 assert isinstance(tensor, UnquantizedTensor)
486
487 # double-check:
488 actual_shape = list(tensor.ndarray.shape)
489 assert actual_shape == lazy_tensor.shape, (actual_shape, lazy_tensor.shape)
490 if expected_dtype is not None and expected_dtype != tensor.ndarray.dtype:
491 if convert:
492 tensor.ndarray = tensor.ndarray.astype(expected_dtype)
493 else:
494 raise ValueError(f'expected this tensor to have dtype {expected_dtype}, got {tensor.ndarray.dtype}')
495
496 return tensor.ndarray
497
498
499GGMLCompatibleTensor = UnquantizedTensor

Callers 1

loadFunction · 0.70

Calls 2

loadMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected