Skip to main content

contiguous_stride

Function contiguous_stride 

Source
pub fn contiguous_stride<const N: usize>(shape: [i32; N]) -> [i64; N]
Expand description

Compute the row-major contiguous stride for the given shape.

Returns [d1·…·dN-1, d2·…·dN-1, …, dN-1, 1]. For the rank-0 case returns the empty array.

Useful for caller-side construction of a TensorRef / TensorMut over a contiguous device buffer:

let shape = [8, 128, 128];
let stride = baracuda_kernels_types::contiguous_stride(shape);
let tref = TensorRef { data: buf.as_slice(), shape, stride };