(self, x)
| 829 | ) |
| 830 | |
| 831 | def forward(self, x): |
| 832 | # timestep embedding |
| 833 | temb = None |
| 834 | |
| 835 | # downsampling |
| 836 | hs = [self.conv_in(x)] |
| 837 | for i_level in range(self.num_resolutions): |
| 838 | for i_block in range(self.num_res_blocks): |
| 839 | if self.gradient_checkpointing and self.training: |
| 840 | h = torch.utils.checkpoint.checkpoint( |
| 841 | self.down[i_level].block[i_block].__call__, |
| 842 | hs[-1], |
| 843 | temb, |
| 844 | use_reentrant=False, |
| 845 | ) |
| 846 | else: |
| 847 | h = self.down[i_level].block[i_block](hs[-1], temb) |
| 848 | if len(self.down[i_level].attn) > 0: |
| 849 | h = self.down[i_level].attn[i_block](h) |
| 850 | hs.append(h) |
| 851 | if i_level != self.num_resolutions - 1: |
| 852 | hs.append(self.down[i_level].downsample(hs[-1])) |
| 853 | |
| 854 | # middle |
| 855 | h = hs[-1] |
| 856 | h = self.mid.block_1(h, temb) |
| 857 | h = self.mid.attn_1(h) |
| 858 | h = self.mid.block_2(h, temb) |
| 859 | |
| 860 | # end |
| 861 | h = self.norm_out(h) |
| 862 | h = nonlinearity(h) |
| 863 | h = self.conv_out(h) |
| 864 | return h |
| 865 | |
| 866 | |
| 867 | class Decoder(nn.Module): |
no test coverage detected