Expand description
The order a tensor’s dimensions occupy memory in. The order a tensor’s dimensions occupy memory in.
A tensor’s strides say which dimension is innermost, which next, and so on
outward — its dimension order. Contiguous NCHW is the identity order; a
convolution that computes channels-last and hands back a permuted view is
[0, 2, 3, 1]. A kernel that iterates a tensor in its own dimension order
reads it linearly; one that iterates in any other order reads it strided.
Two questions are asked here. dim_order asks for the order of a tensor that is dense — that fills its buffer with no gaps — which is what a kernel needs before it may treat the buffer as a flat run of elements. nested_dim_order asks only that the dimensions nest, tolerating the gap a pitched or tile-aligned allocation leaves under a dimension, which is enough to decide what order to iterate in.
Functions§
- dim_
order - The dimension order of a tensor that is dense in memory, or
Noneif it is not dense. - is_
contiguous_ order - Whether a dimension order is the contiguous one,
[0, 1, .., rank - 1]. - nested_
dim_ order - The dimension order of a tensor whose dimensions nest without overlapping,
or
Noneif they do not.
Type Aliases§
- DimOrder
- The order a tensor’s dimensions appear in memory, outermost first.