| 29 | |
| 30 | |
| 31 | class DecoderLayer(nn.Module): |
| 32 | |
| 33 | def __init__(self, sa_block_cfg=None, ca_block_cfg=None, ffn_cfg=None): |
| 34 | super().__init__() |
| 35 | self.sa_block = build_attention(sa_block_cfg) |
| 36 | self.ca_block = build_attention(ca_block_cfg) |
| 37 | self.ffn = FFN(**ffn_cfg) |
| 38 | |
| 39 | def forward(self, **kwargs): |
| 40 | if self.sa_block is not None: |
| 41 | x = self.sa_block(**kwargs) |
| 42 | kwargs.update({'x': x}) |
| 43 | if self.ca_block is not None: |
| 44 | x = self.ca_block(**kwargs) |
| 45 | kwargs.update({'x': x}) |
| 46 | if self.ffn is not None: |
| 47 | x = self.ffn(**kwargs) |
| 48 | return x |
| 49 | |
| 50 | |
| 51 | class DiffusionTransformer(BaseModule, metaclass=ABCMeta): |
no outgoing calls
no test coverage detected