MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / gelu

Method gelu

diffusers/src/diffusers/models/activations.py:107–111  ·  view source on GitHub ↗
(self, gate: torch.Tensor)

Source from the content-addressed store, hash-verified

105 self.proj = nn.Linear(dim_in, dim_out * 2, bias=bias)
106
107 def gelu(self, gate: torch.Tensor) -> torch.Tensor:
108 if gate.device.type != "mps":
109 return F.gelu(gate)
110 # mps: gelu is not implemented for float16
111 return F.gelu(gate.to(dtype=torch.float32)).to(dtype=gate.dtype)
112
113 def forward(self, hidden_states, *args, **kwargs):
114 if len(args) > 0 or kwargs.get("scale", None) is not None:

Callers 1

forwardMethod · 0.95

Calls 2

geluMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected