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

Method apply_rope

diffsynth/models/flux_dit.py:221–226  ·  view source on GitHub ↗
(self, xq, xk, freqs_cis)

Source from the content-addressed store, hash-verified

219
220
221 def apply_rope(self, xq, xk, freqs_cis):
222 xq_ = xq.float().reshape(*xq.shape[:-1], -1, 1, 2)
223 xk_ = xk.float().reshape(*xk.shape[:-1], -1, 1, 2)
224 xq_out = freqs_cis[..., 0] * xq_[..., 0] + freqs_cis[..., 1] * xq_[..., 1]
225 xk_out = freqs_cis[..., 0] * xk_[..., 0] + freqs_cis[..., 1] * xk_[..., 1]
226 return xq_out.reshape(*xq.shape).type_as(xq), xk_out.reshape(*xk.shape).type_as(xk)
227
228
229 def process_attention(self, hidden_states, image_rotary_emb, attn_mask=None, ipadapter_kwargs_list=None):

Callers 1

process_attentionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected