summaryrefslogtreecommitdiff
path: root/candle-nn/src
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-07-12 09:17:08 +0100
committerGitHub <noreply@github.com>2023-07-12 09:17:08 +0100
commita76ec797da866d92a39ca41a2c9e70de6d6d7df7 (patch)
tree56021e6e33aebaca580a72331b32cd5ae1145fe1 /candle-nn/src
parentfa760759e5fa94c8486566af6dd3a456d0548221 (diff)
downloadcandle-a76ec797da866d92a39ca41a2c9e70de6d6d7df7.tar.gz
candle-a76ec797da866d92a39ca41a2c9e70de6d6d7df7.tar.bz2
candle-a76ec797da866d92a39ca41a2c9e70de6d6d7df7.zip
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.
Diffstat (limited to 'candle-nn/src')
-rw-r--r--candle-nn/src/var_builder.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/candle-nn/src/var_builder.rs b/candle-nn/src/var_builder.rs
index 7f68ae08..aa2ec401 100644
--- a/candle-nn/src/var_builder.rs
+++ b/candle-nn/src/var_builder.rs
@@ -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)?