Modulate the input tensor using scaling and shifting parameters.
(x: torch.Tensor, shift: torch.Tensor, scale: torch.Tensor)
| 155 | |
| 156 | |
| 157 | def modulate(x: torch.Tensor, shift: torch.Tensor, scale: torch.Tensor) -> torch.Tensor: |
| 158 | """ |
| 159 | Modulate the input tensor using scaling and shifting parameters. |
| 160 | """ |
| 161 | # modified from https://github.com/facebookresearch/DiT/blob/796c29e532f47bba17c5b9c5eb39b9354b8b7c64/models.py#L19 |
| 162 | return x * (1 + scale) + shift |