nvidia.dali.experimental.dynamic.transpose#

nvidia.dali.experimental.dynamic.transpose(input, /, *, batch_size=None, device=None, output_layout=None, perm=None, transpose_layout=None)#

Transposes the tensors by reordering the dimensions based on the perm parameter.

Destination dimension i is obtained from source dimension perm[i].

For example, for a source image with HWC layout, shape = (100, 200, 3), and perm = [2, 0, 1], it will produce a destination image with CHW layout and shape = (3, 100, 200), holding the equality:

\[dst(x_2, x_0, x_1) = src(x_0, x_1, x_2)\]

which is equivalent to:

\[dst(x_{perm[0]}, x_{perm[1]}, x_{perm[2]}) = src(x_0, x_1, x_2)\]

for all valid coordinates.

This operator allows sequence inputs and supports volumetric data.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

input (Tensor/Batch) – Input to the operator.

Keyword Arguments:
  • output_layout (layout str, optional, default = ‘’) –

    Explicitly sets the output data layout.

    If this argument is specified, transpose_layout is ignored.

  • perm (int or list of int, optional) –

    Permutation of the dimensions of the input, for example, [2, 0, 1].

    If not given, the dimensions are reversed.

  • transpose_layout (bool, optional, default = True) –

    When set to True, the axis names in the output data layout are permuted according to perm, Otherwise, the input layout is copied to the output.

    If output_layout is set, this argument is ignored.