(self, module: torch.nn.Linear, offload_dtype, offload_device, onload_dtype, onload_device, computation_dtype, computation_device)
| 40 | |
| 41 | class AutoWrappedLinear(torch.nn.Linear): |
| 42 | def __init__(self, module: torch.nn.Linear, offload_dtype, offload_device, onload_dtype, onload_device, computation_dtype, computation_device): |
| 43 | with init_weights_on_device(device=torch.device("meta")): |
| 44 | super().__init__(in_features=module.in_features, out_features=module.out_features, bias=module.bias is not None, dtype=offload_dtype, device=offload_device) |
| 45 | self.weight = module.weight |
| 46 | self.bias = module.bias |
| 47 | self.offload_dtype = offload_dtype |
| 48 | self.offload_device = offload_device |
| 49 | self.onload_dtype = onload_dtype |
| 50 | self.onload_device = onload_device |
| 51 | self.computation_dtype = computation_dtype |
| 52 | self.computation_device = computation_device |
| 53 | self.state = 0 |
| 54 | |
| 55 | def offload(self): |
| 56 | if self.state == 1 and (self.offload_dtype != self.onload_dtype or self.offload_device != self.onload_device): |
nothing calls this directly
no test coverage detected