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

Function pad_batch

codegeex/megatron/code_generation_utils.py:540–547  ·  view source on GitHub ↗
(batch, pad_id, args)

Source from the content-addressed store, hash-verified

538
539
540def pad_batch(batch, pad_id, args):
541 context_lengths = []
542 for tokens in batch:
543 context_length = len(tokens)
544 if context_length < args.seq_length:
545 tokens.extend([pad_id] * (args.seq_length - context_length))
546 context_lengths.append(context_length)
547 return batch, context_lengths
548
549
550def topk_sampling(logits: torch.FloatTensor, num_samples: int):

Callers 4

expand_beamsFunction · 0.70
expand_handlesFunction · 0.70
get_token_streamFunction · 0.70
sample_sequence_batchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected