From 62ced44ea94da7062430ed6c21ff17b36f41737d Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Sun, 22 Dec 2024 09:18:13 +0100 Subject: Add a Context trait similar to anyhow::Context. (#2676) * Add a Context trait similar to anyhow::Context. * Switch two unwrap to context. --- candle-core/src/tensor_cat.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'candle-core/src/tensor_cat.rs') diff --git a/candle-core/src/tensor_cat.rs b/candle-core/src/tensor_cat.rs index 204e7fd6..be6dfe61 100644 --- a/candle-core/src/tensor_cat.rs +++ b/candle-core/src/tensor_cat.rs @@ -1,4 +1,4 @@ -use crate::{shape::Dim, Error, Result, Shape, Tensor}; +use crate::{shape::Dim, Context, Error, Result, Shape, Tensor}; impl Tensor { /// Concatenates two or more tensors along a particular dimension. @@ -134,7 +134,7 @@ impl Tensor { .bt())? } } - let next_offset = offsets.last().unwrap() + arg.elem_count(); + let next_offset = offsets.last().context("empty offsets")? + arg.elem_count(); offsets.push(next_offset); } let shape = Shape::from(cat_dims); -- cgit v1.2.3