Disable the redundant torch default initialization to accelerate model creation.
()
| 96 | |
| 97 | |
| 98 | def disable_torch_init(): |
| 99 | """ |
| 100 | Disable the redundant torch default initialization to accelerate model creation. |
| 101 | """ |
| 102 | import torch |
| 103 | |
| 104 | setattr(torch.nn.Linear, "reset_parameters", lambda self: None) |
| 105 | setattr(torch.nn.LayerNorm, "reset_parameters", lambda self: None) |
| 106 | |
| 107 | |
| 108 | def violates_moderation(text): |
nothing calls this directly
no outgoing calls
no test coverage detected