MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / pad_freqs

Function pad_freqs

diffsynth/distributed/xdit_context_parallel.py:15–25  ·  view source on GitHub ↗
(original_tensor, target_len)

Source from the content-addressed store, hash-verified

13 return x.to(position.dtype)
14
15def pad_freqs(original_tensor, target_len):
16 seq_len, s1, s2 = original_tensor.shape
17 pad_size = target_len - seq_len
18 padding_tensor = torch.ones(
19 pad_size,
20 s1,
21 s2,
22 dtype=original_tensor.dtype,
23 device=original_tensor.device)
24 padded_tensor = torch.cat([original_tensor, padding_tensor], dim=0)
25 return padded_tensor
26
27def rope_apply(x, freqs, num_heads):
28 x = rearrange(x, "b s (n d) -> b s n d", n=num_heads)

Callers 1

rope_applyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected