MCPcopy Create free account
hub / github.com/JaydenLyh/Reward-Forcing / lazy_positional_encoding

Function lazy_positional_encoding

demo_utils/utils.py:513–527  ·  view source on GitHub ↗
(t, repeats=None)

Source from the content-addressed store, hash-verified

511
512
513def lazy_positional_encoding(t, repeats=None):
514 if not isinstance(t, list):
515 t = [t]
516
517 from diffusers.models.embeddings import get_timestep_embedding
518
519 te = torch.tensor(t)
520 te = get_timestep_embedding(timesteps=te, embedding_dim=256, flip_sin_to_cos=True, downscale_freq_shift=0.0, scale=1.0)
521
522 if repeats is None:
523 return te
524
525 te = te[:, None, :].expand(-1, repeats, -1)
526
527 return te
528
529
530def state_dict_offset_merge(A, B, C=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected