Bugfix for the contiguous strides.

This commit is contained in:
laurent
2023-06-20 13:35:07 +01:00
parent d922ff97f2
commit 98b423145a
5 changed files with 64 additions and 8 deletions

View File

@ -25,6 +25,16 @@ impl<S: crate::WithDType> NdArray for S {
}
}
impl<S: crate::WithDType, const N: usize> NdArray for &[S; N] {
fn shape(&self) -> Result<Shape> {
Ok(Shape::from(self.len()))
}
fn to_cpu_storage(&self) -> CpuStorage {
S::to_cpu_storage(self.as_slice())
}
}
impl<S: crate::WithDType> NdArray for &[S] {
fn shape(&self) -> Result<Shape> {
Ok(Shape::from(self.len()))
@ -35,6 +45,16 @@ impl<S: crate::WithDType> NdArray for &[S] {
}
}
impl<S: crate::WithDType, const N: usize, const M: usize> NdArray for &[[S; N]; M] {
fn shape(&self) -> Result<Shape> {
Ok(Shape::from((M, N)))
}
fn to_cpu_storage(&self) -> CpuStorage {
S::to_cpu_storage_owned(self.concat())
}
}
impl Device {
pub(crate) fn zeros(&self, shape: &Shape, dtype: DType) -> Storage {
match self {