A sequential module that passes timestep embeddings to the children that support it as an extra input.
| 64 | |
| 65 | |
| 66 | class TimestepEmbedSequential(nn.Sequential, TimestepBlock): |
| 67 | """ |
| 68 | A sequential module that passes timestep embeddings to the children that |
| 69 | support it as an extra input. |
| 70 | """ |
| 71 | |
| 72 | def forward(self, x, emb): |
| 73 | for layer in self: |
| 74 | if isinstance(layer, TimestepBlock): |
| 75 | x = layer(x, emb) |
| 76 | else: |
| 77 | x = layer(x) |
| 78 | return x |
| 79 | |
| 80 | |
| 81 | class Upsample(nn.Module): |