nvidia.dali.fn.transpose

nvidia.dali.fn.transpose(*inputs, **kwargs)

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 (TensorList) – Input to the operator.

Keyword Arguments
  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • 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.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.

  • 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.