Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ljleb/sd-mecha
Browse files Browse the repository at this point in the history
  • Loading branch information
ljleb committed Jun 18, 2024
2 parents fc67567 + b57d146 commit e05c186
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: ljleb
patreon: ljleb
7 changes: 5 additions & 2 deletions examples/custom_merge_method.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sd_mecha
import torch
from sd_mecha.extensions.merge_method import convert_to_recipe, LiftFlag, MergeSpace
from sd_mecha import Hyper
sd_mecha.set_log_level()


Expand Down Expand Up @@ -28,8 +29,10 @@ def custom_sum(
b: torch.Tensor | LiftFlag[MergeSpace.BASE],
*,
# hyperparameters go here
alpha: float = 0.5, # default arguments are honored
beta: float,
# `Hyper` is an union type of `float`, `int` and `dict` (the dict case is for a different weight per block MBW), which is what the caller of the method excpects.
# in practice the method only ever receives numeric types (int or float), so no need to worry about the dict case
alpha: Hyper = 0.5, # default arguments are honored
beta: Hyper,
# `@convert_to_recipe` introduces additional kwargs: `device=` and `dtype=`
# We must put `**kwargs` to satisfy the type system:
**kwargs,
Expand Down

0 comments on commit e05c186

Please sign in to comment.