(self, dim, num_attention_heads, use_rms_norm=False, dual=False)
| 242 | |
| 243 | class JointTransformerBlock(torch.nn.Module): |
| 244 | def __init__(self, dim, num_attention_heads, use_rms_norm=False, dual=False): |
| 245 | super().__init__() |
| 246 | self.norm1_a = AdaLayerNorm(dim, dual=dual) |
| 247 | self.norm1_b = AdaLayerNorm(dim) |
| 248 | |
| 249 | self.attn = JointAttention(dim, dim, num_attention_heads, dim // num_attention_heads, use_rms_norm=use_rms_norm) |
| 250 | if dual: |
| 251 | self.attn2 = SingleAttention(dim, num_attention_heads, dim // num_attention_heads, use_rms_norm=use_rms_norm) |
| 252 | |
| 253 | self.norm2_a = torch.nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6) |
| 254 | self.ff_a = torch.nn.Sequential( |
| 255 | torch.nn.Linear(dim, dim*4), |
| 256 | torch.nn.GELU(approximate="tanh"), |
| 257 | torch.nn.Linear(dim*4, dim) |
| 258 | ) |
| 259 | |
| 260 | self.norm2_b = torch.nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6) |
| 261 | self.ff_b = torch.nn.Sequential( |
| 262 | torch.nn.Linear(dim, dim*4), |
| 263 | torch.nn.GELU(approximate="tanh"), |
| 264 | torch.nn.Linear(dim*4, dim) |
| 265 | ) |
| 266 | |
| 267 | |
| 268 | def forward(self, hidden_states_a, hidden_states_b, temb): |
nothing calls this directly
no test coverage detected