MCPcopy Create free account
hub / github.com/Monalissaa/DisenDiff / LayerNorm

Class LayerNorm

clip/model.py:153–159  ·  view source on GitHub ↗

Subclass torch's LayerNorm to handle fp16.

Source from the content-addressed store, hash-verified

151
152
153class LayerNorm(nn.LayerNorm):
154 """Subclass torch's LayerNorm to handle fp16."""
155
156 def forward(self, x: torch.Tensor):
157 orig_type = x.dtype
158 ret = super().forward(x.type(torch.float32))
159 return ret.type(orig_type)
160
161
162class QuickGELU(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