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

Method forward

src/diffusers/models/unets/unet_2d_blocks.py:3507–3543  ·  view source on GitHub ↗
(
        self,
        hidden_states: torch.FloatTensor,
        res_hidden_states_tuple: Tuple[torch.FloatTensor, ...],
        temb: Optional[torch.FloatTensor] = None,
        upsample_size: Optional[int] = None,
        scale: float = 1.0,
    )

Source from the content-addressed store, hash-verified

3505 self.resolution_idx = resolution_idx
3506
3507 def forward(
3508 self,
3509 hidden_states: torch.FloatTensor,
3510 res_hidden_states_tuple: Tuple[torch.FloatTensor, ...],
3511 temb: Optional[torch.FloatTensor] = None,
3512 upsample_size: Optional[int] = None,
3513 scale: float = 1.0,
3514 ) -> torch.FloatTensor:
3515 res_hidden_states_tuple = res_hidden_states_tuple[-1]
3516 if res_hidden_states_tuple is not None:
3517 hidden_states = torch.cat([hidden_states, res_hidden_states_tuple], dim=1)
3518
3519 for resnet in self.resnets:
3520 if self.training and self.gradient_checkpointing:
3521
3522 def create_custom_forward(module):
3523 def custom_forward(*inputs):
3524 return module(*inputs)
3525
3526 return custom_forward
3527
3528 if is_torch_version(">=", "1.11.0"):
3529 hidden_states = torch.utils.checkpoint.checkpoint(
3530 create_custom_forward(resnet), hidden_states, temb, use_reentrant=False
3531 )
3532 else:
3533 hidden_states = torch.utils.checkpoint.checkpoint(
3534 create_custom_forward(resnet), hidden_states, temb
3535 )
3536 else:
3537 hidden_states = resnet(hidden_states, temb, scale=scale)
3538
3539 if self.upsamplers is not None:
3540 for upsampler in self.upsamplers:
3541 hidden_states = upsampler(hidden_states)
3542
3543 return hidden_states
3544
3545
3546class KCrossAttnUpBlock2D(nn.Module):

Callers

nothing calls this directly

Calls 1

is_torch_versionFunction · 0.85

Tested by

no test coverage detected