(self, x, pooled_text_emb, encoder_hidden_states, cross_attention_kwargs)
| 384 | self.upsample = None |
| 385 | |
| 386 | def forward(self, x, pooled_text_emb, encoder_hidden_states, cross_attention_kwargs): |
| 387 | if self.downsample is not None: |
| 388 | x = self.downsample(x) |
| 389 | |
| 390 | for res_block, attention_block in zip(self.res_blocks, self.attention_blocks): |
| 391 | x = res_block(x, pooled_text_emb) |
| 392 | |
| 393 | batch_size, channels, height, width = x.shape |
| 394 | x = x.view(batch_size, channels, height * width).permute(0, 2, 1) |
| 395 | x = attention_block( |
| 396 | x, encoder_hidden_states=encoder_hidden_states, cross_attention_kwargs=cross_attention_kwargs |
| 397 | ) |
| 398 | x = x.permute(0, 2, 1).view(batch_size, channels, height, width) |
| 399 | |
| 400 | if self.upsample is not None: |
| 401 | x = self.upsample(x) |
| 402 | |
| 403 | return x |
| 404 | |
| 405 | |
| 406 | class ConvNextBlock(nn.Module): |
nothing calls this directly
no test coverage detected