Helper function to get activation function from string. Args: act_fn (str): Name of activation function. Returns: nn.Module: Activation function.
(act_fn: str)
| 34 | |
| 35 | |
| 36 | def get_activation(act_fn: str) -> nn.Module: |
| 37 | """Helper function to get activation function from string. |
| 38 | |
| 39 | Args: |
| 40 | act_fn (str): Name of activation function. |
| 41 | |
| 42 | Returns: |
| 43 | nn.Module: Activation function. |
| 44 | """ |
| 45 | |
| 46 | act_fn = act_fn.lower() |
| 47 | if act_fn in ACT2CLS: |
| 48 | return ACT2CLS[act_fn]() |
| 49 | else: |
| 50 | raise ValueError(f"activation function {act_fn} not found in ACT2FN mapping {list(ACT2CLS.keys())}") |
| 51 | |
| 52 | |
| 53 | class FP32SiLU(nn.Module): |
no outgoing calls
searching dependent graphs…