diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2024-04-03 09:02:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 09:02:38 +0200 |
commit | 318d143224805e490d396874b9e1aaf28991393c (patch) | |
tree | ba51a3ef7b1f27734d8b3e5d5a434aab12c2fffd /candle-core | |
parent | 2be1a357102d8f64feb694720e5528d4974ca141 (diff) | |
download | candle-318d143224805e490d396874b9e1aaf28991393c.tar.gz candle-318d143224805e490d396874b9e1aaf28991393c.tar.bz2 candle-318d143224805e490d396874b9e1aaf28991393c.zip |
Relax the contiguous check for cuda kernels. (#2000)
* Relax the contiguous check for cuda kernels.
* Ensure contiguity for RNNs.
* Unrelated fix for segment anything.
* Better error message + allow concatenating empty slices.
Diffstat (limited to 'candle-core')
-rw-r--r-- | candle-core/src/cuda_backend/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/candle-core/src/cuda_backend/mod.rs b/candle-core/src/cuda_backend/mod.rs index 3690e0dc..6a9e73f8 100644 --- a/candle-core/src/cuda_backend/mod.rs +++ b/candle-core/src/cuda_backend/mod.rs @@ -99,7 +99,7 @@ pub trait WrapErr<O> { impl<O, E: Into<CudaError>> WrapErr<O> for std::result::Result<O, E> { fn w(self) -> std::result::Result<O, crate::Error> { - self.map_err(|e| crate::Error::Cuda(Box::new(e.into()))) + self.map_err(|e| crate::Error::Cuda(Box::new(e.into())).bt()) } } @@ -1761,6 +1761,11 @@ impl BackendStorage for CudaStorage { let dev = &self.device; let d1 = d1 as u32; let d2 = d2 as u32; + // Nothing to copy so we exit early to avoid launching a kernel and some potential invalid + // argument with a null pointer. + if d1 == 0 || d2 == 0 { + return Ok(()); + } let dst_s = dst_s as u32; let src_s = src_s as u32; let (src, dst, kname) = match (&self.slice, &mut dst.slice) { |