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

Method forward

diffsynth/models/stepvideo_dit.py:529–557  ·  view source on GitHub ↗
(
            self, 
            x: torch.Tensor,
            encoder_hidden_states: torch.Tensor,
            attn_mask=None
        )

Source from the content-addressed store, hash-verified

527 self.core_attention = self.attn_processor(attn_type=attn_type)
528
529 def forward(
530 self,
531 x: torch.Tensor,
532 encoder_hidden_states: torch.Tensor,
533 attn_mask=None
534 ):
535 xq = self.wq(x)
536 xq = xq.view(*xq.shape[:-1], self.n_heads, self.head_dim)
537
538 xkv = self.wkv(encoder_hidden_states)
539 xkv = xkv.view(*xkv.shape[:-1], self.n_heads, 2*self.head_dim)
540
541 xk, xv = torch.split(xkv, [self.head_dim]*2, dim=-1) ## seq_len, n, dim
542
543 if self.with_qk_norm:
544 xq = self.q_norm(xq)
545 xk = self.k_norm(xk)
546
547 output = self.core_attention(
548 xq,
549 xk,
550 xv,
551 attn_mask=attn_mask
552 )
553
554 output = rearrange(output, 'b s h d -> b s (h d)')
555 output = self.wo(output)
556
557 return output
558
559
560class GELU(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected