This commit is contained in:
lllyasviel
2024-01-31 09:46:24 -08:00
parent 8a0dcd09c9
commit 071be046d2
15 changed files with 153 additions and 561 deletions

View File

@@ -2,23 +2,7 @@ import time
import torch
import contextlib
from ldm_patched.modules import model_management
@contextlib.contextmanager
def use_patched_ops(operations):
op_names = ['Linear', 'Conv2d', 'Conv3d', 'GroupNorm', 'LayerNorm']
backups = {op_name: getattr(torch.nn, op_name) for op_name in op_names}
try:
for op_name in op_names:
setattr(torch.nn, op_name, getattr(operations, op_name))
yield
finally:
for op_name in op_names:
setattr(torch.nn, op_name, backups[op_name])
return
from ldm_patched.modules.ops import use_patched_ops
@contextlib.contextmanager