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

Method forward

inference/models/falcon.py:270–283  ·  view source on GitHub ↗
(self, tokens: torch.Tensor, start_pos: int)

Source from the content-addressed store, hash-verified

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
286class FalconForCausalLM(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected