diff options
author | laurent <laurent.mazare@gmail.com> | 2023-06-21 21:28:59 +0100 |
---|---|---|
committer | laurent <laurent.mazare@gmail.com> | 2023-06-21 21:28:59 +0100 |
commit | 7c46de9584fd4315b84d3bc4c28cf1b2bad7785d (patch) | |
tree | 710596156a4c026d4dd2ba804fab79b6cdafae3b /src/tensor.rs | |
parent | 983415125495e9d57e684b701fbf746ebb6f7a29 (diff) | |
download | candle-7c46de9584fd4315b84d3bc4c28cf1b2bad7785d.tar.gz candle-7c46de9584fd4315b84d3bc4c28cf1b2bad7785d.tar.bz2 candle-7c46de9584fd4315b84d3bc4c28cf1b2bad7785d.zip |
Check that the tensor is contiguous before applying the kernel.
Diffstat (limited to 'src/tensor.rs')
-rw-r--r-- | src/tensor.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/tensor.rs b/src/tensor.rs index a1262334..02105573 100644 --- a/src/tensor.rs +++ b/src/tensor.rs @@ -310,14 +310,7 @@ impl Tensor { } pub fn is_contiguous(&self) -> bool { - let mut acc = 1; - for (&stride, &dim) in self.stride.iter().zip(self.shape.dims().iter()).rev() { - if stride != acc { - return false; - } - acc *= dim; - } - true + self.shape.is_contiguous(&self.stride) } /// Return all the nodes that lead to this value in a topologically sorted vec, the first |