Process batch and produce inputs for the model.
(batch)
| 32 | |
| 33 | |
| 34 | def process_batch(batch): |
| 35 | """Process batch and produce inputs for the model.""" |
| 36 | args = get_args() |
| 37 | |
| 38 | tokens = batch['text'].long().cuda().contiguous() |
| 39 | types = batch['types'].long().cuda().contiguous() |
| 40 | labels = batch['label'].long().cuda().contiguous() |
| 41 | attention_mask = batch['padding_mask'].float().cuda().contiguous() |
| 42 | if args.fp16: |
| 43 | attention_mask = attention_mask.half() |
| 44 | |
| 45 | return tokens, types, labels, attention_mask |
| 46 | |
| 47 | |
| 48 | def _cross_entropy_forward_step(batch, model): |
no test coverage detected