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

Method forward

diffsynth/models/sd_motion.py:27–49  ·  view source on GitHub ↗
(self, hidden_states, batch_size=1)

Source from the content-addressed store, hash-verified

25
26
27 def forward(self, hidden_states, batch_size=1):
28
29 # 1. Self-Attention
30 norm_hidden_states = self.norm1(hidden_states)
31 norm_hidden_states = rearrange(norm_hidden_states, "(b f) h c -> (b h) f c", b=batch_size)
32 attn_output = self.attn1(norm_hidden_states + self.pe1[:, :norm_hidden_states.shape[1]])
33 attn_output = rearrange(attn_output, "(b h) f c -> (b f) h c", b=batch_size)
34 hidden_states = attn_output + hidden_states
35
36 # 2. Cross-Attention
37 norm_hidden_states = self.norm2(hidden_states)
38 norm_hidden_states = rearrange(norm_hidden_states, "(b f) h c -> (b h) f c", b=batch_size)
39 attn_output = self.attn2(norm_hidden_states + self.pe2[:, :norm_hidden_states.shape[1]])
40 attn_output = rearrange(attn_output, "(b h) f c -> (b f) h c", b=batch_size)
41 hidden_states = attn_output + hidden_states
42
43 # 3. Feed-forward
44 norm_hidden_states = self.norm3(hidden_states)
45 ff_output = self.act_fn(norm_hidden_states)
46 ff_output = self.ff(ff_output)
47 hidden_states = ff_output + hidden_states
48
49 return hidden_states
50
51
52class TemporalBlock(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected