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

Function get_batch

DeepSpeedExample/pretrain_bert.py:44–66  ·  view source on GitHub ↗

Build the batch.

(data_iterator)

Source from the content-addressed store, hash-verified

42
43
44def get_batch(data_iterator):
45 """Build the batch."""
46
47 # Items and their type.
48 keys = ['text', 'types', 'labels', 'is_random', 'loss_mask', 'padding_mask']
49 datatype = torch.int64
50
51 # Broadcast data.
52 if data_iterator is not None:
53 data = next(data_iterator)
54 else:
55 data = None
56 data_b = mpu.broadcast_data(keys, data, datatype)
57
58 # Unpack.
59 tokens = data_b['text'].long()
60 types = data_b['types'].long()
61 sentence_order = data_b['is_random'].long()
62 loss_mask = data_b['loss_mask'].float()
63 lm_labels = data_b['labels'].long()
64 padding_mask = data_b['padding_mask'].long()
65
66 return tokens, types, sentence_order, loss_mask, lm_labels, padding_mask
67
68
69def forward_step(data_iterator, model):

Callers 1

forward_stepFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected