MCPcopy Create free account
hub / github.com/FLC777/GLAT / forward

Method forward

fairseq/models/fairseq_decoder.py:23–40  ·  view source on GitHub ↗

Args: prev_output_tokens (LongTensor): shifted output tokens of shape `(batch, tgt_len)`, for teacher forcing encoder_out (dict, optional): output from the encoder, used for encoder-side attention Returns: tuple:

(self, prev_output_tokens, encoder_out=None, **kwargs)

Source from the content-addressed store, hash-verified

21
22
23 def forward(self, prev_output_tokens, encoder_out=None, **kwargs):
24 """
25 Args:
26 prev_output_tokens (LongTensor): shifted output tokens of shape
27 `(batch, tgt_len)`, for teacher forcing
28 encoder_out (dict, optional): output from the encoder, used for
29 encoder-side attention
30
31 Returns:
32 tuple:
33 - the decoder's output of shape `(batch, tgt_len, vocab)`
34 - a dictionary with any model-specific outputs
35 """
36 x, extra = self.extract_features(
37 prev_output_tokens, encoder_out=encoder_out, **kwargs
38 )
39 x = self.output_layer(x)
40 return x, extra
41
42 def extract_features(self, prev_output_tokens, encoder_out=None, **kwargs):
43 """

Callers

nothing calls this directly

Calls 2

extract_featuresMethod · 0.95
output_layerMethod · 0.95

Tested by

no test coverage detected