(self, prompts, tokenized_prompts)
| 65 | self.dtype = clip_model.dtype |
| 66 | |
| 67 | def forward(self, prompts, tokenized_prompts): |
| 68 | |
| 69 | x = prompts + self.positional_embedding.type(self.dtype) |
| 70 | |
| 71 | x = x.permute(1, 0, 2) # NLD -> LND |
| 72 | x = self.transformer(x) |
| 73 | x = x.permute(1, 0, 2) # LND -> NLD |
| 74 | x = self.ln_final(x).type(self.dtype) |
| 75 | |
| 76 | x = x[torch.arange(x.shape[0]), tokenized_prompts.argmax(dim=-1)] @ self.text_projection |
| 77 | |
| 78 | return x |
| 79 | |
| 80 | |
| 81 | class PromptLearner(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected