r"""The forward method of the `DecoderTiny` class.
(self, x: torch.Tensor)
| 958 | self.gradient_checkpointing = False |
| 959 | |
| 960 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 961 | r"""The forward method of the `DecoderTiny` class.""" |
| 962 | # Clamp. |
| 963 | x = torch.tanh(x / 3) * 3 |
| 964 | |
| 965 | if self.training and self.gradient_checkpointing: |
| 966 | |
| 967 | def create_custom_forward(module): |
| 968 | def custom_forward(*inputs): |
| 969 | return module(*inputs) |
| 970 | |
| 971 | return custom_forward |
| 972 | |
| 973 | if is_torch_version(">=", "1.11.0"): |
| 974 | x = torch.utils.checkpoint.checkpoint(create_custom_forward(self.layers), x, use_reentrant=False) |
| 975 | else: |
| 976 | x = torch.utils.checkpoint.checkpoint(create_custom_forward(self.layers), x) |
| 977 | |
| 978 | else: |
| 979 | x = self.layers(x) |
| 980 | |
| 981 | # scale image from [0, 1] to [-1, 1] to match diffusers convention |
| 982 | return x.mul(2).sub(1) |
nothing calls this directly
no test coverage detected