constensor_core/tensor/mod.rs
1pub mod concretetensor;
2pub mod graphtensor;
3
4pub use concretetensor::Tensor;
5pub use graphtensor::GraphTensor;
6
7/// Compute default (contiguous) strides for a tensor of given shape.
8pub(crate) fn contiguous_strides(shape: &[usize]) -> Vec<usize> {
9 let mut strides = Vec::with_capacity(shape.len());
10 let mut acc = 1;
11 // Iterate dims in reverse to accumulate products
12 for dim in shape.iter().rev() {
13 strides.push(acc);
14 acc *= *dim;
15 }
16 strides.reverse();
17 strides
18}