Files
ComfyUI/comfy/rmsnorm.py

11 lines
366 B
Python
Raw Normal View History

2025-04-14 18:00:33 -04:00
import torch
import comfy.model_management
RMSNorm = torch.nn.RMSNorm
2025-04-14 18:00:33 -04:00
def rms_norm(x, weight=None, eps=1e-6):
if weight is None:
return torch.nn.functional.rms_norm(x, (x.shape[-1],), eps=eps)
2025-04-14 18:00:33 -04:00
else:
return torch.nn.functional.rms_norm(x, weight.shape, weight=comfy.model_management.cast_to(weight, dtype=x.dtype, device=x.device), eps=eps)