MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __init__

Method __init__

diffsynth/vram_management/layers.py:42–53  ·  view source on GitHub ↗
(self, module: torch.nn.Linear, offload_dtype, offload_device, onload_dtype, onload_device, computation_dtype, computation_device)

Source from the content-addressed store, hash-verified

40
41class 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):

Callers

nothing calls this directly

Calls 2

init_weights_on_deviceFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected