| 26 | ]) |
| 27 | |
| 28 | def forward(self, hidden_states, time_emb, text_emb, res_stack): |
| 29 | batch, _, height, width = hidden_states.shape |
| 30 | residual = hidden_states |
| 31 | |
| 32 | hidden_states = self.norm(hidden_states) |
| 33 | inner_dim = hidden_states.shape[1] |
| 34 | hidden_states = hidden_states.permute(0, 2, 3, 1).reshape(batch, height * width, inner_dim) |
| 35 | |
| 36 | for block in self.transformer_blocks: |
| 37 | hidden_states = block(hidden_states) |
| 38 | |
| 39 | hidden_states = hidden_states.reshape(batch, height, width, inner_dim).permute(0, 3, 1, 2).contiguous() |
| 40 | hidden_states = hidden_states + residual |
| 41 | |
| 42 | return hidden_states, time_emb, text_emb, res_stack |
| 43 | |
| 44 | |
| 45 | class TemporalResnetBlock(torch.nn.Module): |