(self)
| 277 | split_head_dim: bool = False |
| 278 | |
| 279 | def setup(self): |
| 280 | # self attention (or cross_attention if only_cross_attention is True) |
| 281 | self.attn1 = FlaxAttention( |
| 282 | self.dim, |
| 283 | self.n_heads, |
| 284 | self.d_head, |
| 285 | self.dropout, |
| 286 | self.use_memory_efficient_attention, |
| 287 | self.split_head_dim, |
| 288 | dtype=self.dtype, |
| 289 | ) |
| 290 | # cross attention |
| 291 | self.attn2 = FlaxAttention( |
| 292 | self.dim, |
| 293 | self.n_heads, |
| 294 | self.d_head, |
| 295 | self.dropout, |
| 296 | self.use_memory_efficient_attention, |
| 297 | self.split_head_dim, |
| 298 | dtype=self.dtype, |
| 299 | ) |
| 300 | self.ff = FlaxFeedForward(dim=self.dim, dropout=self.dropout, dtype=self.dtype) |
| 301 | self.norm1 = nn.LayerNorm(epsilon=1e-5, dtype=self.dtype) |
| 302 | self.norm2 = nn.LayerNorm(epsilon=1e-5, dtype=self.dtype) |
| 303 | self.norm3 = nn.LayerNorm(epsilon=1e-5, dtype=self.dtype) |
| 304 | self.dropout_layer = nn.Dropout(rate=self.dropout) |
| 305 | |
| 306 | def __call__(self, hidden_states, context, deterministic=True): |
| 307 | # self attention |
nothing calls this directly
no test coverage detected