2024-09-12 09:23:32 +00:00
|
|
|
import torch
|
|
|
|
|
|
|
|
class TorchCompileModel:
|
|
|
|
@classmethod
|
|
|
|
def INPUT_TYPES(s):
|
|
|
|
return {"required": { "model": ("MODEL",),
|
2024-09-27 06:12:37 +00:00
|
|
|
"backend": (["inductor", "cudagraphs"],),
|
2024-09-12 09:23:32 +00:00
|
|
|
}}
|
|
|
|
RETURN_TYPES = ("MODEL",)
|
|
|
|
FUNCTION = "patch"
|
|
|
|
|
|
|
|
CATEGORY = "_for_testing"
|
|
|
|
EXPERIMENTAL = True
|
|
|
|
|
2024-09-27 06:12:37 +00:00
|
|
|
def patch(self, model, backend):
|
2024-09-12 09:23:32 +00:00
|
|
|
m = model.clone()
|
2024-09-27 06:12:37 +00:00
|
|
|
m.add_object_patch("diffusion_model", torch.compile(model=m.get_model_object("diffusion_model"), backend=backend))
|
2024-09-12 09:23:32 +00:00
|
|
|
return (m, )
|
|
|
|
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
|
|
"TorchCompileModel": TorchCompileModel,
|
|
|
|
}
|