MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / T5LayerNorm

Class T5LayerNorm

models/transformer/wan/modules/t5.py:53–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53class T5LayerNorm(nn.Module):
54
55 def __init__(self, dim, eps=1e-6):
56 super(T5LayerNorm, self).__init__()
57 self.dim = dim
58 self.eps = eps
59 self.weight = nn.Parameter(torch.ones(dim))
60
61 def forward(self, x):
62 x = x * torch.rsqrt(x.float().pow(2).mean(dim=-1, keepdim=True) +
63 self.eps)
64 if self.weight.dtype in [torch.float16, torch.bfloat16]:
65 x = x.type_as(self.weight)
66 return self.weight * x
67
68
69class T5Attention(nn.Module):

Callers 4

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected