docs / GPU Programming / Tensor

Tensor — statically ranked, dynamically sized

Tensor<T, Rank> (use system.collections.tensor) is a multi-dimensional array whose rank is fixed at compile time and whose extents are runtime values, stored flat in row-major order:

let t = Tensor<int, 2>(shape: [2, 3], data: List([1, 2, 3, 4, 5, 6]))
println(f"{t.rank()}")       // 2
println(f"{t.dimension(1)}") // 3
println(f"{t.size()}")       // 6

Tensor implements Accelerable and is defined entirely in the standard library — the compiler has no Tensor-specific logic. It is the intended carrier for ML data reaching the device.