Shortcuts

data

Functions

extract_batch_size

Unpack a batch to find a torch.Tensor.

has_len_all_ranks

Checks if a given object has __len__ method implemented on all ranks.

lightning.pytorch.utilities.data.extract_batch_size(batch)[source]

Unpack a batch to find a torch.Tensor.

Return type:

int

Returns:

len(tensor) when found, or 1 when it hits an empty or non iterable.

lightning.pytorch.utilities.data.has_len_all_ranks(dataloader, strategy, allow_zero_length_dataloader_with_multiple_devices=False)[source]

Checks if a given object has __len__ method implemented on all ranks.

Return type:

TypeGuard[Sized]