(self, input_ids, attention_mask)
| 39 | return text_embeds # bs x ntoken x ch |
| 40 | |
| 41 | def forward(self, input_ids, attention_mask): |
| 42 | net_device = next(self.parameters()).device |
| 43 | text_embeds = self.encode_text(input_ids=input_ids, attention_mask=attention_mask) |
| 44 | query_embeds = self.query_embeds( |
| 45 | repeat( |
| 46 | torch.arange(0, self.n_learnable_queries, dtype=torch.int64).to(net_device), |
| 47 | 'src -> bs src', |
| 48 | bs = text_embeds.shape[0] |
| 49 | ) |
| 50 | ) |
| 51 | query_outputs = self.qformer( |
| 52 | query_embeds=query_embeds, |
| 53 | encoder_hidden_states=text_embeds, |
| 54 | encoder_attention_mask=attention_mask |
| 55 | ) |
| 56 | query_outputs = query_outputs[0][:, : self.n_learnable_queries, :] |
| 57 | return self.out_project(query_outputs) |
| 58 | |
| 59 | |
| 60 |
nothing calls this directly
no test coverage detected