diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-16 20:13:55 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-16 20:13:55 +0000 |
commit | b75b004fe62826455f1aa77e849e7da13902cb17 (patch) | |
tree | 23aa9debf80fff6ef7fe9778e56df6a135065310 /extensions-builtin/Lora/lyco_helpers.py | |
parent | 7d26c479eebec03c2abb28f7b5226791688a7cea (diff) | |
download | stable-diffusion-webui-gfx803-b75b004fe62826455f1aa77e849e7da13902cb17.tar.gz stable-diffusion-webui-gfx803-b75b004fe62826455f1aa77e849e7da13902cb17.tar.bz2 stable-diffusion-webui-gfx803-b75b004fe62826455f1aa77e849e7da13902cb17.zip |
lora extension rework to include other types of networks
Diffstat (limited to 'extensions-builtin/Lora/lyco_helpers.py')
-rw-r--r-- | extensions-builtin/Lora/lyco_helpers.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/extensions-builtin/Lora/lyco_helpers.py b/extensions-builtin/Lora/lyco_helpers.py new file mode 100644 index 00000000..9ea499fb --- /dev/null +++ b/extensions-builtin/Lora/lyco_helpers.py @@ -0,0 +1,15 @@ +import torch
+
+
+def make_weight_cp(t, wa, wb):
+ temp = torch.einsum('i j k l, j r -> i r k l', t, wb)
+ return torch.einsum('i j k l, i r -> r j k l', temp, wa)
+
+
+def rebuild_conventional(up, down, shape, dyn_dim=None):
+ up = up.reshape(up.size(0), -1)
+ down = down.reshape(down.size(0), -1)
+ if dyn_dim is not None:
+ up = up[:, :dyn_dim]
+ down = down[:dyn_dim, :]
+ return (up @ down).reshape(shape)
|