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

Method forward

diffsynth/models/flux_dit.py:173–186  ·  view source on GitHub ↗
(self, hidden_states, image_rotary_emb)

Source from the content-addressed store, hash-verified

171
172
173 def forward(self, hidden_states, image_rotary_emb):
174 batch_size = hidden_states.shape[0]
175
176 qkv_a = self.a_to_qkv(hidden_states)
177 qkv_a = qkv_a.view(batch_size, -1, 3 * self.num_heads, self.head_dim).transpose(1, 2)
178 q_a, k_a, v = qkv_a.chunk(3, dim=1)
179 q_a, k_a = self.norm_q_a(q_a), self.norm_k_a(k_a)
180
181 q, k = self.apply_rope(q_a, k_a, image_rotary_emb)
182
183 hidden_states = torch.nn.functional.scaled_dot_product_attention(q, k, v)
184 hidden_states = hidden_states.transpose(1, 2).reshape(batch_size, -1, self.num_heads * self.head_dim)
185 hidden_states = hidden_states.to(q.dtype)
186 return hidden_states
187
188
189

Callers

nothing calls this directly

Calls 2

apply_ropeMethod · 0.95
toMethod · 0.45

Tested by

no test coverage detected