Last active
April 1, 2025 15:35
-
-
Save drbh/46b4b59a78171b09cc0e79120e8b3ad7 to your computer and use it in GitHub Desktop.
README example from https://github.com/huggingface/kernels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# dependencies = [ | |
# "numpy", | |
# "torch", | |
# "kernels", | |
# ] | |
# /// | |
import torch | |
from kernels import get_kernel | |
# Download optimized kernels from the Hugging Face hub | |
activation = get_kernel("kernels-community/activation") | |
# Random tensor | |
x = torch.randn((10, 10), dtype=torch.float16, device="cuda") | |
# Run the kernel | |
y = torch.empty_like(x) | |
activation.gelu_fast(y, x) | |
print(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment