Update cfz_cudnn.toggle.py

This commit is contained in:
patientx 2025-06-06 17:59:03 +03:00 committed by GitHub
parent d28b4525b3
commit 8beae68f3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,36 +1,48 @@
import torch import torch
class AutoCUDNNToggle: class CUDNNToggleAutoPassthrough:
@classmethod @classmethod
def INPUT_TYPES(cls): def INPUT_TYPES(cls):
return { return {
"optional": {
"model": ("MODEL",),
"conditioning": ("CONDITIONING",),
"latent": ("LATENT",),
"audio": ("AUDIO",),
"image": ("IMAGE",),
},
"required": { "required": {
"enable_cudnn": ("BOOLEAN", {"default": True}), "enable_cudnn": ("BOOLEAN", {"default": True}),
}, },
"optional": {
"latent": ("LATENT",),
"audio": ("AUDIO",),
}
} }
RETURN_TYPES = ("LATENT", "AUDIO") RETURN_TYPES = ("MODEL", "CONDITIONING", "LATENT", "AUDIO", "IMAGE")
RETURN_NAMES = ("latent_out", "audio_out") RETURN_NAMES = ("model", "conditioning", "latent", "audio", "image")
FUNCTION = "toggle" FUNCTION = "toggle"
CATEGORY = "advanced/utils" CATEGORY = "utils"
def toggle(self, enable_cudnn, latent=None, audio=None): def toggle(self, enable_cudnn, model=None, conditioning=None, latent=None, audio=None, image=None):
# Set CuDNN state
torch.backends.cudnn.enabled = enable_cudnn torch.backends.cudnn.enabled = enable_cudnn
print(f"[CUDNN_TOGGLE] torch.backends.cudnn.enabled set to {enable_cudnn}")
# Auto-detect active path return_tuple = (None, None, None, None, None)
if latent is not None: if model is not None:
print(f"[CuDNN] Latent mode | Enabled: {enable_cudnn}") return_tuple = (model, None, None, None, None)
return (latent, None) elif conditioning is not None:
return_tuple = (None, conditioning, None, None, None)
elif latent is not None:
return_tuple = (None, None, latent, None, None)
elif audio is not None: elif audio is not None:
print(f"[CuDNN] Audio mode | Enabled: {enable_cudnn}") return_tuple = (None, None, None, audio, None)
return (None, audio) elif image is not None:
else: return_tuple = (None, None, None, None, image)
raise ValueError("No valid input connected - must connect either latent OR audio")
NODE_CLASS_MAPPINGS = {"CFZ-CUDNNToggle": AutoCUDNNToggle} return return_tuple
NODE_DISPLAY_NAME_MAPPINGS = {"CFZ-CUDNNToggle": "CFZ CuDNN Toggle"}
NODE_CLASS_MAPPINGS = {
"CUDNNToggleAutoPassthrough": CUDNNToggleAutoPassthrough
}
NODE_DISPLAY_NAME_MAPPINGS = {
"CUDNNToggleAutoPassthrough": "CFZ CUDNN Toggle"
}