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

Function get_batch

DeepSpeedExample/megatron/text_generation_utils.py:32–47  ·  view source on GitHub ↗

Generate batch from context tokens.

(context_tokens)

Source from the content-addressed store, hash-verified

30
31
32def get_batch(context_tokens):
33 """Generate batch from context tokens."""
34 args = get_args()
35 tokenizer = get_tokenizer()
36
37 # Move to GPU.
38 tokens = context_tokens.view(args.batch_size, -1).contiguous().cuda()
39 # Get the attention mask and postition ids.
40 attention_mask, _, position_ids = get_ltor_masks_and_position_ids(
41 tokens,
42 tokenizer.eod,
43 args.reset_position_ids,
44 args.reset_attention_mask,
45 args.eod_mask_loss)
46
47 return tokens, attention_mask, position_ids
48
49
50def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):

Callers 1

get_token_streamFunction · 0.70

Calls 3

get_argsFunction · 0.90
get_tokenizerFunction · 0.90

Tested by

no test coverage detected