Instructions to use kernels-community/relu with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use kernels-community/relu with Kernels:
# !pip install kernels from kernels import get_kernel kernel = get_kernel("kernels-community/relu") - Notebooks
- Google Colab
- Kaggle
| import torch | |
| import torch.nn.functional as F | |
| from kernels.benchmark import Benchmark | |
| class ReluBenchmark(Benchmark): | |
| seed: int = 42 | |
| def setup(self): | |
| self.x = torch.randn(1024, 1024, device=self.device, dtype=torch.float32) | |
| self.out = torch.empty_like(self.x) | |
| def benchmark_base(self): | |
| self.out = self.kernel.relu(self.x) | |
| def verify_base(self) -> torch.Tensor: | |
| return F.relu(self.x) | |
| def setup_large(self): | |
| self.x = torch.randn(4096, 4096, device=self.device, dtype=torch.float32) | |
| self.out = torch.empty_like(self.x) | |
| def benchmark_large(self): | |
| self.out = self.kernel.relu(self.x) | |
| def verify_large(self) -> torch.Tensor: | |
| return F.relu(self.x) | |