MCPcopy Create free account
hub / github.com/microsoft/BitNet / bf16_to_fp32

Function bf16_to_fp32

utils/convert.py:718–721  ·  view source on GitHub ↗
(bf16_arr: np.ndarray[Any, np.dtype[np.uint16]])

Source from the content-addressed store, hash-verified

716
717
718def bf16_to_fp32(bf16_arr: np.ndarray[Any, np.dtype[np.uint16]]) -> NDArray:
719 assert bf16_arr.dtype == np.uint16, f"Input array should be of dtype uint16, but got {bf16_arr.dtype}"
720 fp32_arr = bf16_arr.astype(np.uint32) << 16
721 return fp32_arr.view(np.float32)
722
723def preprocess_weights(
724 w: np.ndarray,

Callers 1

astypeMethod · 0.70

Calls 1

astypeMethod · 0.45

Tested by

no test coverage detected