| 366 | |
| 367 | @staticmethod |
| 368 | def A_log_init(d_state, d_inner, copies=1, device=None, merge=True): |
| 369 | # S4D real initialization |
| 370 | A = repeat( |
| 371 | torch.arange(1, d_state + 1, dtype=torch.float32, device=device), |
| 372 | "n -> d n", |
| 373 | d=d_inner, |
| 374 | ).contiguous() |
| 375 | A_log = torch.log(A) # Keep A_log in fp32 |
| 376 | if copies > 1: |
| 377 | A_log = repeat(A_log, "d n -> r d n", r=copies) |
| 378 | if merge: |
| 379 | A_log = A_log.flatten(0, 1) |
| 380 | A_log = nn.Parameter(A_log) |
| 381 | A_log._no_weight_decay = True |
| 382 | return A_log |
| 383 | |
| 384 | @staticmethod |
| 385 | def D_init(d_inner, copies=1, device=None, merge=True): |