(data_iterator, args, timers)
| 23 | from sat.model import T5Model |
| 24 | |
| 25 | def 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 |
no test coverage detected