(self, x, e)
| 511 | self.modulation = nn.Parameter(torch.randn(1, 2, dim) / dim**0.5) |
| 512 | |
| 513 | def forward(self, x, e): |
| 514 | assert e.dtype == torch.float32 |
| 515 | with amp.autocast(dtype=torch.float32, device_type="cuda"): |
| 516 | e = (self.modulation.to(dtype=e.dtype, device=e.device) + e.unsqueeze(1)).chunk(2, dim=1) |
| 517 | x = (self.head(self.norm(x) * (1 + e[1]) + e[0])) |
| 518 | return x |
| 519 | |
| 520 | |
| 521 | class MLPProj(torch.nn.Module): |