diff options
Diffstat (limited to 'candle-nn/src/var_builder.rs')
-rw-r--r-- | candle-nn/src/var_builder.rs | 5 |
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)? |