nvidia.dali.experimental.dynamic.constant#

nvidia.dali.experimental.dynamic.constant(*, batch_size=None, device=None, dtype=None, fdata=None, idata=None, layout=None, shape=None)#

Produces a batch of constant tensors.

The floating point input data should be placed in the fdata argument and integer data in idata. The data, which can be a flat vector of values or a scalar, is then reshaped according to the shape argument. If the data is scalar, it will be broadcast to fill the entire shape.

The operator only performs meaningful work at first invocation; subsequent calls will return a reference to the same memory.

The operator can be automatically instantiated in Python with a call to types.Constant(value, dtype, shape, layout). The value can be a scalar, a tuple, a list, or a numpy array. If not explicitly overridden, the shape and dtype, will be taken from the array.

Warning

64-bit integer and double precision arrays are not supported and will be silently downgraded to 32-bit.

Supported backends
  • ‘cpu’

  • ‘gpu’

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

    Output data type.

    If this value is not set, the output is float if the fdata argument is used and int if idata is used.

  • fdata (float or list of float, optional) –

    Contents of the constant that is produced (for floating point types).

    Note

    fdata and idata are mutually exclusive, and one of them is required.

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

    Contents of the constant that is produced (for integer point types).

    Note

    fdata and idata are mutually exclusive, and one of them is required.

  • layout (layout str, optional, default = ‘’) –

    Layout info.

    If set and not empty, the layout must match the dimensionality of the output.

  • shape (int or list of int, optional) – The desired shape of the output. If not set, the data is assumed to be 1D