Instructions to use kernels-community/activation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use kernels-community/activation with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("kernels-community/activation", version=1) - Notebooks
- Google Colab
- Kaggle
File size: 1,558 Bytes
74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 3bf3198 74459d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | import torch
from ._ops import ops
from . import layers
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.silu_and_mul(out, x)
return out
def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.mul_and_silu(out, x)
return out
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_and_mul(out, x)
return out
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_tanh_and_mul(out, x)
return out
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> torch.Tensor:
ops.fatrelu_and_mul(out, x, threshold)
return out
def gelu(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu(out, x)
return out
def silu(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.silu(out, x)
return out
def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_tanh(out, x)
return out
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_fast(out, x)
return out
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_new(out, x)
return out
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
ops.gelu_quick(out, x)
return out
__all__ = [
"silu_and_mul",
"mul_and_silu",
"gelu_and_mul",
"gelu_tanh_and_mul",
"fatrelu_and_mul",
"gelu_fast",
"gelu_new",
"gelu_quick",
"gelu_tanh",
"silu",
"gelu",
"layers",
]
|