Skip to content

Commit

Permalink
Switch two unwrap to context.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed Dec 22, 2024
1 parent f3f235e commit 6b04707
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions candle-core/src/quantized/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Code for GGML and GGUF files
use crate::{CpuStorage, DType, Device, Result, Shape, Storage, Tensor};
use crate::{Context, CpuStorage, DType, Device, Result, Shape, Storage, Tensor};
use k_quants::*;
use std::borrow::Cow;

Expand Down Expand Up @@ -481,7 +481,7 @@ impl crate::CustomOp1 for QTensor {
crate::bail!("input tensor has only one dimension {layout:?}")
}
let mut dst_shape = src_shape.dims().to_vec();
let last_k = dst_shape.pop().unwrap();
let last_k = dst_shape.pop().context("empty dst_shape")?;
if last_k != k {
crate::bail!("input tensor {layout:?} incompatible with {:?}", self.shape)
}
Expand Down
4 changes: 2 additions & 2 deletions candle-transformers/src/generation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Functionality for modeling sampling strategies and logits processing in text generation
//! with support for temperature-based sampling, top-k filtering, nucleus sampling (top-p),
//! and combinations thereof.
use candle::{DType, Error, Result, Tensor};
use candle::{Context, DType, Error, Result, Tensor};
use rand::{distributions::Distribution, SeedableRng};

#[derive(Clone, PartialEq, Debug)]
Expand Down Expand Up @@ -45,7 +45,7 @@ impl LogitsProcessor {
.enumerate()
.max_by(|(_, u), (_, v)| u.total_cmp(v))
.map(|(i, _)| i as u32)
.unwrap();
.context("empty logits")?;
Ok(next_token)
}

Expand Down

0 comments on commit 6b04707

Please sign in to comment.