Use yoke to provide a self-referential container for mmaped safetenso… (#939)

* Use yoke to provide a self-referential container for mmaped safetensor files.

* Add the new self-owned type for safetensor files without removing the previous version.

* Add routing.

* Add an initializer for the case of multiple files.
This commit is contained in:
Laurent Mazare
2023-09-23 15:43:11 +01:00
committed by GitHub
parent 402d207f0f
commit ccf352f3d1
5 changed files with 104 additions and 15 deletions

View File

@ -150,8 +150,7 @@ fn run_ls(file: &std::path::PathBuf, format: Option<Format>, verbose: bool) -> R
}
}
Format::Safetensors => {
let tensors = unsafe { candle_core::safetensors::MmapedFile::new(file)? };
let tensors = tensors.deserialize()?;
let tensors = unsafe { candle_core::safetensors::MmapedSafetensors::new(file)? };
let mut tensors = tensors.tensors();
tensors.sort_by(|a, b| a.0.cmp(&b.0));
for (name, view) in tensors.iter() {