mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
Fix diffusers_sdxl on ipex
This commit is contained in:
+10
-3
@@ -175,8 +175,10 @@ else:
|
||||
backend = 'cpu'
|
||||
|
||||
if backend == 'ipex':
|
||||
#Fix broken function in ipex 1.13.120+xpu
|
||||
#Fix broken functions with ipex
|
||||
from modules.sd_hijack_utils import CondFunc
|
||||
torch.cuda.empty_cache = torch.xpu.empty_cache
|
||||
|
||||
#Functions with dtype errors:
|
||||
CondFunc('torch.nn.modules.GroupNorm.forward',
|
||||
lambda orig_func, *args, **kwargs: orig_func(args[0], args[1].to(args[0].weight.data.dtype)),
|
||||
@@ -184,6 +186,7 @@ if backend == 'ipex':
|
||||
CondFunc('torch.nn.modules.Linear.forward',
|
||||
lambda orig_func, *args, **kwargs: orig_func(args[0], args[1].to(args[0].weight.data.dtype)),
|
||||
lambda *args, **kwargs: args[2].dtype != args[1].weight.data.dtype)
|
||||
|
||||
#Functions that does not work with the XPU:
|
||||
#UniPC:
|
||||
CondFunc('torch.linalg.solve',
|
||||
@@ -191,8 +194,12 @@ if backend == 'ipex':
|
||||
lambda *args, **kwargs: args[1].device != torch.device("cpu"))
|
||||
#SDE Samplers:
|
||||
CondFunc('torch.Generator',
|
||||
lambda _, device: torch.xpu.Generator(device),
|
||||
lambda _, device: device != torch.device("cpu") and device != "cpu")
|
||||
lambda orig_func, device: torch.xpu.Generator(device),
|
||||
lambda orig_func, device: device != torch.device("cpu") and device != "cpu")
|
||||
#Diffusers Float64 (ARC GPUs doesn't support double or Float64):
|
||||
CondFunc('torch.from_numpy',
|
||||
lambda orig_func, *args, **kwargs: orig_func(args[0].astype('float32')),
|
||||
lambda *args, **kwargs: args[1].dtype == float)
|
||||
#ControlNet:
|
||||
CondFunc('torch.batch_norm',
|
||||
lambda orig_func, *args, **kwargs: orig_func(args[0].to("cpu"),
|
||||
|
||||
Reference in New Issue
Block a user