(
self,
attention_mode=None,
cross_frame_attention_mode=None,
temporal_position_encoding=False,
temporal_position_encoding_max_len=24,
*args,
**kwargs,
)
| 278 | |
| 279 | class VersatileAttention(Attention): |
| 280 | def __init__( |
| 281 | self, |
| 282 | attention_mode=None, |
| 283 | cross_frame_attention_mode=None, |
| 284 | temporal_position_encoding=False, |
| 285 | temporal_position_encoding_max_len=24, |
| 286 | *args, |
| 287 | **kwargs, |
| 288 | ): |
| 289 | super().__init__(*args, **kwargs) |
| 290 | assert attention_mode == "Temporal" |
| 291 | |
| 292 | self.attention_mode = attention_mode |
| 293 | self.is_cross_attention = kwargs["cross_attention_dim"] is not None |
| 294 | |
| 295 | self.pos_encoder = ( |
| 296 | PositionalEncoding( |
| 297 | kwargs["query_dim"], |
| 298 | dropout=0.0, |
| 299 | max_len=temporal_position_encoding_max_len, |
| 300 | ) |
| 301 | if (temporal_position_encoding and attention_mode == "Temporal") |
| 302 | else None |
| 303 | ) |
| 304 | |
| 305 | def extra_repr(self): |
| 306 | return f"(Module Info) Attention_Mode: {self.attention_mode}, Is_Cross_Attention: {self.is_cross_attention}" |
nothing calls this directly
no test coverage detected