Skip to main content

layout_permutation

Function layout_permutation 

Source
pub fn layout_permutation(
    from: MemoryLayout,
    to: MemoryLayout,
) -> Option<Vec<i64>>
Expand description

Returns the permutation needed to convert from one layout to another.

NHWC -> NCHW = [0, 3, 1, 2] (move channels from last to second) NCHW -> NHWC = [0, 2, 3, 1] (move channels from second to last)

Returns None if layouts are the same or conversion is not applicable (e.g. between RowMajor and a spatial layout).