mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-02-07 06:02:53 +08:00
faster by calculating R in updown and using cached R in forward
This commit is contained in:
parent
853e21d98e
commit
eb01d7f0e0
@ -58,17 +58,18 @@ class NetworkModuleOFT(network.NetworkModule):
|
|||||||
|
|
||||||
def calc_updown(self, orig_weight):
|
def calc_updown(self, orig_weight):
|
||||||
# this works
|
# this works
|
||||||
R = self.R
|
# R = self.R
|
||||||
|
self.R = self.get_weight(self.multiplier())
|
||||||
|
|
||||||
# this causes major deepfrying i.e. just doesn't work
|
# sending R to device causes major deepfrying i.e. just doesn't work
|
||||||
# R = self.R.to(orig_weight.device, dtype=orig_weight.dtype)
|
# R = self.R.to(orig_weight.device, dtype=orig_weight.dtype)
|
||||||
|
|
||||||
if orig_weight.dim() == 4:
|
# if orig_weight.dim() == 4:
|
||||||
weight = torch.einsum("oihw, op -> pihw", orig_weight, R)
|
# weight = torch.einsum("oihw, op -> pihw", orig_weight, R)
|
||||||
else:
|
# else:
|
||||||
weight = torch.einsum("oi, op -> pi", orig_weight, R)
|
# weight = torch.einsum("oi, op -> pi", orig_weight, R)
|
||||||
|
|
||||||
updown = orig_weight @ R
|
updown = orig_weight @ self.R
|
||||||
output_shape = self.oft_blocks.shape
|
output_shape = self.oft_blocks.shape
|
||||||
|
|
||||||
## this works
|
## this works
|
||||||
|
Loading…
Reference in New Issue
Block a user