Return the corresponding activation function.
(self)
| 24 | ) |
| 25 | |
| 26 | def get_function(self): |
| 27 | """Return the corresponding activation function.""" |
| 28 | if self == ActFn.SILU: |
| 29 | return F.silu |
| 30 | elif self == ActFn.GELU: |
| 31 | return F.gelu |
| 32 | elif self == ActFn.GELU_APPROX: |
| 33 | return partial(F.gelu, approximate="tanh") |
| 34 | else: |
| 35 | raise ValueError(f"Unsupported activation function: {self}") |
| 36 | |
| 37 | |
| 38 | @dataclass |