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

Method forward

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

Source from the content-addressed store, hash-verified

3147 self.resolution_idx = resolution_idx
3148
3149 def forward(
3150 self,
3151 hidden_states: torch.FloatTensor,
3152 res_hidden_states_tuple: Tuple[torch.FloatTensor, ...],
3153 temb: Optional[torch.FloatTensor] = None,
3154 skip_sample=None,
3155 scale: float = 1.0,
3156 ) -> Tuple[torch.FloatTensor, torch.FloatTensor]:
3157 for resnet in self.resnets:
3158 # pop res hidden states
3159 res_hidden_states = res_hidden_states_tuple[-1]
3160 res_hidden_states_tuple = res_hidden_states_tuple[:-1]
3161 hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1)
3162
3163 hidden_states = resnet(hidden_states, temb, scale=scale)
3164
3165 if skip_sample is not None:
3166 skip_sample = self.upsampler(skip_sample)
3167 else:
3168 skip_sample = 0
3169
3170 if self.resnet_up is not None:
3171 skip_sample_states = self.skip_norm(hidden_states)
3172 skip_sample_states = self.act(skip_sample_states)
3173 skip_sample_states = self.skip_conv(skip_sample_states)
3174
3175 skip_sample = skip_sample + skip_sample_states
3176
3177 hidden_states = self.resnet_up(hidden_states, temb, scale=scale)
3178
3179 return hidden_states, skip_sample
3180
3181
3182class ResnetUpsampleBlock2D(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected