(self, x, pooled_text_emb, encoder_hidden_states, cross_attention_kwargs)
| 321 | self.upsample = None |
| 322 | |
| 323 | def forward(self, x, pooled_text_emb, encoder_hidden_states, cross_attention_kwargs): |
| 324 | if self.downsample is not None: |
| 325 | x = self.downsample(x) |
| 326 | |
| 327 | for res_block, attention_block in zip(self.res_blocks, self.attention_blocks): |
| 328 | x = res_block(x, pooled_text_emb) |
| 329 | |
| 330 | batch_size, channels, height, width = x.shape |
| 331 | x = x.view(batch_size, channels, height * width).permute(0, 2, 1) |
| 332 | x = attention_block( |
| 333 | x, encoder_hidden_states=encoder_hidden_states, cross_attention_kwargs=cross_attention_kwargs |
| 334 | ) |
| 335 | x = x.permute(0, 2, 1).view(batch_size, channels, height, width) |
| 336 | |
| 337 | if self.upsample is not None: |
| 338 | x = self.upsample(x) |
| 339 | |
| 340 | return x |
| 341 | |
| 342 | |
| 343 | class ConvNextBlock(nn.Module): |
nothing calls this directly
no test coverage detected