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

Function load_unquantized

convert.py:504–517  ·  view source on GitHub ↗
(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False)

Source from the content-addressed store, hash-verified

502
503
504def load_unquantized(lazy_tensor: LazyTensor, expected_dtype: Any = None, convert: bool = False) -> NDArray:
505 tensor = lazy_tensor.load()
506 assert isinstance(tensor, UnquantizedTensor)
507
508 # double-check:
509 actual_shape = list(tensor.ndarray.shape)
510 assert actual_shape == lazy_tensor.shape, (actual_shape, lazy_tensor.shape)
511 if expected_dtype is not None and expected_dtype != tensor.ndarray.dtype:
512 if convert:
513 tensor.ndarray = tensor.ndarray.astype(expected_dtype)
514 else:
515 raise ValueError(f'expected this tensor to have dtype {expected_dtype}, got {tensor.ndarray.dtype}')
516
517 return tensor.ndarray
518
519
520GGMLCompatibleTensor = UnquantizedTensor

Callers 1

loadFunction · 0.70

Calls 2

loadMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected