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

Method forward

utils/wan_wrapper.py:38–51  ·  view source on GitHub ↗
(self, text_prompts: List[str])

Source from the content-addressed store, hash-verified

36 return torch.cuda.current_device()
37
38 def forward(self, text_prompts: List[str]) -> dict:
39 ids, mask = self.tokenizer(
40 text_prompts, return_mask=True, add_special_tokens=True)
41 ids = ids.to(self.device)
42 mask = mask.to(self.device)
43 seq_lens = mask.gt(0).sum(dim=1).long()
44 context = self.text_encoder(ids, mask)
45
46 for u, v in zip(context, seq_lens):
47 u[v:] = 0.0 # set padding to 0.0
48
49 return {
50 "prompt_embeds": context
51 }
52
53
54class WanVAEWrapper(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected