(self, x, attn_mask=None)
| 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 | |
| 102 | class DecoderLayer(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected