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

Method gelu

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

Source from the content-addressed store, hash-verified

79 self.approximate = approximate
80
81 def gelu(self, gate: torch.Tensor) -> torch.Tensor:
82 if gate.device.type != "mps":
83 return F.gelu(gate, approximate=self.approximate)
84 # mps: gelu is not implemented for float16
85 return F.gelu(gate.to(dtype=torch.float32), approximate=self.approximate).to(dtype=gate.dtype)
86
87 def forward(self, hidden_states):
88 hidden_states = self.proj(hidden_states)

Callers 4

forwardMethod · 0.95
__call__Method · 0.45
geluMethod · 0.45
forwardMethod · 0.45

Calls 1

toMethod · 0.45

Tested by

no test coverage detected