Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
81c16c96
Commit
81c16c96
authored
Feb 07, 2024
by
v0xie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add butterfly_factor fn
parent
a4668a16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
extensions-builtin/Lora/lyco_helpers.py
extensions-builtin/Lora/lyco_helpers.py
+26
-0
No files found.
extensions-builtin/Lora/lyco_helpers.py
View file @
81c16c96
...
@@ -66,3 +66,29 @@ def factorization(dimension: int, factor:int=-1) -> tuple[int, int]:
...
@@ -66,3 +66,29 @@ def factorization(dimension: int, factor:int=-1) -> tuple[int, int]:
n
,
m
=
m
,
n
n
,
m
=
m
,
n
return
m
,
n
return
m
,
n
# from https://github.com/KohakuBlueleaf/LyCORIS/blob/dev/lycoris/modules/boft.py
def
butterfly_factor
(
dimension
:
int
,
factor
:
int
=
-
1
)
->
tuple
[
int
,
int
]:
"""
m = 2k
n = 2**p
m*n = dim
"""
# Find the first solution and check if it is even doable
m
=
n
=
0
while
m
<=
factor
:
m
+=
2
while
dimension
%
m
!=
0
and
m
<
dimension
:
m
+=
2
if
m
>
factor
:
break
if
sum
(
int
(
i
)
for
i
in
f
"{dimension//m:b}"
)
==
1
:
n
=
dimension
//
m
if
n
==
0
:
raise
ValueError
(
f
"It is impossible to decompose {dimension} with factor {factor} under BOFT constrains."
)
#log_butterfly_factorize(dimension, factor, (dimension // n, n))
return
dimension
//
n
,
n
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment