Path: blob/master/extensions-builtin/Lora/network_full.py
2447 views
import network123class ModuleTypeFull(network.ModuleType):4def create_module(self, net: network.Network, weights: network.NetworkWeights):5if all(x in weights.w for x in ["diff"]):6return NetworkModuleFull(net, weights)78return None91011class NetworkModuleFull(network.NetworkModule):12def __init__(self, net: network.Network, weights: network.NetworkWeights):13super().__init__(net, weights)1415self.weight = weights.w.get("diff")16self.ex_bias = weights.w.get("diff_b")1718def calc_updown(self, orig_weight):19output_shape = self.weight.shape20updown = self.weight.to(orig_weight.device)21if self.ex_bias is not None:22ex_bias = self.ex_bias.to(orig_weight.device)23else:24ex_bias = None2526return self.finalize_updown(updown, orig_weight, output_shape, ex_bias)272829