(self, gate: torch.Tensor)
| 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) |