| 113 | |
| 114 | |
| 115 | class Decoder(nn.Module): |
| 116 | def __init__(self, layers, norm_layer=None, projection=None): |
| 117 | super(Decoder, self).__init__() |
| 118 | self.layers = nn.ModuleList(layers) |
| 119 | self.norm = norm_layer |
| 120 | self.projection = projection |
| 121 | |
| 122 | def forward(self, x, cross, x_mask=None, cross_mask=None): |
| 123 | for layer in self.layers: |
| 124 | x = layer(x, cross, x_mask=x_mask, cross_mask=cross_mask) |
| 125 | |
| 126 | if self.norm is not None: |
| 127 | x = self.norm(x) |
| 128 | |
| 129 | if self.projection is not None: |
| 130 | x = self.projection(x) |
| 131 | return x |