MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / forward

Method forward

layers/Transformer_EncDec.py:81–99  ·  view source on GitHub ↗
(self, x, attn_mask=None)

Source from the content-addressed store, hash-verified

79 self.norm = norm_layer
80
81 def forward(self, x, attn_mask=None):
82 # x [B, L, D]
83 attns = []
84 if self.conv_layers is not None:
85 for attn_layer, conv_layer in zip(self.attn_layers, self.conv_layers):
86 x, attn = attn_layer(x, attn_mask=attn_mask)
87 x = conv_layer(x)
88 attns.append(attn)
89 x, attn = self.attn_layers[-1](x)
90 attns.append(attn)
91 else:
92 for attn_layer in self.attn_layers:
93 x, attn = attn_layer(x, attn_mask=attn_mask)
94 attns.append(attn)
95
96 if self.norm is not None:
97 x = self.norm(x)
98
99 return x, attns
100
101
102class DecoderLayer(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected