A sequential module that passes timestep embeddings to the children that support it as an extra input.
| 33 | |
| 34 | |
| 35 | class TimestepEmbedSequential(nn.Sequential, TimestepBlock): |
| 36 | """ |
| 37 | A sequential module that passes timestep embeddings to the children that |
| 38 | support it as an extra input. |
| 39 | """ |
| 40 | |
| 41 | def forward(self, x, emb): |
| 42 | for layer in self: |
| 43 | if isinstance(layer, TimestepBlock): |
| 44 | x = layer(x, emb) |
| 45 | else: |
| 46 | x = layer(x) |
| 47 | return x |
| 48 | |
| 49 | |
| 50 | class Upsample(nn.Module): |