(self, hidden_states, encoder_hidden_states, ipadapter_kwargs=None)
| 48 | |
| 49 | |
| 50 | def forward(self, hidden_states, encoder_hidden_states, ipadapter_kwargs=None): |
| 51 | # 1. Self-Attention |
| 52 | norm_hidden_states = self.norm1(hidden_states) |
| 53 | attn_output = self.attn1(norm_hidden_states, encoder_hidden_states=None) |
| 54 | hidden_states = attn_output + hidden_states |
| 55 | |
| 56 | # 2. Cross-Attention |
| 57 | norm_hidden_states = self.norm2(hidden_states) |
| 58 | attn_output = self.attn2(norm_hidden_states, encoder_hidden_states=encoder_hidden_states, ipadapter_kwargs=ipadapter_kwargs) |
| 59 | hidden_states = attn_output + hidden_states |
| 60 | |
| 61 | # 3. Feed-forward |
| 62 | norm_hidden_states = self.norm3(hidden_states) |
| 63 | ff_output = self.act_fn(norm_hidden_states) |
| 64 | ff_output = self.ff(ff_output) |
| 65 | hidden_states = ff_output + hidden_states |
| 66 | |
| 67 | return hidden_states |
| 68 | |
| 69 | |
| 70 | class DownSampler(torch.nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected