2023-07-17 00:00:47 -06:00
|
|
|
import network
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleTypeFull(network.ModuleType):
|
|
|
|
def create_module(self, net: network.Network, weights: network.NetworkWeights):
|
|
|
|
if all(x in weights.w for x in ["diff"]):
|
|
|
|
return NetworkModuleFull(net, weights)
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkModuleFull(network.NetworkModule):
|
|
|
|
def __init__(self, net: network.Network, weights: network.NetworkWeights):
|
|
|
|
super().__init__(net, weights)
|
|
|
|
|
|
|
|
self.weight = weights.w.get("diff")
|
2023-08-15 09:41:46 -06:00
|
|
|
self.ex_bias = weights.w.get("diff_b")
|
2023-07-17 00:00:47 -06:00
|
|
|
|
|
|
|
def calc_updown(self, orig_weight):
|
|
|
|
output_shape = self.weight.shape
|
2023-10-18 23:56:17 -06:00
|
|
|
updown = self.weight.to(orig_weight.device)
|
2023-08-15 09:41:46 -06:00
|
|
|
if self.ex_bias is not None:
|
2023-10-18 23:56:17 -06:00
|
|
|
ex_bias = self.ex_bias.to(orig_weight.device)
|
2023-08-15 09:41:46 -06:00
|
|
|
else:
|
|
|
|
ex_bias = None
|
2023-07-17 00:00:47 -06:00
|
|
|
|
2023-08-15 09:41:46 -06:00
|
|
|
return self.finalize_updown(updown, orig_weight, output_shape, ex_bias)
|