MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / forward

Method forward

src/diffusers/models/autoencoders/vae.py:961–983  ·  view source on GitHub ↗

r"""The forward method of the `DecoderTiny` class.

(self, x: torch.FloatTensor)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

is_torch_versionFunction · 0.85
layersMethod · 0.80

Tested by

no test coverage detected