Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
title: Kernels
- local: api/layers
title: Layers
- local: use_layers
title: Kernelize a model
title: Python API
- sections:
- local: cli
Expand Down
3 changes: 3 additions & 0 deletions docs/source/layers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Use layers

> [!NOTE]
> Open the [Kernelize your model with ease](https://colab.research.google.com/github/huggingface/kernels/blob/main/examples/cookbook/use_layers.ipynb) notebook to build a kernel, replace a layer definition, and use a kernel layer with functions.

A kernel can provide layers in addition to kernel functions. A layer from
the Hub can replace the `forward` method of an existing layer for a certain
device type. This makes it possible to provide more performant kernels for
Expand Down
10 changes: 6 additions & 4 deletions examples/cookbook/use_layers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"provenance": [],
"gpuType": "T4",
"toc_visible": true,
"authorship_tag": "ABX9TyNmkB5Sx3PN1y+UVcpXmx/I",
"authorship_tag": "ABX9TyN8VYZ9YmOM2c5WoK3qdTF4",
"include_colab_link": true
},
"kernelspec": {
Expand All @@ -26,7 +26,7 @@
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ariG23498/kernels/blob/aritra%2Fcookbook/examples/cookbook/use_layers.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
"<a href=\"https://colab.research.google.com/github/ariG23498/kernels/blob/cookbook-addition/examples/cookbook/use_layers.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
Expand Down Expand Up @@ -495,7 +495,7 @@
"def gelu(input):\n",
" return F.gelu(input)\n",
"\n",
"@use_kernelized_func(Gelu)\n",
"@use_kernelized_func(gelu)\n",
"class MLP(nn.Module):\n",
" def __init__(self, d_in=1024, d_hidden=4096, d_out=1024):\n",
" super().__init__()\n",
Expand Down Expand Up @@ -694,7 +694,9 @@
"\n",
"We hope this interactive cookbook gets you up to speed with how one would use kernels which are built and uploaded to the Hub. We hope to seeing more of you using kernels for your models and also your libraries.\n",
"\n",
"Kernels are really powerful and we want you to use them leaving all the tooling issues for us to tackle! Keep the hardware accelerators warm 🔥."
"Kernels are really powerful and we want you to use them leaving all the tooling issues for us to tackle! Keep the hardware accelerators warm 🔥.\n",
"\n",
"Special thanks to [Noe](https://huggingface.co/NoeFlandre) for reporting a bug (that is now fixed 😅)"
],
"metadata": {
"id": "4rnNhS_5FlR9"
Expand Down
Loading
Loading