aboutsummaryrefslogtreecommitdiff
path: root/extensions-builtin/Lora/lyco_helpers.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-07-17 09:00:47 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-07-17 09:00:47 +0300
commit238adeaffb037dedbcefe41e7fd4814a1f17baa2 (patch)
tree901557b4f4814effe18d23900317f7dbabf3e162 /extensions-builtin/Lora/lyco_helpers.py
parent46466f09d0b0c14118033dee6af0f876059776d3 (diff)
support specifying te and unet weights separately
update lora code support full module
Diffstat (limited to 'extensions-builtin/Lora/lyco_helpers.py')
-rw-r--r--extensions-builtin/Lora/lyco_helpers.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/extensions-builtin/Lora/lyco_helpers.py b/extensions-builtin/Lora/lyco_helpers.py
index 9ea499fb..279b34bc 100644
--- a/extensions-builtin/Lora/lyco_helpers.py
+++ b/extensions-builtin/Lora/lyco_helpers.py
@@ -13,3 +13,9 @@ def rebuild_conventional(up, down, shape, dyn_dim=None):
up = up[:, :dyn_dim]
down = down[:dyn_dim, :]
return (up @ down).reshape(shape)
+
+
+def rebuild_cp_decomposition(up, down, mid):
+ up = up.reshape(up.size(0), -1)
+ down = down.reshape(down.size(0), -1)
+ return torch.einsum('n m k l, i n, m j -> i j k l', mid, up, down)