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

Method astype

utils/convert.py:788–794  ·  view source on GitHub ↗
(self, data_type: DataType)

Source from the content-addressed store, hash-verified

786 self.i2_scale = i2_scale
787
788 def astype(self, data_type: DataType) -> UnquantizedTensor:
789 dtype = data_type.dtype
790 if self.data_type == DT_BF16:
791 self.ndarray = bf16_to_fp32(self.ndarray)
792 if dtype == np.uint8:
793 self.ndarray, self.i2_scale = transform_to_i2(self.ndarray)
794 return UnquantizedTensor(self.ndarray.astype(dtype), self.i2_scale)
795
796 def to_ggml(self) -> Self:
797 return self

Callers

nothing calls this directly

Calls 4

bf16_to_fp32Function · 0.70
transform_to_i2Function · 0.70
UnquantizedTensorClass · 0.70
astypeMethod · 0.45

Tested by

no test coverage detected