nvidia.dali.fn.reinterpret#

nvidia.dali.fn.reinterpret(
__data,
__shape_input=None,
/,
*,
bytes_per_sample_hint=[0],
dtype=None,
layout='',
preserve=False,
rel_shape=[],
seed=-1,
shape=[],
src_dims=[],
device=None,
name=None,
)#

Treats content of the input as if it had a different type, shape, and/or layout.

The buffer contents are not copied.

This operator allows sequence inputs and supports volumetric data.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:
  • __data (TensorList) – Data to be reshaped

  • __shape_input (1D TensorList of integers, optional) – Same as shape keyword argument

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.

  • dtype (nvidia.dali.types.DALIDataType, optional) –

    Output data type.

    The total size, in bytes, of the output must match the input. If no shape is provided, the innermost dimension is adjusted accordingly. If the byte size of the innermost dimension is not divisible by the size of the target type, an error occurs.

:keyword layout : layout str, optional, default = ‘’: New layout for the data.

If a value is not specified, if number of dimension matches existing layout, the output layout is preserved. If the number of dimensions does not match, the argument is reset to empty. If a value is set, and is not empty, the layout must match the dimensionality of the output.

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

  • rel_shape (float or list of float or TensorList of float, optional, default = []) –

    The relative shape of the output.

    The output shape is calculated by multiplying the input shape by rel_shape:

    out_shape[i] = in_shape[i] * rel_shape[i]
    

    An additional argument src_dims may be used to alter which source dimension is used for calculating the output shape:

    out_shape[i] = in_shape[src_dims[i]] * rel_shape[i]
    

    There can be one negative extent that receives the size that is required to match the input volume. For example, an input of shape [480, 640, 3] and a rel_shape = [0.5, -1] results in the output shape [240, 3840].

    The number of dimensions is subject to the following restrictions:

    • if src_dims argument is used, the number of elements in src_dims and rel_shape must match

    • otherwise, the length of rel_shape must not exceed the number of dimensions in the input except when the last element in rel_shape is negative, in which case an extra dimension at the end will be added

    Note

    rel_shape and shape are mutually exclusive.

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

    Random seed.

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

  • shape (int or list of int or TensorList of int, optional, default = []) –

    The desired shape of the output.

    There can be one negative extent that receives the size that is required to match the input volume. For example, an input of shape [480, 640, 3] and shape = [240, -1] results in the output shape [240, 3840].

    Note

    rel_shape and shape are mutually exclusive.

  • src_dims (int or list of int or TensorList of int, optional, default = []) –

    Indices of dimensions to keep.

    This argument can be used to manipulate the order of existing dimensions or to remove or add dimension. A special index value -1 can be used to insert new dimensions.

    For example, reshaping a sample with shape [300, 200, 1] and a src_dims argument [-1, 1, 0] produces an output shape [1, 200, 300]. A leading dimension with extent 1 is inserted at the beginning, followed by the first original dimensions but in reverse order. The last dimension is removed.

    The src_dims argument can be used together with rel_shape, in which case the relative extents in rel_shape describe to the target dimensions. In the example above, specifying rel_shape = [-1, 0.5, 2] would result in the output shape [1, 100, 600].

    All indices must be in the range of valid dimensions of the input, or -1.