Dataset - move all to GPU

Hi. My Dataset is working with relatively small data, with no disc read. Tensors are moved to GPU in Dataset init() like that:

# Fill x&y lists...

self.x = torch.tensor(self.x, device = device, dtype = dtype)
self.y = torch.tensor(self.y, device = device, dtype = torch.int64)

In tutorials preferred approach is to move every batch to GPU after retrieve from DataLoader. Is that two methods equivalent?