mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-28 18:21:48 +00:00
revise GGUF by precomputing some parameters
rather than computing them in each diffusion iteration
This commit is contained in:
@@ -405,12 +405,24 @@ class ForgeOperationsGGUF(ForgeOperations):
|
||||
self.weight = state_dict[prefix + 'weight']
|
||||
if prefix + 'bias' in state_dict:
|
||||
self.bias = state_dict[prefix + 'bias']
|
||||
if self.weight is not None and hasattr(self.weight, 'parent'):
|
||||
self.weight.parent = self
|
||||
if self.bias is not None and hasattr(self.bias, 'parent'):
|
||||
self.bias.parent = self
|
||||
return
|
||||
|
||||
def _apply(self, fn, recurse=True):
|
||||
if self.weight is not None:
|
||||
self.weight = utils.tensor2parameter(fn(self.weight))
|
||||
if self.bias is not None:
|
||||
self.bias = utils.tensor2parameter(fn(self.bias))
|
||||
for i in range(5):
|
||||
quant_state_name = f'quant_state_{i}'
|
||||
quant_state = getattr(self, quant_state_name, None)
|
||||
if quant_state is not None:
|
||||
quant_state = fn(quant_state)
|
||||
quant_state = utils.tensor2parameter(quant_state)
|
||||
setattr(self, quant_state_name, quant_state)
|
||||
return self
|
||||
|
||||
def forward(self, x):
|
||||
|
||||
Reference in New Issue
Block a user