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.
This commit is contained in:
Laurent Mazare
2024-04-03 09:02:38 +02:00
committed by GitHub
parent 2be1a35710
commit 318d143224
4 changed files with 10 additions and 4 deletions

View File

@ -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) {