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

Method forward

diffusers/src/diffusers/models/activations.py:113–123  ·  view source on GitHub ↗
(self, hidden_states, *args, **kwargs)

Source from the content-addressed store, hash-verified

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:
115 deprecation_message = "The `scale` argument is deprecated and will be ignored. Please remove it, as passing it will raise an error in the future. `scale` should directly be passed while calling the underlying pipeline component i.e., via `cross_attention_kwargs`."
116 deprecate("scale", "1.0.0", deprecation_message)
117 hidden_states = self.proj(hidden_states)
118 if is_torch_npu_available():
119 # using torch_npu.npu_geglu can run faster and save memory on NPU.
120 return torch_npu.npu_geglu(hidden_states, dim=-1, approximate=1)[0]
121 else:
122 hidden_states, gate = hidden_states.chunk(2, dim=-1)
123 return hidden_states * self.gelu(gate)
124
125
126class SwiGLU(nn.Module):

Callers

nothing calls this directly

Calls 3

geluMethod · 0.95
deprecateFunction · 0.85
is_torch_npu_availableFunction · 0.85

Tested by

no test coverage detected