(hidden_states, q, ip_k, ip_v, scale=1.0)
| 5 | from .utils import init_weights_on_device |
| 6 | |
| 7 | def interact_with_ipadapter(hidden_states, q, ip_k, ip_v, scale=1.0): |
| 8 | batch_size, num_tokens = hidden_states.shape[0:2] |
| 9 | ip_hidden_states = torch.nn.functional.scaled_dot_product_attention(q, ip_k, ip_v) |
| 10 | ip_hidden_states = ip_hidden_states.transpose(1, 2).reshape(batch_size, num_tokens, -1) |
| 11 | hidden_states = hidden_states + scale * ip_hidden_states |
| 12 | return hidden_states |
| 13 | |
| 14 | |
| 15 | class RoPEEmbedding(torch.nn.Module): |
no outgoing calls
no test coverage detected