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

Method forward

diffsynth/models/stepvideo_dit.py:477–509  ·  view source on GitHub ↗
(
        self, 
        x,
        cu_seqlens=None,
        max_seqlen=None,
        rope_positions=None,
        attn_mask=None
    )

Source from the content-addressed store, hash-verified

475 return x
476
477 def forward(
478 self,
479 x,
480 cu_seqlens=None,
481 max_seqlen=None,
482 rope_positions=None,
483 attn_mask=None
484 ):
485 xqkv = self.wqkv(x)
486 xqkv = xqkv.view(*x.shape[:-1], self.n_heads, 3*self.head_dim)
487
488 xq, xk, xv = torch.split(xqkv, [self.head_dim]*3, dim=-1) ## seq_len, n, dim
489
490 if self.with_qk_norm:
491 xq = self.q_norm(xq)
492 xk = self.k_norm(xk)
493
494 if self.with_rope:
495 xq = self.apply_rope3d(xq, rope_positions, self.rope_ch_split, parallel=self.parallel)
496 xk = self.apply_rope3d(xk, rope_positions, self.rope_ch_split, parallel=self.parallel)
497
498 output = self.core_attention(
499 xq,
500 xk,
501 xv,
502 cu_seqlens=cu_seqlens,
503 max_seqlen=max_seqlen,
504 attn_mask=attn_mask
505 )
506 output = rearrange(output, 'b s h d -> b s (h d)')
507 output = self.wo(output)
508
509 return output
510
511
512class CrossAttention(Attention):

Callers

nothing calls this directly

Calls 1

apply_rope3dMethod · 0.95

Tested by

no test coverage detected