MCPcopy Index your code
hub / github.com/zai-org/CodeGeeX / get_batch_

Function get_batch_

codegeex/megatron/code_generation_utils.py:56–72  ·  view source on GitHub ↗

Generate batch from context tokens.

(context_tokens)

Source from the content-addressed store, hash-verified

54
55
56def get_batch_(context_tokens):
57 """Generate batch from context tokens."""
58 args = get_args()
59 tokenizer = get_tokenizer()
60
61 # Move to GPU.
62 tokens = context_tokens.contiguous().cuda()
63 # Get the attention mask and postition ids.
64 attention_mask, _, position_ids = get_ltor_masks_and_position_ids(
65 tokens,
66 tokenizer.eod,
67 args.reset_position_ids,
68 args.reset_attention_mask,
69 args.eod_mask_loss,
70 )
71
72 return tokens, attention_mask, position_ids
73
74
75def top_k_logits(logits, top_k=0, top_p=0.0, filter_value=-float("Inf")):

Callers 2

expand_beamsFunction · 0.85
expand_handlesFunction · 0.85

Calls 3

get_argsFunction · 0.90
get_tokenizerFunction · 0.90

Tested by

no test coverage detected