MCPcopy
hub / github.com/Lightricks/ComfyUI-LTXVideo / _cat_with_padding

Function _cat_with_padding

gemma_encoder.py:499–516  ·  view source on GitHub ↗

Concatenate a tensor with a padding tensor of the given value.

(
    tensor: torch.Tensor,
    padding_length: int,
    value: int | float,
)

Source from the content-addressed store, hash-verified

497
498
499def _cat_with_padding(
500 tensor: torch.Tensor,
501 padding_length: int,
502 value: int | float,
503) -> torch.Tensor:
504 """Concatenate a tensor with a padding tensor of the given value."""
505 return torch.cat(
506 [
507 tensor,
508 torch.full(
509 (1, padding_length),
510 value,
511 dtype=tensor.dtype,
512 device=tensor.device,
513 ),
514 ],
515 dim=1,
516 )
517
518
519def _pad_inputs_for_attention_alignment(model_inputs, pad_token_id, alignment: int = 8):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected