MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / forward

Method forward

diffsynth/models/step1x_connector.py:604–630  ·  view source on GitHub ↗
(
        self,
        x: torch.Tensor,
        t: torch.LongTensor,
        mask: Optional[torch.LongTensor] = None,
        y: torch.LongTensor=None,
    )

Source from the content-addressed store, hash-verified

602 )
603
604 def forward(
605 self,
606 x: torch.Tensor,
607 t: torch.LongTensor,
608 mask: Optional[torch.LongTensor] = None,
609 y: torch.LongTensor=None,
610 ):
611 timestep_aware_representations = self.t_embedder(t)
612
613 if mask is None:
614 context_aware_representations = x.mean(dim=1)
615 else:
616 mask_float = mask.unsqueeze(-1) # [b, s1, 1]
617 context_aware_representations = (x * mask_float).sum(
618 dim=1
619 ) / mask_float.sum(dim=1)
620 context_aware_representations = self.c_embedder(context_aware_representations)
621 c = timestep_aware_representations + context_aware_representations
622
623 x = self.input_embedder(x)
624 if self.need_CA:
625 y = self.input_embedder_CA(y)
626 x = self.individual_token_refiner(x, c, mask, y)
627 else:
628 x = self.individual_token_refiner(x, c, mask)
629
630 return x
631
632
633class Qwen2Connector(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected