(self, text_prompts: List[str])
| 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 | |
| 54 | class WanVAEWrapper(torch.nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected