MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / get_batch

Function get_batch

SwissArmyTransformer/examples/t5/finetune_t5.py:25–42  ·  view source on GitHub ↗
(data_iterator, args, timers)

Source from the content-addressed store, hash-verified

23from sat.model import T5Model
24
25def get_batch(data_iterator, args, timers):
26 # Items and their type.
27 keys = ['sentence', 'label']
28 datatype = torch.int64
29
30 # Broadcast data.
31 timers('data loader').start()
32 if data_iterator is not None:
33 data = next(data_iterator)
34 else:
35 data = None
36 timers('data loader').stop()
37 data = data[0].to('cuda')
38 attention_mask = torch.ones((1, data.shape[-1], data.shape[-1]), device=data.device)
39 attention_mask.tril_()
40 attention_mask.unsqueeze_(1)
41
42 return data, torch.arange(data.shape[-1], device=data.device), attention_mask
43
44
45

Callers 1

forward_stepFunction · 0.70

Calls 3

startMethod · 0.80
stopMethod · 0.80
toMethod · 0.80

Tested by

no test coverage detected