Concepts: Tensors & Strides
In-depth explanation of strided multi-dimensional arrays, signed strides, and memory layouts.
Strided Memory Model
A tensor in Dark Forest consists of:
- An underlying flat buffer in memory (
Storage<T, D>). - An integer byte offset.
- A shape vector [d_0, d_1, ..., d_(n-1)].
- A strides vector [s_0, s_1, ..., s_(n-1)].
The memory address for element index (i_0, i_1, ..., i_(n-1)) is computed as:
text
address = offset + sum(i_k * stride_k for k in 0..n-1)