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

Method __init__

diffsynth/models/attention.py:17–27  ·  view source on GitHub ↗
(self, q_dim, num_heads, head_dim, kv_dim=None, bias_q=False, bias_kv=False, bias_out=False)

Source from the content-addressed store, hash-verified

15class Attention(torch.nn.Module):
16
17 def __init__(self, q_dim, num_heads, head_dim, kv_dim=None, bias_q=False, bias_kv=False, bias_out=False):
18 super().__init__()
19 dim_inner = head_dim * num_heads
20 kv_dim = kv_dim if kv_dim is not None else q_dim
21 self.num_heads = num_heads
22 self.head_dim = head_dim
23
24 self.to_q = torch.nn.Linear(q_dim, dim_inner, bias=bias_q)
25 self.to_k = torch.nn.Linear(kv_dim, dim_inner, bias=bias_kv)
26 self.to_v = torch.nn.Linear(kv_dim, dim_inner, bias=bias_kv)
27 self.to_out = torch.nn.Linear(dim_inner, q_dim, bias=bias_out)
28
29 def interact_with_ipadapter(self, hidden_states, q, ip_k, ip_v, scale=1.0):
30 batch_size = q.shape[0]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected