(self, hidden_states, *args, **kwargs)
| 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 | |
| 126 | class SwiGLU(nn.Module): |
nothing calls this directly
no test coverage detected