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