MCPcopy Create free account
hub / github.com/pytorch/executorch / forward

Method forward

examples/llm_pte_finetuning/training_lib.py:50–59  ·  view source on GitHub ↗
(self, input: torch.Tensor, labels: torch.Tensor)

Source from the content-addressed store, hash-verified

48 )
49
50 def forward(self, input: torch.Tensor, labels: torch.Tensor) -> torch.Tensor:
51 # Output is of the shape (seq_len, vocab_size).
52 logits = self.model(input)
53 labels = torch.hstack(
54 (labels[..., 1:], self.ignore_labels_cache[: labels.shape[0]])
55 )
56 if not isinstance(logits, list):
57 labels = labels.reshape(-1)
58 logits = logits.reshape(-1, logits.size(-1))
59 return self.loss(logits, labels)
60
61
62def python_code_instructions_alpaca(tokenizer: ModelTokenizer) -> PackedDataset:

Callers 2

mainFunction · 0.45
eval_modelFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected