Cleanup the main crate error and add a couple dedicated ones (#142)

* Cosmetic cleanups to the error enum.

* More error cleanup.

* Proper error handling rather than panicing.

* Add some conv1d dedicated error.
This commit is contained in:
Laurent Mazare
2023-07-12 09:17:08 +01:00
committed by GitHub
parent fa760759e5
commit a76ec797da
6 changed files with 151 additions and 119 deletions

View File

@ -157,8 +157,9 @@ impl<'a> VarBuilder<'a> {
routing,
safetensors,
} => {
// Unwrap or 0 just to let the proper error flow.
let index = routing.get(&path).unwrap_or(&0);
let index = routing.get(&path).ok_or_else(|| Error::CannotFindTensor {
path: path.to_string(),
})?;
safetensors[*index]
.tensor(&path, &data.device)?
.to_dtype(data.dtype)?