MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / forward

Method forward

inference/models/mpt.py:273–286  ·  view source on GitHub ↗
(self, tokens: torch.Tensor, start_pos: int)

Source from the content-addressed store, hash-verified

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
289class MPTForCausalLM(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected