Retrieve tensor data from PyTorch files. (#516)

This commit is contained in:
Laurent Mazare
2023-08-19 15:57:18 +01:00
committed by GitHub
parent 607ffb9f1e
commit 6431140250
3 changed files with 65 additions and 9 deletions

View File

@ -196,7 +196,11 @@ impl Header {
impl Tensor {
// TODO: Add the possibility to read directly to a device?
fn from_reader<R: std::io::Read>(shape: Shape, dtype: DType, reader: &mut R) -> Result<Self> {
pub(crate) fn from_reader<R: std::io::Read>(
shape: Shape,
dtype: DType,
reader: &mut R,
) -> Result<Self> {
let elem_count = shape.elem_count();
match dtype {
DType::BF16 => {