mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-19 14:40:04 +00:00
11 lines
366 B
Python
11 lines
366 B
Python
import torch
|
|
import comfy.model_management
|
|
|
|
RMSNorm = torch.nn.RMSNorm
|
|
|
|
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)
|
|
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)
|