r""" Args: x(Tensor): Shape [B, L1, C] e(Tensor): Shape [B, C]
(self, x, e)
| 335 | self.modulation = nn.Parameter(torch.randn(1, 2, dim) / dim**0.5) |
| 336 | |
| 337 | def forward(self, x, e): |
| 338 | r""" |
| 339 | Args: |
| 340 | x(Tensor): Shape [B, L1, C] |
| 341 | e(Tensor): Shape [B, C] |
| 342 | """ |
| 343 | assert e.dtype == torch.float32 |
| 344 | with amp.autocast(dtype=torch.float32): |
| 345 | e = (self.modulation.to(e.device) + e.unsqueeze(1)).chunk(2, dim=1) |
| 346 | x = (self.head(self.norm(x) * (1 + e[1]) + e[0])) |
| 347 | return x |
| 348 | |
| 349 | |
| 350 | class MLPProj(torch.nn.Module): |