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 residentin_memory_batch. Otherwise a batch is drawn and its device is read. AMultiDatasetdeclares no device, and a store opened without a device declares an index-lesscudathat 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:
Examples
>>> from nvalchemi.data.datapipes import InMemoryDataset, dataset_device >>> dataset_device(InMemoryDataset(in_memory_batch=batch)) device(type='cpu')