import{s as _n,n as Nn,o as Vn}from"../chunks/scheduler.f3b1e791.js";import{S as Zn,i as Rn,e as a,s as i,c as p,h as Bn,a as o,d as l,b as s,f as Hn,g as d,j as r,k as Ln,l as En,m as n,n as c,t as m,o as u,p as h}from"../chunks/index.023a9934.js";import{C as Qn}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{C as T}from"../chunks/CodeBlock.5aa52fca.js";import{H as f,E as Wn}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function An(_l){let y,ze,Fe,Ke,M,et,b,tt,k,lt,$,Nl=`The Kernel Hub allows Python libraries and applications to load compute
kernels directly from the <a href="https://hf.co/" rel="nofollow">Hub</a>. To support this kind
of dynamic loading, Hub kernels differ from traditional Python kernel
packages in that they are made to be:`,nt,g,Vl=`<li>Portable: a kernel can be loaded from paths outside <code>PYTHONPATH</code>.</li> <li>Unique: multiple versions of the same kernel can be loaded in the
same Python process.</li> <li>Compatible: kernels must support all recent versions of Python and
the different PyTorch build configurations (various CUDA versions
and C++ ABIs). Furthermore, older C library versions must be supported.</li>`,it,w,Zl=`<code>kernel-builder</code> is a set of tools that can build conforming kernels. It
takes care of:`,st,U,Rl=`<li>Building kernels for all supported PyTorch configurations (C++98/11 and
different CUDA versions).</li> <li>Compatibility with old glibc and libstdc++ versions, so that kernels also
work on older Linux distributions.</li> <li>Registering Torch ops, such that multiple versions the same kernel can be
loaded without namespace conflicts.</li>`,at,J,Bl=`<code>kernel-builder</code> builds are configured through a <code>build.toml</code> file.
<code>build.toml</code> is a simple format that does not require intricate knowledge
of CMake or setuptools.`,ot,C,El=`This page describes the directory layout of a kernel-builder project, the
format of the <code>build.toml</code> file, and some additional Python glue that
<code>kernel-builder</code> provides. We will use a <a href="https://github.com/huggingface/kernels/tree/main/examples/kernels/relu" rel="nofollow">simple ReLU kernel</a>
as the running example. After reading this page, you may also want to have
a look at the more realistic <a href="https://github.com/huggingface/kernels/tree/main/examples/kernels/relu-backprop-compile" rel="nofollow">ReLU kernel with backprop and <code>torch.compile</code></a>
support.`,rt,v,pt,j,dt,x,Ql=`The fastest way to get started is to run the install script. This
installs <a href="https://docs.determinate.systems/determinate-nix/" rel="nofollow">Determinate Nix</a>
and <code>kernel-builder</code> in a single command:`,ct,I,mt,H,Wl="This will:",ut,L,Al=`<li>Install Determinate Nix (if not already installed).</li> <li>Configure the Hugging Face binary cache (to avoid building dependencies from
source).</li> <li>Install <code>kernel-builder</code> via <code>nix profile install</code>.</li>`,ht,_,Sl="To update <code>kernel-builder</code> later:",ft,N,Tt,V,Pl=`For a step-by-step breakdown of what the script does, see
<a href="nix">Using the kernel builder with Nix</a>.`,yt,Z,Mt,R,Gl=`In the <a href="https://github.com/huggingface/kernels/tree/main/terraform" rel="nofollow"><code>terraform</code></a> directory, we provide an
example of programatically spinning up an EC2 instance that is ready
with everything needed for you to start developing and building
kernels.`,bt,B,ql=`If you use a different provider, the Terraform bridges should be
similar and straightforward to modify.`,kt,E,$t,Q,Xl=`The easiest way to start a new kernel is by using the <code>init</code> subcommand
of <code>kernel-builder</code>. This creates a minimal, compilable kernel:`,gt,W,wt,A,Ol=`This creates a kernel named <code>mykernel</code> in the directory <code>mykernel</code>. The
kernel is configured to upload to the <code>myorg/mykernel</code> Hub
repository when an upload command is used.`,Ut,S,Yl=`By default, the <code>init</code> subcommand creates a CUDA kernel. You can specify
another backend with the <code>--backends</code> option:`,Jt,P,Ct,G,Fl=`You can also make a multi-backend kernel by adding all the backends
that you would like to support as arguments to <code>--backends</code>:`,vt,q,jt,X,Dl=`Finally, if you want to create a kernel for all supported backends, you
can use <code>--backends all</code>.`,xt,O,It,Y,zl="Kernel projects follow this general directory layout:",Ht,F,Lt,D,Kl="In this example we can find:",_t,z,en=`<li>The build configuration in <code>build.toml</code>.</li> <li>One or more top-level directories containing kernels (<code>mykernel_cuda</code>).</li> <li>The <code>torch-ext</code> directory, which contains:
<ul><li><code>torch_binding.h</code>: contains declarations for kernel entry points
(from <code>kernel_a</code> and <code>kernel_b</code>).</li> <li><code>torch_binding.cpp</code>: registers the entry points as Torch ops.</li> <li><code>torch_ext/mykernel</code>: contains any Python wrapping the kernel needs. At the
bare minimum, it should contain an <code>__init__.py</code> file.</li></ul></li> <li>Kernel tests in the directory <code>tests</code>.</li> <li>Benchmarks in the directory <code>benchmarks</code>.</li> <li>A kernel card template in <code>CARD.md</code>. This placeholders in the card are filled
during the kernel build.</li> <li>The Nix flake configuration in <code>flake.nix</code>.</li> <li>An example script that uses the kernel in <code>example.py</code>.</li>`,Nt,K,Vt,ee,tn=`<code>build.toml</code> tells <code>kernel-builder</code> what to build and how. It looks as
follows for the <code>mykernel</code> kernel:`,Zt,te,Rt,le,ln="The following sections enumerate all supported options for <code>build.toml</code>.",Bt,ne,Et,ie,nn=`<li><code>name</code> (required): the name of the kernel. The Python code for a Torch
extension must be stored in <code>torch-ext/&lt;name&gt;</code>.</li> <li><code>version</code> (int): the major version of the kernel.
The version is written to the kernel’s <code>metadata.json</code> and is used
by the <code>kernels upload</code> command to upload the kernel to a version
branch named <code>v&lt;version&gt;</code>.</li> <li><code>backends</code> (required): a list of supported backends. Must be one or
more of <code>cpu</code>, <code>cuda</code>, <code>metal</code>, <code>rocm</code>, or <code>xpu</code>.</li> <li><code>python-depends</code> (<strong>experimental</strong>): a list of additional Python dependencies
that the kernel requires. The only supported dependencies are <code>einops</code>
and <code>nvidia-cutlass-dsl</code>.</li>`,Qt,se,Wt,ae,sn=`<li><code>repo-id</code>: the Hub repository to upload the kernel to when the <code>upload</code> or
<code>build-and-upload</code> subcommands of <code>kernel-builder</code> are used.</li>`,At,oe,St,re,an=`<li><code>maxver</code>: the maximum CUDA toolkit version (inclusive). This option
<em>must not</em> be set under normal circumstances, since it can exclude Torch
build variants that are <a href="../kernel-requirements">required for compliant kernels</a>.
This option is provided for kernels that cause compiler errors on
newer CUDA toolkit versions.</li> <li><code>minver</code>: the minimum required CUDA toolkit version. This option
<em>must not</em> be set under normal circumstances, since it can exclude Torch
build variants that are <a href="../kernel-requirements">required for compliant kernels</a>.
This option is provided for kernels that require functionality only
provided by newer CUDA toolkits.</li>`,Pt,pe,Gt,de,on=`This section describes the Torch extension. In the future, there may be
similar sections for other frameworks. This section has the following
options:`,qt,ce,rn=`<li><code>src</code> (required): a list of source files and headers.</li> <li><code>pyext</code> (optional): the list of extensions for Python files. Default:
<code>[&quot;py&quot;, &quot;pyi&quot;]</code>.</li> <li><code>include</code> (optional): include directories relative to the project root.
Default: <code>[]</code>.</li> <li><code>maxver</code> (optional): only build for this Torch version and earlier. Use cautiously, since this option produces
non-compliant kernels if the version range does not correspond to the <a href="build-variants">required variants</a>.</li> <li><code>minver</code> (optional): only build for this Torch version and later. Use cautiously, since this option produces
non-compliant kernels if the version range does not correspond to the <a href="build-variants">required variants</a>.</li>`,Xt,me,Ot,ue,pn=`Specification of a kernel with the name <code>&lt;name&gt;</code>. Multiple <code>kernel.&lt;name&gt;</code>
sections can be defined in the same <code>build.toml</code>.
See for example <a href="https://huggingface.co/kernels-community/quantization/" rel="nofollow"><code>kernels-community/quantization</code></a>
for an example with multiple kernel sections.`,Yt,he,dn="The following options can be set for a kernel:",Ft,fe,cn=`<li><code>backend</code> (required): the compute backend of the kernel. The currently
supported backends are <code>cpu</code>, <code>cuda</code>, <code>metal</code>, <code>rocm</code>, and <code>xpu</code>.
<strong>The <code>cpu</code> backend is currently experimental and might still change.</strong></li> <li><code>depends</code> (required): a list of dependencies. The supported dependencies
are listed in <a href="https://github.com/huggingface/kernels/blob/main/builder/lib/deps.nix" rel="nofollow"><code>deps.nix</code></a>.</li> <li><code>src</code> (required): a list of source files and headers.</li> <li><code>include</code> (optional): include directories relative to the project root.
Default: <code>[]</code>.</li>`,Dt,Te,mn=`Besides these shared options, the following backend-specific options
are available:`,zt,ye,Kt,Me,un=`<li><code>cuda-capabilities</code> (optional): a list of CUDA capabilities that the
kernel should be compiled for. When absent, the kernel will be built
using all capabilities that the builder supports. The effective
capabilities are the intersection of this list and the capabilities
supported by the CUDA compiler. It is recommended to leave this option
unspecified <strong>unless</strong> a kernel requires specific capabilities.</li> <li><code>cuda_flags</code> (optional): additional flags to be passed to <code>nvcc</code>.
<strong>Warning</strong>: this option should only be used in exceptional circumstances.
Custom compile flags can interfere with the build process or break
compatibility requirements.</li>`,el,be,tl,ke,hn=`<li><code>rocm-archs</code>: a list of ROCm architectures that the kernel should be
compiled for.</li>`,ll,$e,nl,ge,fn=`<li><code>sycl_flags</code>: a list of additional flags to be passed to the SYCL
compiler.</li>`,il,we,sl,Ue,al,Je,Tn="Torch bindings are defined in C++, kernels commonly use two files:",ol,Ce,yn="<li><code>torch_binding.h</code> containing function declarations.</li> <li><code>torch_binding.cpp</code> registering the functions as Torch ops.</li>",rl,ve,Mn=`For instance, the <code>mykernel</code> kernel discussed above has the following
declaration in <code>torch_binding.h</code>:`,pl,je,dl,xe,bn="This function is then registered as a Torch op in <code>torch_binding.cpp</code>:",cl,Ie,ml,He,kn=`This snippet uses macros from <code>registration.h</code> to register the function.
<code>registration.h</code> is generated by <code>kernel-builder</code> itself. A function
is registered through the <code>def</code>/<code>ops</code> methods. <code>ops</code> specifies the
function signature following the <a href="https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/README.md#func" rel="nofollow">function schema</a>.
<code>impl</code> associates the function name with the C/C++ function and
the applicable device.`,ul,Le,hl,_e,$n=`The bindings are typically wrapped in Python code in <code>torch_ext/&lt;name&gt;</code>.
The native code is exposed under the <code>torch.ops</code> namespace. However,
we add some unique material to the name of the extension to ensure that
different versions of the same extension can be loaded at the same time.
As a result, the extension is registered as
<code>torch.ops.&lt;name&gt;_&lt;unique_material&gt;</code>.`,fl,Ne,gn=`To deal with this uniqueness, <code>kernel_builder</code> generates a Python module
named <code>_ops</code> that contains an alias for the name. This can be used to
refer to the correct <code>torch.ops</code> module. For example:`,Tl,Ve,yl,Ze,Ml,Re,wn=`Kernel tests are stored in the <code>tests</code> directory. Since running all
kernel tests in CI may be prohibitively expensive, the <code>pyproject.toml</code>
generated by the builder adds support for the special <code>kernels_ci</code>
PyTest marker that can be used as follows:`,bl,Be,kl,Ee,Un=`We recommend that you to pick tests that together would catch most error
cases while running within 60 seconds.`,$l,Qe,Jn="You can run the tests (e.g. in CI) using:",gl,We,wl,Ae,Cn=`If the kernel supports multiple backends, it will run the test for the
first supported backend that was found, obeying the following order: CUDA,
ROCm, XPU, Metal, CPU. If you would like to the tests for a specific build
variant, you can use <code>nix run .#ciTests.&lt;variant&gt;</code>. For instance:`,Ul,Se,Jl,Pe,vn=`When running the tests on a non-NixOS systems, make sure that
<a href="https://danieldk.eu/Software/Nix/Nix-CUDA-on-non-NixOS-systems#solutions" rel="nofollow">the CUDA driver library can be found</a>.`,Cl,Ge,vl,qe,jn=`We provide a utility to generate a system card for a given kernel, utilizing
information from its <code>build.toml</code> and metadata. This system card provides a
reasonable starting point and is meant to be edited afterward by the kernel
developer.`,jl,Xe,xn=`The template card is generated as a part of <code>kernel-builder init</code>
command and is serialized in the root directory of the kernel.`,xl,Oe,In=`The card will be filled automatically by the builder when using the
<code>build-and-upload</code> or <code>build-and-copy</code> command. It will be serialized
to the <code>build</code> sub-directory inside the main kernel directory. It
will be uploaded as <code>README.md</code> to the Hub.`,Il,Ye,Hl,De,Ll;return M=new Qn({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new f({props:{title:"Writing Hub kernels with kernel-builder",local:"writing-hub-kernels-with-kernel-builder",headingTag:"h1"}}),k=new f({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),v=new f({props:{title:"Setting up environment",local:"setting-up-environment",headingTag:"h2"}}),j=new f({props:{title:"Quick install",local:"quick-install",headingTag:"h3"}}),I=new T({props:{code:"Y3VybCUyMC1mc1NMJTIwaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGaHVnZ2luZ2ZhY2UlMkZrZXJuZWxzJTJGbWFpbiUyRmluc3RhbGwuc2glMjAlN0MlMjBiYXNo",highlighted:"curl -fsSL https://raw.githubusercontent.com/huggingface/kernels/main/install.sh | bash",wrap:!1}}),N=new T({props:{code:"bml4JTIwcHJvZmlsZSUyMHVwZ3JhZGUlMjAtLWFsbA==",highlighted:"nix profile upgrade --all",wrap:!1}}),Z=new f({props:{title:"Cloud environment",local:"cloud-environment",headingTag:"h3"}}),E=new f({props:{title:"Starting a new kernel",local:"starting-a-new-kernel",headingTag:"h2"}}),W=new T({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBpbml0JTIwLS1uYW1lJTIwbXlvcmclMkZteWtlcm5lbCUwQUluaXRpYWxpemVkJTIwJTYwbXlvcmclMkZteWtlcm5lbCU2MCUyMGF0JTIwJTJGaG9tZSUyRmRhbmllbCUyRmdpdCUyRmtlcm5lbHMlMkZleGFtcGxlcyUyRmtlcm5lbHMlMkZteWtlcm5lbA==",highlighted:"$ kernel-builder init --name myorg/mykernel\nInitialized `myorg/mykernel` at /home/daniel/git/kernels/examples/kernels/mykernel",wrap:!1}}),P=new T({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBpbml0JTIwLS1uYW1lJTIwbXlvcmclMkZteWtlcm5lbCUyMC0tYmFja2VuZHMlMjB4cHU=",highlighted:"$ kernel-builder init --name myorg/mykernel --backends xpu",wrap:!1}}),q=new T({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBpbml0JTIwLS1uYW1lJTIwbXlvcmclMkZteWtlcm5lbCUyMC0tYmFja2VuZHMlMjBjdWRhJTIweHB1JTBBSW5pdGlhbGl6ZWQlMjAlNjBteW9yZyUyRm15a2VybmVsJTYwJTIwYXQlMjAlMkZob21lJTJGZGFuaWVsJTJGZ2l0JTJGa2VybmVscyUyRmV4YW1wbGVzJTJGa2VybmVscyUyRm15a2VybmVs",highlighted:"$ kernel-builder init --name myorg/mykernel --backends cuda xpu\nInitialized `myorg/mykernel` at /home/daniel/git/kernels/examples/kernels/mykernel",wrap:!1}}),O=new f({props:{title:"Kernel project layout",local:"kernel-project-layout",headingTag:"h2"}}),F=new T({props:{code:"bXlrZXJuZWwlMEElRTIlOTQlOUMlRTIlOTQlODAlRTIlOTQlODAlMjBiZW5jaG1hcmtzJTBBJUUyJTk0JTgyJTIwJTIwJTIwJUUyJTk0JTk0JUUyJTk0JTgwJUUyJTk0JTgwJTIwYmVuY2htYXJrLnB5JTBBJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwYnVpbGQudG9tbCUwQSVFMiU5NCU5QyVFMiU5NCU4MCVFMiU5NCU4MCUyMENBUkQubWQlMEElRTIlOTQlOUMlRTIlOTQlODAlRTIlOTQlODAlMjBleGFtcGxlLnB5JTBBJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwZmxha2Uubml4JTBBJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwbXlrZXJuZWxfY3VkYSUwQSVFMiU5NCU4MiUyMCUyMCUyMCVFMiU5NCU5NCVFMiU5NCU4MCVFMiU5NCU4MCUyMG15a2VybmVsLmN1JTBBJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwdGVzdHMlMEElRTIlOTQlODIlMjAlMjAlMjAlRTIlOTQlOUMlRTIlOTQlODAlRTIlOTQlODAlMjBfX2luaXRfXy5weSUwQSVFMiU5NCU4MiUyMCUyMCUyMCVFMiU5NCU5NCVFMiU5NCU4MCVFMiU5NCU4MCUyMHRlc3RfbXlrZXJuZWwucHklMEElRTIlOTQlOTQlRTIlOTQlODAlRTIlOTQlODAlMjB0b3JjaC1leHQlMEElRTIlOTQlOUMlRTIlOTQlODAlRTIlOTQlODAlMjBteWtlcm5lbCUwQSVFMiU5NCU4MiUyMCUyMCUyMCVFMiU5NCU5NCVFMiU5NCU4MCVFMiU5NCU4MCUyMF9faW5pdF9fLnB5JTBBJUUyJTk0JTlDJUUyJTk0JTgwJUUyJTk0JTgwJTIwdG9yY2hfYmluZGluZy5jcHAlMEElRTIlOTQlOTQlRTIlOTQlODAlRTIlOTQlODAlMjB0b3JjaF9iaW5kaW5nLmg=",highlighted:`mykernel
├── benchmarks
│   └── benchmark.py
├── build.toml
├── CARD.md
├── example.py
├── flake.nix
├── mykernel_cuda
│   └── mykernel.cu
├── tests
│   ├── __init__.py
│   └── test_mykernel.py
└── torch-ext
├── mykernel
│   └── __init__.py
├── torch_binding.cpp
└── torch_binding.h`,wrap:!1}}),K=new f({props:{title:"build.toml",local:"buildtoml",headingTag:"h2"}}),te=new T({props:{code:"JTVCZ2VuZXJhbCU1RCUwQWJhY2tlbmRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIyY3VkYSUyMiUyQyUwQSU1RCUwQW5hbWUlMjAlM0QlMjAlMjJteWtlcm5lbCUyMiUwQXZlcnNpb24lMjAlM0QlMjAxJTBBJTBBJTVCZ2VuZXJhbC5odWIlNUQlMEFyZXBvLWlkJTIwJTNEJTIwJTIybXlvcmclMkZteWtlcm5lbCUyMiUwQSUwQSU1QnRvcmNoJTVEJTBBc3JjJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIydG9yY2gtZXh0JTJGdG9yY2hfYmluZGluZy5jcHAlMjIlMkMlMEElMjAlMjAlMjJ0b3JjaC1leHQlMkZ0b3JjaF9iaW5kaW5nLmglMjIlMkMlMEElNUQlMEElMEElNUJrZXJuZWwubXlrZXJuZWwlNUQlMEFiYWNrZW5kJTIwJTNEJTIwJTIyY3VkYSUyMiUwQWRlcGVuZHMlMjAlM0QlMjAlNUIlMjJ0b3JjaCUyMiU1RCUwQXNyYyUyMCUzRCUyMCU1QiUyMm15a2VybmVsX2N1ZGElMkZteWtlcm5lbC5jdSUyMiU1RCUwQSUyMyUyMElmJTIwdGhlJTIwa2VybmVsJTIwaXMlMjBvbmx5JTIwc3VwcG9ydGVkJTIwb24lMjBzcGVjaWZpYyUyMGNhcGFiaWxpdGllcyUyQyUyMHNldCUyMHRoZSUwQSUyMyUyMGN1ZGEtY2FwYWJpbGl0aWVzJTIwb3B0aW9uJTNBJTBBJTIzJTBBJTIzJTIwY3VkYS1jYXBhYmlsaXRpZXMlMjAlM0QlMjAlNUIlMjAlMjI5LjAlMjIlMkMlMjAlMjIxMC4wJTIyJTJDJTIwJTIyMTIuMCUyMiUyMCU1RA==",highlighted:`<span class="hljs-section">[general]</span>
<span class="hljs-attr">backends</span> = [
  <span class="hljs-string">&quot;cuda&quot;</span>,
]
<span class="hljs-attr">name</span> = <span class="hljs-string">&quot;mykernel&quot;</span>
<span class="hljs-attr">version</span> = <span class="hljs-number">1</span>

<span class="hljs-section">[general.hub]</span>
<span class="hljs-attr">repo-id</span> = <span class="hljs-string">&quot;myorg/mykernel&quot;</span>

<span class="hljs-section">[torch]</span>
<span class="hljs-attr">src</span> = [
  <span class="hljs-string">&quot;torch-ext/torch_binding.cpp&quot;</span>,
  <span class="hljs-string">&quot;torch-ext/torch_binding.h&quot;</span>,
]

<span class="hljs-section">[kernel.mykernel]</span>
<span class="hljs-attr">backend</span> = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-attr">depends</span> = [<span class="hljs-string">&quot;torch&quot;</span>]
<span class="hljs-attr">src</span> = [<span class="hljs-string">&quot;mykernel_cuda/mykernel.cu&quot;</span>]
<span class="hljs-comment"># If the kernel is only supported on specific capabilities, set the</span>
<span class="hljs-comment"># cuda-capabilities option:</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># cuda-capabilities = [ &quot;9.0&quot;, &quot;10.0&quot;, &quot;12.0&quot; ]</span>`,wrap:!1}}),ne=new f({props:{title:"general",local:"general",headingTag:"h3"}}),se=new f({props:{title:"general.hub",local:"generalhub",headingTag:"h3"}}),oe=new f({props:{title:"general.cuda",local:"generalcuda",headingTag:"h3"}}),pe=new f({props:{title:"torch",local:"torch",headingTag:"h3"}}),me=new f({props:{title:"kernel.<name>",local:"kernelltnamegt",headingTag:"h3"}}),ye=new f({props:{title:"cuda",local:"cuda",headingTag:"h4"}}),be=new f({props:{title:"rocm",local:"rocm",headingTag:"h4"}}),$e=new f({props:{title:"xpu",local:"xpu",headingTag:"h4"}}),we=new f({props:{title:"Torch bindings",local:"torch-bindings",headingTag:"h2"}}),Ue=new f({props:{title:"Defining bindings",local:"defining-bindings",headingTag:"h3"}}),je=new T({props:{code:"JTIzcHJhZ21hJTIwb25jZSUwQSUwQSUyM2luY2x1ZGUlMjAlM0N0b3JjaCUyRnRvcmNoLmglM0UlMEElMEF2b2lkJTIwbXlrZXJuZWwodG9yY2glM0ElM0FUZW5zb3IlMjAlMjZvdXQlMkMlMjB0b3JjaCUzQSUzQVRlbnNvciUyMGNvbnN0JTIwJTI2aW5wdXQpJTNC",highlighted:`<span class="hljs-meta">#<span class="hljs-keyword">pragma</span> once</span>

<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;torch/torch.h&gt;</span></span>

<span class="hljs-function"><span class="hljs-type">void</span> <span class="hljs-title">mykernel</span><span class="hljs-params">(torch::Tensor &amp;out, torch::Tensor <span class="hljs-type">const</span> &amp;input)</span></span>;`,wrap:!1}}),Ie=new T({props:{code:"JTIzaW5jbHVkZSUyMCUzQ3RvcmNoJTJGbGlicmFyeS5oJTNFJTBBJTBBJTIzaW5jbHVkZSUyMCUyMnJlZ2lzdHJhdGlvbi5oJTIyJTBBJTIzaW5jbHVkZSUyMCUyMnRvcmNoX2JpbmRpbmcuaCUyMiUwQSUwQVRPUkNIX0xJQlJBUllfRVhQQU5EKFRPUkNIX0VYVEVOU0lPTl9OQU1FJTJDJTIwb3BzKSUyMCU3QiUwQSUyMCUyMG9wcy5kZWYoJTIybXlrZXJuZWwoVGVuc29yISUyMG91dCUyQyUyMFRlbnNvciUyMGlucHV0KSUyMC0lM0UlMjAoKSUyMiklM0IlMEElMjNpZiUyMGRlZmluZWQoQ1VEQV9LRVJORUwpJTIwJTdDJTdDJTIwZGVmaW5lZChST0NNX0tFUk5FTCklMEElMjAlMjBvcHMuaW1wbCglMjJteWtlcm5lbCUyMiUyQyUyMHRvcmNoJTNBJTNBa0NVREElMkMlMjAlMjZteWtlcm5lbCklM0IlMEElMjNlbmRpZiUwQSU3RCUwQSUwQVJFR0lTVEVSX0VYVEVOU0lPTihUT1JDSF9FWFRFTlNJT05fTkFNRSk=",highlighted:`<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;torch/library.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&quot;registration.h&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&quot;torch_binding.h&quot;</span></span>

<span class="hljs-built_in">TORCH_LIBRARY_EXPAND</span>(TORCH_EXTENSION_NAME, ops) {
  ops.<span class="hljs-built_in">def</span>(<span class="hljs-string">&quot;mykernel(Tensor! out, Tensor input) -&gt; ()&quot;</span>);
<span class="hljs-meta">#<span class="hljs-keyword">if</span> defined(CUDA_KERNEL) || defined(ROCM_KERNEL)</span>
  ops.<span class="hljs-built_in">impl</span>(<span class="hljs-string">&quot;mykernel&quot;</span>, torch::kCUDA, &amp;mykernel);
<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span>
}

<span class="hljs-built_in">REGISTER_EXTENSION</span>(TORCH_EXTENSION_NAME)`,wrap:!1}}),Le=new f({props:{title:"Using kernel functions from Python",local:"using-kernel-functions-from-python",headingTag:"h2"}}),Ve=new T({props:{code:"ZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTBBJTBBaW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwLl9vcHMlMjBpbXBvcnQlMjBvcHMlMEElMEElMEFkZWYlMjBteWtlcm5lbCh4JTNBJTIwdG9yY2guVGVuc29yJTJDJTIwb3V0JTNBJTIwT3B0aW9uYWwlNUJ0b3JjaC5UZW5zb3IlNUQlMjAlM0QlMjBOb25lKSUyMC0lM0UlMjB0b3JjaC5UZW5zb3IlM0ElMEElMjAlMjAlMjAlMjBpZiUyMG91dCUyMGlzJTIwTm9uZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dCUyMCUzRCUyMHRvcmNoLmVtcHR5X2xpa2UoeCklMEElMjAlMjAlMjAlMjBvcHMubXlrZXJuZWwob3V0JTJDJTIweCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBvdXQ=",highlighted:`<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>

<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> ._ops <span class="hljs-keyword">import</span> ops


<span class="hljs-keyword">def</span> <span class="hljs-title function_">mykernel</span>(<span class="hljs-params">x: torch.Tensor, out: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span></span>) -&gt; torch.Tensor:
    <span class="hljs-keyword">if</span> out <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
        out = torch.empty_like(x)
    ops.mykernel(out, x)
    <span class="hljs-keyword">return</span> out`,wrap:!1}}),Ze=new f({props:{title:"Kernel tests",local:"kernel-tests",headingTag:"h2"}}),Be=new T({props:{code:"aW1wb3J0JTIwcHl0ZXN0JTBBJTBBJTQwcHl0ZXN0Lm1hcmsua2VybmVsc19jaSUwQWRlZiUyMHRlc3RfbXlrZXJuZWwoKSUzQSUwQSUyMCUyMC4uLg==",highlighted:`<span class="hljs-keyword">import</span> pytest

<span class="hljs-meta">@pytest.mark.kernels_ci</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">test_mykernel</span>():
  ...`,wrap:!1}}),We=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpLXRlc3Q=",highlighted:'$ nix run .<span class="hljs-comment">#ci-test</span>',wrap:!1}}),Se=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpVGVzdHMudG9yY2gyMTAtY3h4MTEtY3B1LXg4Nl82NC1saW51eA==",highlighted:'$ nix run .<span class="hljs-comment">#ciTests.torch210-cxx11-cpu-x86_64-linux</span>',wrap:!1}}),Ge=new f({props:{title:"Kernel docs",local:"kernel-docs",headingTag:"h2"}}),Ye=new Wn({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/writing-kernels.md"}}),{c(){y=a("meta"),ze=i(),Fe=a("p"),Ke=i(),p(M.$$.fragment),et=i(),p(b.$$.fragment),tt=i(),p(k.$$.fragment),lt=i(),$=a("p"),$.innerHTML=Nl,nt=i(),g=a("ul"),g.innerHTML=Vl,it=i(),w=a("p"),w.innerHTML=Zl,st=i(),U=a("ul"),U.innerHTML=Rl,at=i(),J=a("p"),J.innerHTML=Bl,ot=i(),C=a("p"),C.innerHTML=El,rt=i(),p(v.$$.fragment),pt=i(),p(j.$$.fragment),dt=i(),x=a("p"),x.innerHTML=Ql,ct=i(),p(I.$$.fragment),mt=i(),H=a("p"),H.textContent=Wl,ut=i(),L=a("ol"),L.innerHTML=Al,ht=i(),_=a("p"),_.innerHTML=Sl,ft=i(),p(N.$$.fragment),Tt=i(),V=a("p"),V.innerHTML=Pl,yt=i(),p(Z.$$.fragment),Mt=i(),R=a("p"),R.innerHTML=Gl,bt=i(),B=a("p"),B.textContent=ql,kt=i(),p(E.$$.fragment),$t=i(),Q=a("p"),Q.innerHTML=Xl,gt=i(),p(W.$$.fragment),wt=i(),A=a("p"),A.innerHTML=Ol,Ut=i(),S=a("p"),S.innerHTML=Yl,Jt=i(),p(P.$$.fragment),Ct=i(),G=a("p"),G.innerHTML=Fl,vt=i(),p(q.$$.fragment),jt=i(),X=a("p"),X.innerHTML=Dl,xt=i(),p(O.$$.fragment),It=i(),Y=a("p"),Y.textContent=zl,Ht=i(),p(F.$$.fragment),Lt=i(),D=a("p"),D.textContent=Kl,_t=i(),z=a("ul"),z.innerHTML=en,Nt=i(),p(K.$$.fragment),Vt=i(),ee=a("p"),ee.innerHTML=tn,Zt=i(),p(te.$$.fragment),Rt=i(),le=a("p"),le.innerHTML=ln,Bt=i(),p(ne.$$.fragment),Et=i(),ie=a("ul"),ie.innerHTML=nn,Qt=i(),p(se.$$.fragment),Wt=i(),ae=a("ul"),ae.innerHTML=sn,At=i(),p(oe.$$.fragment),St=i(),re=a("ul"),re.innerHTML=an,Pt=i(),p(pe.$$.fragment),Gt=i(),de=a("p"),de.textContent=on,qt=i(),ce=a("ul"),ce.innerHTML=rn,Xt=i(),p(me.$$.fragment),Ot=i(),ue=a("p"),ue.innerHTML=pn,Yt=i(),he=a("p"),he.textContent=dn,Ft=i(),fe=a("ul"),fe.innerHTML=cn,Dt=i(),Te=a("p"),Te.textContent=mn,zt=i(),p(ye.$$.fragment),Kt=i(),Me=a("ul"),Me.innerHTML=un,el=i(),p(be.$$.fragment),tl=i(),ke=a("ul"),ke.innerHTML=hn,ll=i(),p($e.$$.fragment),nl=i(),ge=a("ul"),ge.innerHTML=fn,il=i(),p(we.$$.fragment),sl=i(),p(Ue.$$.fragment),al=i(),Je=a("p"),Je.textContent=Tn,ol=i(),Ce=a("ul"),Ce.innerHTML=yn,rl=i(),ve=a("p"),ve.innerHTML=Mn,pl=i(),p(je.$$.fragment),dl=i(),xe=a("p"),xe.innerHTML=bn,cl=i(),p(Ie.$$.fragment),ml=i(),He=a("p"),He.innerHTML=kn,ul=i(),p(Le.$$.fragment),hl=i(),_e=a("p"),_e.innerHTML=$n,fl=i(),Ne=a("p"),Ne.innerHTML=gn,Tl=i(),p(Ve.$$.fragment),yl=i(),p(Ze.$$.fragment),Ml=i(),Re=a("p"),Re.innerHTML=wn,bl=i(),p(Be.$$.fragment),kl=i(),Ee=a("p"),Ee.textContent=Un,$l=i(),Qe=a("p"),Qe.textContent=Jn,gl=i(),p(We.$$.fragment),wl=i(),Ae=a("p"),Ae.innerHTML=Cn,Ul=i(),p(Se.$$.fragment),Jl=i(),Pe=a("p"),Pe.innerHTML=vn,Cl=i(),p(Ge.$$.fragment),vl=i(),qe=a("p"),qe.innerHTML=jn,jl=i(),Xe=a("p"),Xe.innerHTML=xn,xl=i(),Oe=a("p"),Oe.innerHTML=In,Il=i(),p(Ye.$$.fragment),Hl=i(),De=a("p"),this.h()},l(e){const t=Bn("svelte-u9bgzb",document.head);y=o(t,"META",{name:!0,content:!0}),t.forEach(l),ze=s(e),Fe=o(e,"P",{}),Hn(Fe).forEach(l),Ke=s(e),d(M.$$.fragment,e),et=s(e),d(b.$$.fragment,e),tt=s(e),d(k.$$.fragment,e),lt=s(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1i1c9ni"&&($.innerHTML=Nl),nt=s(e),g=o(e,"UL",{"data-svelte-h":!0}),r(g)!=="svelte-1odnsz3"&&(g.innerHTML=Vl),it=s(e),w=o(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1gp9ycj"&&(w.innerHTML=Zl),st=s(e),U=o(e,"UL",{"data-svelte-h":!0}),r(U)!=="svelte-ysrhph"&&(U.innerHTML=Rl),at=s(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-vy7wcb"&&(J.innerHTML=Bl),ot=s(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-o9ssdv"&&(C.innerHTML=El),rt=s(e),d(v.$$.fragment,e),pt=s(e),d(j.$$.fragment,e),dt=s(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-96m8sj"&&(x.innerHTML=Ql),ct=s(e),d(I.$$.fragment,e),mt=s(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1b4vj4e"&&(H.textContent=Wl),ut=s(e),L=o(e,"OL",{"data-svelte-h":!0}),r(L)!=="svelte-3arzgs"&&(L.innerHTML=Al),ht=s(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1ihjqjm"&&(_.innerHTML=Sl),ft=s(e),d(N.$$.fragment,e),Tt=s(e),V=o(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1cac215"&&(V.innerHTML=Pl),yt=s(e),d(Z.$$.fragment,e),Mt=s(e),R=o(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-4lye9k"&&(R.innerHTML=Gl),bt=s(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-g5i707"&&(B.textContent=ql),kt=s(e),d(E.$$.fragment,e),$t=s(e),Q=o(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-cn9mkc"&&(Q.innerHTML=Xl),gt=s(e),d(W.$$.fragment,e),wt=s(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1prqyz3"&&(A.innerHTML=Ol),Ut=s(e),S=o(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-1exh4w8"&&(S.innerHTML=Yl),Jt=s(e),d(P.$$.fragment,e),Ct=s(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1poutmy"&&(G.innerHTML=Fl),vt=s(e),d(q.$$.fragment,e),jt=s(e),X=o(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-s84xza"&&(X.innerHTML=Dl),xt=s(e),d(O.$$.fragment,e),It=s(e),Y=o(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-6oo725"&&(Y.textContent=zl),Ht=s(e),d(F.$$.fragment,e),Lt=s(e),D=o(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-1lqdx4"&&(D.textContent=Kl),_t=s(e),z=o(e,"UL",{"data-svelte-h":!0}),r(z)!=="svelte-c8vtob"&&(z.innerHTML=en),Nt=s(e),d(K.$$.fragment,e),Vt=s(e),ee=o(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-1hgp1cr"&&(ee.innerHTML=tn),Zt=s(e),d(te.$$.fragment,e),Rt=s(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-pgruc9"&&(le.innerHTML=ln),Bt=s(e),d(ne.$$.fragment,e),Et=s(e),ie=o(e,"UL",{"data-svelte-h":!0}),r(ie)!=="svelte-cm9oc9"&&(ie.innerHTML=nn),Qt=s(e),d(se.$$.fragment,e),Wt=s(e),ae=o(e,"UL",{"data-svelte-h":!0}),r(ae)!=="svelte-12rq95i"&&(ae.innerHTML=sn),At=s(e),d(oe.$$.fragment,e),St=s(e),re=o(e,"UL",{"data-svelte-h":!0}),r(re)!=="svelte-1fzn2"&&(re.innerHTML=an),Pt=s(e),d(pe.$$.fragment,e),Gt=s(e),de=o(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-3rear0"&&(de.textContent=on),qt=s(e),ce=o(e,"UL",{"data-svelte-h":!0}),r(ce)!=="svelte-1079mx2"&&(ce.innerHTML=rn),Xt=s(e),d(me.$$.fragment,e),Ot=s(e),ue=o(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1weg0gu"&&(ue.innerHTML=pn),Yt=s(e),he=o(e,"P",{"data-svelte-h":!0}),r(he)!=="svelte-1al5myg"&&(he.textContent=dn),Ft=s(e),fe=o(e,"UL",{"data-svelte-h":!0}),r(fe)!=="svelte-1fbzu1m"&&(fe.innerHTML=cn),Dt=s(e),Te=o(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-1mf578x"&&(Te.textContent=mn),zt=s(e),d(ye.$$.fragment,e),Kt=s(e),Me=o(e,"UL",{"data-svelte-h":!0}),r(Me)!=="svelte-1ym43dg"&&(Me.innerHTML=un),el=s(e),d(be.$$.fragment,e),tl=s(e),ke=o(e,"UL",{"data-svelte-h":!0}),r(ke)!=="svelte-mx7mxt"&&(ke.innerHTML=hn),ll=s(e),d($e.$$.fragment,e),nl=s(e),ge=o(e,"UL",{"data-svelte-h":!0}),r(ge)!=="svelte-10v9trt"&&(ge.innerHTML=fn),il=s(e),d(we.$$.fragment,e),sl=s(e),d(Ue.$$.fragment,e),al=s(e),Je=o(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-r7rot5"&&(Je.textContent=Tn),ol=s(e),Ce=o(e,"UL",{"data-svelte-h":!0}),r(Ce)!=="svelte-poxr41"&&(Ce.innerHTML=yn),rl=s(e),ve=o(e,"P",{"data-svelte-h":!0}),r(ve)!=="svelte-1ikzb58"&&(ve.innerHTML=Mn),pl=s(e),d(je.$$.fragment,e),dl=s(e),xe=o(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-5ja9lk"&&(xe.innerHTML=bn),cl=s(e),d(Ie.$$.fragment,e),ml=s(e),He=o(e,"P",{"data-svelte-h":!0}),r(He)!=="svelte-ssih46"&&(He.innerHTML=kn),ul=s(e),d(Le.$$.fragment,e),hl=s(e),_e=o(e,"P",{"data-svelte-h":!0}),r(_e)!=="svelte-1y8rjsx"&&(_e.innerHTML=$n),fl=s(e),Ne=o(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-a3yu8e"&&(Ne.innerHTML=gn),Tl=s(e),d(Ve.$$.fragment,e),yl=s(e),d(Ze.$$.fragment,e),Ml=s(e),Re=o(e,"P",{"data-svelte-h":!0}),r(Re)!=="svelte-q979am"&&(Re.innerHTML=wn),bl=s(e),d(Be.$$.fragment,e),kl=s(e),Ee=o(e,"P",{"data-svelte-h":!0}),r(Ee)!=="svelte-1uzdod8"&&(Ee.textContent=Un),$l=s(e),Qe=o(e,"P",{"data-svelte-h":!0}),r(Qe)!=="svelte-s01sgi"&&(Qe.textContent=Jn),gl=s(e),d(We.$$.fragment,e),wl=s(e),Ae=o(e,"P",{"data-svelte-h":!0}),r(Ae)!=="svelte-1ucbtrx"&&(Ae.innerHTML=Cn),Ul=s(e),d(Se.$$.fragment,e),Jl=s(e),Pe=o(e,"P",{"data-svelte-h":!0}),r(Pe)!=="svelte-gcopz4"&&(Pe.innerHTML=vn),Cl=s(e),d(Ge.$$.fragment,e),vl=s(e),qe=o(e,"P",{"data-svelte-h":!0}),r(qe)!=="svelte-11q3n4g"&&(qe.innerHTML=jn),jl=s(e),Xe=o(e,"P",{"data-svelte-h":!0}),r(Xe)!=="svelte-zjr5ot"&&(Xe.innerHTML=xn),xl=s(e),Oe=o(e,"P",{"data-svelte-h":!0}),r(Oe)!=="svelte-rt0n0n"&&(Oe.innerHTML=In),Il=s(e),d(Ye.$$.fragment,e),Hl=s(e),De=o(e,"P",{}),Hn(De).forEach(l),this.h()},h(){Ln(y,"name","hf:doc:metadata"),Ln(y,"content",Sn)},m(e,t){En(document.head,y),n(e,ze,t),n(e,Fe,t),n(e,Ke,t),c(M,e,t),n(e,et,t),c(b,e,t),n(e,tt,t),c(k,e,t),n(e,lt,t),n(e,$,t),n(e,nt,t),n(e,g,t),n(e,it,t),n(e,w,t),n(e,st,t),n(e,U,t),n(e,at,t),n(e,J,t),n(e,ot,t),n(e,C,t),n(e,rt,t),c(v,e,t),n(e,pt,t),c(j,e,t),n(e,dt,t),n(e,x,t),n(e,ct,t),c(I,e,t),n(e,mt,t),n(e,H,t),n(e,ut,t),n(e,L,t),n(e,ht,t),n(e,_,t),n(e,ft,t),c(N,e,t),n(e,Tt,t),n(e,V,t),n(e,yt,t),c(Z,e,t),n(e,Mt,t),n(e,R,t),n(e,bt,t),n(e,B,t),n(e,kt,t),c(E,e,t),n(e,$t,t),n(e,Q,t),n(e,gt,t),c(W,e,t),n(e,wt,t),n(e,A,t),n(e,Ut,t),n(e,S,t),n(e,Jt,t),c(P,e,t),n(e,Ct,t),n(e,G,t),n(e,vt,t),c(q,e,t),n(e,jt,t),n(e,X,t),n(e,xt,t),c(O,e,t),n(e,It,t),n(e,Y,t),n(e,Ht,t),c(F,e,t),n(e,Lt,t),n(e,D,t),n(e,_t,t),n(e,z,t),n(e,Nt,t),c(K,e,t),n(e,Vt,t),n(e,ee,t),n(e,Zt,t),c(te,e,t),n(e,Rt,t),n(e,le,t),n(e,Bt,t),c(ne,e,t),n(e,Et,t),n(e,ie,t),n(e,Qt,t),c(se,e,t),n(e,Wt,t),n(e,ae,t),n(e,At,t),c(oe,e,t),n(e,St,t),n(e,re,t),n(e,Pt,t),c(pe,e,t),n(e,Gt,t),n(e,de,t),n(e,qt,t),n(e,ce,t),n(e,Xt,t),c(me,e,t),n(e,Ot,t),n(e,ue,t),n(e,Yt,t),n(e,he,t),n(e,Ft,t),n(e,fe,t),n(e,Dt,t),n(e,Te,t),n(e,zt,t),c(ye,e,t),n(e,Kt,t),n(e,Me,t),n(e,el,t),c(be,e,t),n(e,tl,t),n(e,ke,t),n(e,ll,t),c($e,e,t),n(e,nl,t),n(e,ge,t),n(e,il,t),c(we,e,t),n(e,sl,t),c(Ue,e,t),n(e,al,t),n(e,Je,t),n(e,ol,t),n(e,Ce,t),n(e,rl,t),n(e,ve,t),n(e,pl,t),c(je,e,t),n(e,dl,t),n(e,xe,t),n(e,cl,t),c(Ie,e,t),n(e,ml,t),n(e,He,t),n(e,ul,t),c(Le,e,t),n(e,hl,t),n(e,_e,t),n(e,fl,t),n(e,Ne,t),n(e,Tl,t),c(Ve,e,t),n(e,yl,t),c(Ze,e,t),n(e,Ml,t),n(e,Re,t),n(e,bl,t),c(Be,e,t),n(e,kl,t),n(e,Ee,t),n(e,$l,t),n(e,Qe,t),n(e,gl,t),c(We,e,t),n(e,wl,t),n(e,Ae,t),n(e,Ul,t),c(Se,e,t),n(e,Jl,t),n(e,Pe,t),n(e,Cl,t),c(Ge,e,t),n(e,vl,t),n(e,qe,t),n(e,jl,t),n(e,Xe,t),n(e,xl,t),n(e,Oe,t),n(e,Il,t),c(Ye,e,t),n(e,Hl,t),n(e,De,t),Ll=!0},p:Nn,i(e){Ll||(m(M.$$.fragment,e),m(b.$$.fragment,e),m(k.$$.fragment,e),m(v.$$.fragment,e),m(j.$$.fragment,e),m(I.$$.fragment,e),m(N.$$.fragment,e),m(Z.$$.fragment,e),m(E.$$.fragment,e),m(W.$$.fragment,e),m(P.$$.fragment,e),m(q.$$.fragment,e),m(O.$$.fragment,e),m(F.$$.fragment,e),m(K.$$.fragment,e),m(te.$$.fragment,e),m(ne.$$.fragment,e),m(se.$$.fragment,e),m(oe.$$.fragment,e),m(pe.$$.fragment,e),m(me.$$.fragment,e),m(ye.$$.fragment,e),m(be.$$.fragment,e),m($e.$$.fragment,e),m(we.$$.fragment,e),m(Ue.$$.fragment,e),m(je.$$.fragment,e),m(Ie.$$.fragment,e),m(Le.$$.fragment,e),m(Ve.$$.fragment,e),m(Ze.$$.fragment,e),m(Be.$$.fragment,e),m(We.$$.fragment,e),m(Se.$$.fragment,e),m(Ge.$$.fragment,e),m(Ye.$$.fragment,e),Ll=!0)},o(e){u(M.$$.fragment,e),u(b.$$.fragment,e),u(k.$$.fragment,e),u(v.$$.fragment,e),u(j.$$.fragment,e),u(I.$$.fragment,e),u(N.$$.fragment,e),u(Z.$$.fragment,e),u(E.$$.fragment,e),u(W.$$.fragment,e),u(P.$$.fragment,e),u(q.$$.fragment,e),u(O.$$.fragment,e),u(F.$$.fragment,e),u(K.$$.fragment,e),u(te.$$.fragment,e),u(ne.$$.fragment,e),u(se.$$.fragment,e),u(oe.$$.fragment,e),u(pe.$$.fragment,e),u(me.$$.fragment,e),u(ye.$$.fragment,e),u(be.$$.fragment,e),u($e.$$.fragment,e),u(we.$$.fragment,e),u(Ue.$$.fragment,e),u(je.$$.fragment,e),u(Ie.$$.fragment,e),u(Le.$$.fragment,e),u(Ve.$$.fragment,e),u(Ze.$$.fragment,e),u(Be.$$.fragment,e),u(We.$$.fragment,e),u(Se.$$.fragment,e),u(Ge.$$.fragment,e),u(Ye.$$.fragment,e),Ll=!1},d(e){e&&(l(ze),l(Fe),l(Ke),l(et),l(tt),l(lt),l($),l(nt),l(g),l(it),l(w),l(st),l(U),l(at),l(J),l(ot),l(C),l(rt),l(pt),l(dt),l(x),l(ct),l(mt),l(H),l(ut),l(L),l(ht),l(_),l(ft),l(Tt),l(V),l(yt),l(Mt),l(R),l(bt),l(B),l(kt),l($t),l(Q),l(gt),l(wt),l(A),l(Ut),l(S),l(Jt),l(Ct),l(G),l(vt),l(jt),l(X),l(xt),l(It),l(Y),l(Ht),l(Lt),l(D),l(_t),l(z),l(Nt),l(Vt),l(ee),l(Zt),l(Rt),l(le),l(Bt),l(Et),l(ie),l(Qt),l(Wt),l(ae),l(At),l(St),l(re),l(Pt),l(Gt),l(de),l(qt),l(ce),l(Xt),l(Ot),l(ue),l(Yt),l(he),l(Ft),l(fe),l(Dt),l(Te),l(zt),l(Kt),l(Me),l(el),l(tl),l(ke),l(ll),l(nl),l(ge),l(il),l(sl),l(al),l(Je),l(ol),l(Ce),l(rl),l(ve),l(pl),l(dl),l(xe),l(cl),l(ml),l(He),l(ul),l(hl),l(_e),l(fl),l(Ne),l(Tl),l(yl),l(Ml),l(Re),l(bl),l(kl),l(Ee),l($l),l(Qe),l(gl),l(wl),l(Ae),l(Ul),l(Jl),l(Pe),l(Cl),l(vl),l(qe),l(jl),l(Xe),l(xl),l(Oe),l(Il),l(Hl),l(De)),l(y),h(M,e),h(b,e),h(k,e),h(v,e),h(j,e),h(I,e),h(N,e),h(Z,e),h(E,e),h(W,e),h(P,e),h(q,e),h(O,e),h(F,e),h(K,e),h(te,e),h(ne,e),h(se,e),h(oe,e),h(pe,e),h(me,e),h(ye,e),h(be,e),h($e,e),h(we,e),h(Ue,e),h(je,e),h(Ie,e),h(Le,e),h(Ve,e),h(Ze,e),h(Be,e),h(We,e),h(Se,e),h(Ge,e),h(Ye,e)}}}const Sn='{"title":"Writing Hub kernels with kernel-builder","local":"writing-hub-kernels-with-kernel-builder","sections":[{"title":"Introduction","local":"introduction","sections":[],"depth":2},{"title":"Setting up environment","local":"setting-up-environment","sections":[{"title":"Quick install","local":"quick-install","sections":[],"depth":3},{"title":"Cloud environment","local":"cloud-environment","sections":[],"depth":3}],"depth":2},{"title":"Starting a new kernel","local":"starting-a-new-kernel","sections":[],"depth":2},{"title":"Kernel project layout","local":"kernel-project-layout","sections":[],"depth":2},{"title":"build.toml","local":"buildtoml","sections":[{"title":"general","local":"general","sections":[],"depth":3},{"title":"general.hub","local":"generalhub","sections":[],"depth":3},{"title":"general.cuda","local":"generalcuda","sections":[],"depth":3},{"title":"torch","local":"torch","sections":[],"depth":3},{"title":"kernel.&lt;name&gt;","local":"kernelltnamegt","sections":[{"title":"cuda","local":"cuda","sections":[],"depth":4},{"title":"rocm","local":"rocm","sections":[],"depth":4},{"title":"xpu","local":"xpu","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"Torch bindings","local":"torch-bindings","sections":[{"title":"Defining bindings","local":"defining-bindings","sections":[],"depth":3}],"depth":2},{"title":"Using kernel functions from Python","local":"using-kernel-functions-from-python","sections":[],"depth":2},{"title":"Kernel tests","local":"kernel-tests","sections":[],"depth":2},{"title":"Kernel docs","local":"kernel-docs","sections":[],"depth":2}],"depth":1}';function Pn(_l){return Vn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fn extends Zn{constructor(y){super(),Rn(this,y,Pn,An,_n,{})}}export{Fn as component};
