(self, z, enc_fea)
| 756 | padding=1) |
| 757 | |
| 758 | def forward(self, z, enc_fea): |
| 759 | #assert z.shape[1:] == self.z_shape[1:] |
| 760 | self.last_z_shape = z.shape |
| 761 | |
| 762 | # timestep embedding |
| 763 | temb = None |
| 764 | |
| 765 | # z to block_in |
| 766 | h = self.conv_in(z) |
| 767 | |
| 768 | # middle |
| 769 | h = self.mid.block_1(h, temb) |
| 770 | h = self.mid.attn_1(h) |
| 771 | h = self.mid.block_2(h, temb) |
| 772 | |
| 773 | # upsampling |
| 774 | for i_level in reversed(range(self.num_resolutions)): |
| 775 | for i_block in range(self.num_res_blocks+1): |
| 776 | h = self.up[i_level].block[i_block](h, temb) |
| 777 | if len(self.up[i_level].attn) > 0: |
| 778 | h = self.up[i_level].attn[i_block](h) |
| 779 | |
| 780 | if i_level != self.num_resolutions-1 and i_level != 0: |
| 781 | cur_fuse_layer = getattr(self, 'fusion_layer_{}'.format(i_level)) |
| 782 | h = cur_fuse_layer(enc_fea[i_level-1], h, self.fusion_w) |
| 783 | |
| 784 | if i_level != 0: |
| 785 | h = self.up[i_level].upsample(h) |
| 786 | # end |
| 787 | if self.give_pre_end: |
| 788 | return h |
| 789 | |
| 790 | h = self.norm_out(h) |
| 791 | h = nonlinearity(h) |
| 792 | h = self.conv_out(h) |
| 793 | if self.tanh_out: |
| 794 | h = torch.tanh(h) |
| 795 | return h |
| 796 | |
| 797 | class ResBlock(nn.Module): |
| 798 | def __init__(self, in_channels, out_channels=None): |
nothing calls this directly
no test coverage detected