Disable the redundant torch default initialization to accelerate model creation.
()
| 91 | |
| 92 | |
| 93 | def disable_torch_init(): |
| 94 | """ |
| 95 | Disable the redundant torch default initialization to accelerate model creation. |
| 96 | """ |
| 97 | import torch |
| 98 | setattr(torch.nn.Linear, "reset_parameters", lambda self: None) |
| 99 | setattr(torch.nn.LayerNorm, "reset_parameters", lambda self: None) |
| 100 | |
| 101 | |
| 102 | def violates_moderation(text): |
no outgoing calls
no test coverage detected