MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / T5LayerNorm

Class T5LayerNorm

wan/models/wan_text_encoder.py:44–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44class T5LayerNorm(nn.Module):
45 def __init__(self, dim, eps=1e-6):
46 super(T5LayerNorm, self).__init__()
47 self.dim = dim
48 self.eps = eps
49 self.weight = nn.Parameter(torch.ones(dim))
50
51 def forward(self, x):
52 x = x * torch.rsqrt(x.float().pow(2).mean(dim=-1, keepdim=True) +
53 self.eps)
54 if self.weight.dtype in [torch.float16, torch.bfloat16]:
55 x = x.type_as(self.weight)
56 return self.weight * x
57
58
59class T5Attention(nn.Module):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected