pub fn greedy_layout<D>(
layout: &Layout<D>,
keep_shape: bool,
) -> (Layout<D>, Vec<isize>)where
D: DimDevAPI,
Expand description
This function will return a f-prefer layout that make minimal memory accessing efforts (pointers will not frequently back-and-forth).
Note that this function should only be used for iteration.
§Parameter keep_shape
Keep size of output layout when input layout is boardcasted.
This option should be false if TensorIterOrder::K
and true if
TensorIterOrder::G
.
For example of layout shape [5, 1, 2, 1, 3, 6]
and stride [1000, 10, 10, 40, 0, 100]
,
- false: shape
[2, 6, 5, 1, 1, 1]
and stride[10, 100, 1000, 0, 0, 0]
; meaning that broadcasted shapes are eliminated and moved to last axes. - true: shape
[3, 1, 1, 2, 6, 5]
and stride[0, 10, 40, 10, 100, 1000]
; meaning that broadcasted shapes are iterated with most priority.
§Returns
layout
: The output layout of greedy iteration.index
: Transpose index from input layout to output layout.