(self, tokens: torch.Tensor, start_pos: int)
| 268 | |
| 269 | @torch.inference_mode() |
| 270 | def forward(self, tokens: torch.Tensor, start_pos: int): |
| 271 | _bsz, seqlen = tokens.shape |
| 272 | h = self.word_embeddings(tokens) |
| 273 | |
| 274 | mask = None |
| 275 | if seqlen > 1: |
| 276 | mask = torch.full( |
| 277 | (1, 1, seqlen, seqlen), float("-inf"), device=tokens.device |
| 278 | ) |
| 279 | mask = torch.triu(mask, diagonal=start_pos + 1).type_as(h) |
| 280 | for layer in self.h: |
| 281 | h = layer(h, start_pos, mask) |
| 282 | h = self.ln_f(h) |
| 283 | return h |
| 284 | |
| 285 | |
| 286 | class FalconForCausalLM(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected