MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / T5LayerNorm

Class T5LayerNorm

examples/diffusion/python_stable_diffusion_3/other_impls.py:330–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328
329
330class T5LayerNorm(torch.nn.Module):
331 def __init__(self, hidden_size, eps=1e-6, dtype=None, device=None):
332 super().__init__()
333 self.weight = torch.nn.Parameter(torch.ones(hidden_size, dtype=dtype, device=device))
334 self.variance_epsilon = eps
335
336 def forward(self, x):
337 variance = x.pow(2).mean(-1, keepdim=True)
338 x = x * torch.rsqrt(variance + self.variance_epsilon)
339 return self.weight.to(device=x.device, dtype=x.dtype) * x
340
341
342class T5DenseGatedActDense(torch.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