nvalchemi.data.datapipes.dataset_device#

nvalchemi.data.datapipes.dataset_device(dataset, probe=None)[source]#

Return the concrete device dataset emits its batches on.

The device comes from a declaration when the dataset has one: a target_device, or the device of a resident in_memory_batch. Otherwise a batch is drawn and its device is read. A MultiDataset declares no device, and a store opened without a device declares an index-less cuda that names whichever device is current, so the device of both is measured from a batch.

Parameters:
  • dataset (BatchDatasetProtocol) – Dataset to resolve the emission device of.

  • probe (Batch | None, optional) – A batch already drawn from dataset. When the device has to be measured, this batch is read instead of drawing a new one. Default None.

Returns:

Device batches are emitted on.

Return type:

torch.device

Examples

>>> from nvalchemi.data.datapipes import InMemoryDataset, dataset_device
>>> dataset_device(InMemoryDataset(in_memory_batch=batch))
device(type='cpu')