pyTorch Plugin API reference

class nvidia.dali.plugin.pytorch.DALIClassificationIterator(pipelines, size, auto_reset=False, stop_at_epoch=False)

DALI iterator for classification tasks for pyTorch. It returns 2 outputs (data and label) in the form of pyTorch’s Tensor.

Calling

DALIClassificationIterator(pipelines, size)

is equivalent to calling

DALIGenericIterator(pipelines, ["data", "label"], size)
Parameters
  • pipelines (list of nvidia.dali.pipeline.Pipeline) – List of pipelines to use

  • size (int) – Epoch size.

  • auto_reset (bool, optional, default = False) – Whether the iterator resets itself for the next epoch or it requires reset() to be called separately.

  • stop_at_epoch (bool, optional, default = False) – Whether to return a fraction of a full batch of data such that the total entries returned by the iterator == ‘size’. Setting this flag to False will cause the iterator to return the first integer multiple of self._num_gpus * self.batch_size which exceeds ‘size’.

class nvidia.dali.plugin.pytorch.DALIGenericIterator(pipelines, output_map, size, auto_reset=False, stop_at_epoch=False)

General DALI iterator for pyTorch. It can return any number of outputs from the DALI pipeline in the form of pyTorch’s Tensors.

Parameters
  • pipelines (list of nvidia.dali.pipeline.Pipeline) – List of pipelines to use

  • output_map (list of str) – List of strings which maps consecutive outputs of DALI pipelines to user specified name. Outputs will be returned from iterator as dictionary of those names. Each name should be distinct

  • size (int) – Epoch size.

  • auto_reset (bool, optional, default = False) – Whether the iterator resets itself for the next epoch or it requires reset() to be called separately.

  • stop_at_epoch (bool, optional, default = False) – Whether to return a fraction of a full batch of data such that the total entries returned by the iterator == ‘size’. Setting this flag to False will cause the iterator to return the first integer multiple of self._num_gpus * self.batch_size which exceeds ‘size’.

next()

Returns the next batch of data.

reset()

Resets the iterator after the full epoch. DALI iterators do not support resetting before the end of the epoch and will ignore such request.

nvidia.dali.plugin.pytorch.feed_ndarray(dali_tensor, arr)

Copy contents of DALI tensor to pyTorch’s Tensor.

Parameters