(self, x, temb)
| 89 | self.nin_shortcut = torch.nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0) |
| 90 | |
| 91 | def forward(self, x, temb): |
| 92 | h = x |
| 93 | h = self.norm1(h) |
| 94 | h = nonlinearity(h) |
| 95 | h = self.conv1(h) |
| 96 | |
| 97 | if temb is not None: |
| 98 | h = h + self.temb_proj(nonlinearity(temb))[:, :, None, None] |
| 99 | |
| 100 | h = self.norm2(h) |
| 101 | h = nonlinearity(h) |
| 102 | h = self.dropout(h) |
| 103 | h = self.conv2(h) |
| 104 | |
| 105 | if self.in_channels != self.out_channels: |
| 106 | if self.use_conv_shortcut: |
| 107 | x = self.conv_shortcut(x) |
| 108 | else: |
| 109 | x = self.nin_shortcut(x) |
| 110 | |
| 111 | return x + h |
| 112 | |
| 113 | |
| 114 | class AttnBlock(nn.Module): |
nothing calls this directly
no test coverage detected