(self, x, emb)
| 256 | |
| 257 | |
| 258 | def _forward(self, x, emb): |
| 259 | if self.updown: |
| 260 | in_rest, in_conv = self.in_layers[:-1], self.in_layers[-1] |
| 261 | h = in_rest(x) |
| 262 | h = self.h_upd(h) |
| 263 | x = self.x_upd(x) |
| 264 | h = in_conv(h) |
| 265 | else: |
| 266 | h = self.in_layers(x) |
| 267 | emb_out = self.emb_layers(emb).type(h.dtype) |
| 268 | while len(emb_out.shape) < len(h.shape): |
| 269 | emb_out = emb_out[..., None] |
| 270 | if self.use_scale_shift_norm: |
| 271 | out_norm, out_rest = self.out_layers[0], self.out_layers[1:] |
| 272 | scale, shift = th.chunk(emb_out, 2, dim=1) |
| 273 | h = out_norm(h) * (1 + scale) + shift |
| 274 | h = out_rest(h) |
| 275 | else: |
| 276 | h = h + emb_out |
| 277 | h = self.out_layers(h) |
| 278 | return self.skip_connection(x) + h |
| 279 | |
| 280 | |
| 281 | class AttentionBlock(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected