nvidia.dali.fn.reshape

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

Treats content of the input as if it had a different 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.

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

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

    Number of dimensions cannot exceed the number of dimensions of the input. 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 shape [240, 3840].

    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.

    Number of dimensions cannot exceed the number of dimensions of the input. 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 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.