nvidia.dali.fn.reshape#
- nvidia.dali.fn.reshape(__data, __shape_input=None, /, *, bytes_per_sample_hint=[0], 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 shape and/or layout.
The buffer contents are not copied.
This operator allows sequence inputs and supports volumetric data.
- Supported backends
‘cpu’
‘gpu’
- Parameters:
- 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.
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 arel_shape = [0.5, -1]
results in the output shape[240, 3840]
.The number of dimensions is subject to the following restrictions:
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]
andshape = [240, -1]
results in the output shape[240, 3840]
.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 asrc_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 withrel_shape
, in which case the relative extents inrel_shape
describe to the target dimensions. In the example above, specifyingrel_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.
See also