Skip to main content

nested_dim_order

Function nested_dim_order 

Source
pub fn nested_dim_order(shape: &[usize], strides: &[usize]) -> Option<DimOrder>
Expand description

The dimension order of a tensor whose dimensions nest without overlapping, or None if they do not.

Weaker than dim_order, which additionally requires consecutive elements without gaps. A dimension may sit at a larger stride than the extents inside it need, which is what a pitched or tile-aligned allocation produces: 48 channels held innermost on a 64-element tile have stride 64 where a dense tensor would have 48.

Iterating in this order can improve locality, but reads must still use the tensor’s actual strides. Gaps can affect memory transactions and vectorization; accepting an order does not guarantee dense-access performance. This also accepts sliced views whose dimensions satisfy the same nesting condition. Anything reinterpreting a buffer as a flat run of elements must keep asking dim_order.