MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / process_batch

Function process_batch

DeepSpeedExample/tasks/zeroshot_gpt2/evaluate.py:58–76  ·  view source on GitHub ↗

Process batch and produce inputs for the model.

(batch)

Source from the content-addressed store, hash-verified

56
57
58def process_batch(batch):
59 """Process batch and produce inputs for the model."""
60 args = get_args()
61 tokenizer = get_tokenizer()
62
63 loss_mask = batch['pad_mask'].long().cuda().contiguous().byte()
64 tokens_ = batch['text'].long().cuda().contiguous()
65 labels = tokens_[:, 1:].contiguous()
66 tokens = tokens_[:, :-1].contiguous()
67
68 # Get the masks and postition ids.
69 attention_mask, _, position_ids = get_ltor_masks_and_position_ids(
70 tokens,
71 tokenizer.eod,
72 args.reset_position_ids,
73 args.reset_attention_mask,
74 args.eod_mask_loss)
75
76 return tokens, labels, attention_mask, position_ids, loss_mask
77
78
79def forward_step(batch, model, eval_metric):

Callers 1

forward_stepFunction · 0.70

Calls 3

get_argsFunction · 0.90
get_tokenizerFunction · 0.90

Tested by

no test coverage detected