Buckets:
| import{s as Bi,n as Ni,o as Wi}from"../chunks/scheduler.f3b1e791.js";import{S as Qi,i as Ei,e as o,s as i,c as p,h as Ai,a,d as l,b as s,f as Ri,g as c,j as r,k as Un,l as qi,m as n,n as d,t as m,o as u,p as h}from"../chunks/index.023a9934.js";import{C as Gi,H as f,E as Xi}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3d676eea.js";import{C as T}from"../chunks/CodeBlock.bc5a8d81.js";function Si(Jn){let y,kt,bt,gt,M,$t,k,wt,g,Ut,$,Cn=`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:`,Jt,w,vn=`<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>`,Ct,U,jn=`<code>kernel-builder</code> is a set of tools that can build conforming kernels. It | |
| takes care of:`,vt,J,xn=`<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>`,jt,C,_n=`<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.`,xt,v,Hn=`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.`,_t,b,In=`<p>We maintain a set of conforming kernels in the | |
| <a href="https://github.com/huggingface/kernels-community" rel="nofollow">kernels-community repository</a>. | |
| We try to keep these kernels synced with upstream as much as possible.</p>`,Ht,j,It,x,Lt,_,Ln=`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:`,Vt,H,Zt,I,Vn="This will:",Rt,L,Zn=`<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>`,Bt,V,Rn="To update <code>kernel-builder</code> later:",Nt,Z,Wt,R,Bn=`For a step-by-step breakdown of what the script does, see | |
| <a href="nix">Using the kernel builder with Nix</a>.`,Qt,B,Et,N,Nn=`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.`,At,W,Wn=`If you use a different provider, the Terraform bridges should be | |
| similar and straightforward to modify.`,qt,Q,Gt,E,Qn=`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:`,Xt,A,St,q,En=`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.`,Pt,G,An=`By default, the <code>init</code> subcommand creates a CUDA kernel. You can specify | |
| another backend with the <code>--backends</code> option:`,Ft,X,Yt,S,qn=`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>:`,Ot,P,zt,F,Gn=`Finally, if you want to create a kernel for all supported backends, you | |
| can use <code>--backends all</code>.`,Dt,Y,Kt,O,Xn="Kernel projects follow this general directory layout:",el,z,tl,D,Sn="In this example we can find:",ll,K,Pn=`<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>`,nl,ee,il,te,Fn=`<code>build.toml</code> tells <code>kernel-builder</code> what to build and how. It looks as | |
| follows for the <code>mykernel</code> kernel:`,sl,le,ol,ne,Yn="The following sections enumerate all supported options for <code>build.toml</code>.",al,ie,rl,se,On=`<li><code>name</code> (required): the name of the kernel. The Python code for a Torch | |
| extension must be stored in <code>torch-ext/<name></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<version></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>upstream</code>: Git-compatible URL (passable to <code>git clone</code>) of the original | |
| upstream repository where the kernel source code comes from.</li> <li><code>source</code>: Git-compatible URL (passable to <code>git clone</code>) of the kernel-builder | |
| formatted source repository. This repository must contain a <code>build.toml</code> and | |
| <code>flake.nix</code> so that it can be pulled and built with the kernel builder.</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>`,pl,oe,cl,ae,zn=`<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>`,dl,re,ml,pe,Dn=`<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>`,ul,ce,hl,de,Kn=`The framework section specifies framework-specific settings. The name of | |
| the section depends on the framework that is used. The currently supported | |
| frameworks are:`,fl,me,ei="<li>AOT-compiled Torch kernel (<code>torch</code>).</li> <li>AOT-compiled TVM-FFI kernel (<code>tvm-ffi</code>).</li> <li>JIT-compiled or not-compiled Torch kernel (<code>torch-noarch</code>, experimental).</li>",Tl,ue,yl,he,ti=`This framework section is used for AOT-compiled Torch kernels, and has the | |
| following options:`,bl,fe,li=`<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>["py", "pyi"]</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> <li><code>stable-abi</code> (<strong>experimental</strong>): when set to a Torch version (e.g. | |
| <code>"2.11"</code>), the kernel is built using the Torch stable ABI. This | |
| requires that the kernel itself only use | |
| <a href="https://docs.pytorch.org/docs/2.12/notes/libtorch_stable_abi.html" rel="nofollow">stable ABI headers</a>. | |
| For an example, see the <a href="https://github.com/huggingface/kernels/tree/main/examples/kernels/relu-torch-stable-abi" rel="nofollow"><code>relu-torch-stable-abi</code></a> | |
| example kernel.</li>`,Ml,Te,kl,ye,ni="This framework section is used for AOT-compiled TVM-FFI kernels.",gl,be,ii=`<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>["py", "pyi"]</code>.</li> <li><code>include</code> (optional): include directories relative to the project root. | |
| Default: <code>[]</code>.</li>`,$l,Me,wl,ke,si=`The <code>torch-noarch</code> section is used for JIT-compiled kernels or kernels that | |
| do not require any ahead-of-time compilation (e.g. a kernel that packages plain PyTorch | |
| layers).`,Ul,ge,oi=`Normally, it is expected that this type of kernel runs on all CUDA capabilities | |
| or ROCm architectures. However, for kernels that support only a limited range | |
| of archs, the <code>cuda-capabilites</code> and <code>rocm-archs</code> options can be used to specify | |
| the supported archs. These are then exported to <code>metadata.json</code> for consumption | |
| by e.g. the Hugging Face Hub.`,Jl,$e,ai=`<li><code>pyext</code> (optional): the list of extensions for Python files. Default: | |
| <code>["py", "pyi"]</code>.</li> <li><code>cuda-capabilities</code> (optional): a list of CUDA compute capabilities the | |
| kernel supports (e.g. <code>["9.0", "10.0"]</code>).</li> <li><code>rocm-archs</code> (optional): a list of ROCm architectures the kernel supports | |
| (e.g. <code>["gfx942"]</code>).</li>`,Cl,we,vl,Ue,ri=`Specification of a kernel with the name <code><name></code>. Multiple <code>kernel.<name></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.`,jl,Je,pi="The following options can be set for a kernel:",xl,Ce,ci=`<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>`,_l,ve,di=`Besides these shared options, the following backend-specific options | |
| are available:`,Hl,je,Il,xe,mi=`<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>`,Ll,_e,Vl,He,ui=`<li><code>rocm-archs</code>: a list of ROCm architectures that the kernel should be | |
| compiled for.</li>`,Zl,Ie,Rl,Le,hi=`<li><code>sycl-flags</code>: a list of additional flags to be passed to the SYCL | |
| compiler.</li>`,Bl,Ve,Nl,Ze,fi=`<li><code>cxx-flags</code>: a list of additional flags to be passed to the C++ | |
| compiler.</li>`,Wl,Re,Ql,Be,El,Ne,Ti="Torch bindings are defined in C++, kernels commonly use two files:",Al,We,yi="<li><code>torch_binding.h</code> containing function declarations.</li> <li><code>torch_binding.cpp</code> registering the functions as Torch ops.</li>",ql,Qe,bi=`For instance, the <code>mykernel</code> kernel discussed above has the following | |
| declaration in <code>torch_binding.h</code>:`,Gl,Ee,Xl,Ae,Mi="This function is then registered as a Torch op in <code>torch_binding.cpp</code>:",Sl,qe,Pl,Ge,ki=`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.`,Fl,Xe,Yl,Se,gi=`The bindings are typically wrapped in Python code in <code>torch_ext/<name></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.<name>_<unique_material></code>.`,Ol,Pe,$i=`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:`,zl,Fe,Dl,Ye,Kl,Oe,wi=`You may want to register Torch ops from your kernel’s Python code or | |
| register fake ops for <code>torch.compile</code> support. It is important to register | |
| such ops in the namespace that kernel-builder makes for your kernel | |
| build. This is required for compliant kernels to ensure that multiple | |
| versions of the same kernel can be loaded at the same time without | |
| namespace conflicts.`,en,ze,Ui=`You can use the <code>add_op_namespace_prefix</code> to prefix an op name with the | |
| correct prefix. So for instance, replace`,tn,De,ln,Ke,Ji="by",nn,et,sn,tt,Ci="As mentioned in the above, the <code>_ops</code> module is generated by kernel-builder.",on,lt,vi=`kernel-builder uses a hook to reject incorrect usage of Torch op registration | |
| functions. However, it can only catch direct use of certain <code>torch.library</code> | |
| decorators. For instance, the hook would not reject the following decorator, | |
| so it should be seen as a last-resort check if human review failed:`,an,nt,rn,it,pn,st,ji=`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:`,cn,ot,dn,at,xi=`We recommend that you to pick tests that together would catch most error | |
| cases while running within 60 seconds.`,mn,rt,_i="You can run the tests (e.g. in CI) using:",un,pt,hn,ct,Hi=`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.<variant></code>. For instance:`,fn,dt,Tn,mt,Ii=`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>.`,yn,ut,bn,ht,Li=`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.`,Mn,ft,Vi=`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.`,kn,Tt,Zi=`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.`,gn,yt,$n,Mt,wn;return M=new Gi({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),k=new f({props:{title:"Write kernels",local:"write-kernels",headingTag:"h1"}}),g=new f({props:{title:"Introduction",local:"introduction",headingTag:"h2"}}),j=new f({props:{title:"Setting up environment",local:"setting-up-environment",headingTag:"h2"}}),x=new f({props:{title:"Quick install",local:"quick-install",headingTag:"h3"}}),H=new T({props:{code:"Y3VybCUyMC1mc1NMJTIwaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGaHVnZ2luZ2ZhY2UlMkZrZXJuZWxzJTJGbWFpbiUyRmluc3RhbGwuc2glMjAlN0MlMjBiYXNo",highlighted:"curl -fsSL https://raw.githubusercontent.com/huggingface/kernels/main/install.sh | bash",lang:"bash",wrap:!1}}),Z=new T({props:{code:"bml4JTIwcHJvZmlsZSUyMHVwZ3JhZGUlMjAtLWFsbA==",highlighted:"nix profile upgrade --all",lang:"bash",wrap:!1}}),B=new f({props:{title:"Cloud environment",local:"cloud-environment",headingTag:"h3"}}),Q=new f({props:{title:"Starting a new kernel",local:"starting-a-new-kernel",headingTag:"h2"}}),A=new T({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBpbml0JTIwLS1uYW1lJTIwbXlvcmclMkZteWtlcm5lbCUwQUluaXRpYWxpemVkJTIwJTYwbXlvcmclMkZteWtlcm5lbCU2MCUyMGF0JTIwJTJGaG9tZSUyRmRhbmllbCUyRmdpdCUyRmtlcm5lbHMlMkZleGFtcGxlcyUyRmtlcm5lbHMlMkZteWtlcm5lbA==",highlighted:"$ kernel-builder init --name myorg/mykernel\nInitialized `myorg/mykernel` at /home/daniel/git/kernels/examples/kernels/mykernel",lang:"bash",wrap:!1}}),X=new T({props:{code:"JTI0JTIwa2VybmVsLWJ1aWxkZXIlMjBpbml0JTIwLS1uYW1lJTIwbXlvcmclMkZteWtlcm5lbCUyMC0tYmFja2VuZHMlMjB4cHU=",highlighted:"$ kernel-builder init --name myorg/mykernel --backends xpu",lang:"bash",wrap:!1}}),P=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",lang:"bash",wrap:!1}}),Y=new f({props:{title:"Kernel project layout",local:"kernel-project-layout",headingTag:"h2"}}),z=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`,lang:"text",wrap:!1}}),ee=new f({props:{title:"build.toml",local:"buildtoml",headingTag:"h2"}}),le=new T({props:{code:"JTVCZ2VuZXJhbCU1RCUwQWJhY2tlbmRzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIyY3VkYSUyMiUyQyUwQSU1RCUwQW5hbWUlMjAlM0QlMjAlMjJteWtlcm5lbCUyMiUwQXZlcnNpb24lMjAlM0QlMjAxJTBBJTBBJTVCZ2VuZXJhbC5odWIlNUQlMEFyZXBvLWlkJTIwJTNEJTIwJTIybXlvcmclMkZteWtlcm5lbCUyMiUwQSUwQSU1QnRvcmNoJTVEJTBBc3JjJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIydG9yY2gtZXh0JTJGdG9yY2hfYmluZGluZy5jcHAlMjIlMkMlMEElMjAlMjAlMjJ0b3JjaC1leHQlMkZ0b3JjaF9iaW5kaW5nLmglMjIlMkMlMEElNUQlMEElMEElNUJrZXJuZWwubXlrZXJuZWwlNUQlMEFiYWNrZW5kJTIwJTNEJTIwJTIyY3VkYSUyMiUwQWRlcGVuZHMlMjAlM0QlMjAlNUIlMjJ0b3JjaCUyMiU1RCUwQXNyYyUyMCUzRCUyMCU1QiUyMm15a2VybmVsX2N1ZGElMkZteWtlcm5lbC5jdSUyMiU1RCUwQSUyMyUyMElmJTIwdGhlJTIwa2VybmVsJTIwaXMlMjBvbmx5JTIwc3VwcG9ydGVkJTIwb24lMjBzcGVjaWZpYyUyMGNhcGFiaWxpdGllcyUyQyUyMHNldCUyMHRoZSUwQSUyMyUyMGN1ZGEtY2FwYWJpbGl0aWVzJTIwb3B0aW9uJTNBJTBBJTIzJTBBJTIzJTIwY3VkYS1jYXBhYmlsaXRpZXMlMjAlM0QlMjAlNUIlMjAlMjI5LjAlMjIlMkMlMjAlMjIxMC4wJTIyJTJDJTIwJTIyMTIuMCUyMiUyMCU1RA==",highlighted:`<span class="hljs-section">[general]</span> | |
| <span class="hljs-attr">backends</span> = [ | |
| <span class="hljs-string">"cuda"</span>, | |
| ] | |
| <span class="hljs-attr">name</span> = <span class="hljs-string">"mykernel"</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">"myorg/mykernel"</span> | |
| <span class="hljs-section">[torch]</span> | |
| <span class="hljs-attr">src</span> = [ | |
| <span class="hljs-string">"torch-ext/torch_binding.cpp"</span>, | |
| <span class="hljs-string">"torch-ext/torch_binding.h"</span>, | |
| ] | |
| <span class="hljs-section">[kernel.mykernel]</span> | |
| <span class="hljs-attr">backend</span> = <span class="hljs-string">"cuda"</span> | |
| <span class="hljs-attr">depends</span> = [<span class="hljs-string">"torch"</span>] | |
| <span class="hljs-attr">src</span> = [<span class="hljs-string">"mykernel_cuda/mykernel.cu"</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 = [ "9.0", "10.0", "12.0" ]</span>`,lang:"toml",wrap:!1}}),ie=new f({props:{title:"general",local:"general",headingTag:"h3"}}),oe=new f({props:{title:"general.hub",local:"generalhub",headingTag:"h3"}}),re=new f({props:{title:"general.cuda",local:"generalcuda",headingTag:"h3"}}),ce=new f({props:{title:"Framework sections",local:"framework-sections",headingTag:"h3"}}),ue=new f({props:{title:"torch",local:"torch",headingTag:"h3"}}),Te=new f({props:{title:"tvm-ffi",local:"tvm-ffi",headingTag:"h3"}}),Me=new f({props:{title:"torch-noarch",local:"torch-noarch",headingTag:"h3"}}),we=new f({props:{title:"kernel.<name>",local:"kernelltnamegt",headingTag:"h3"}}),je=new f({props:{title:"cuda",local:"cuda",headingTag:"h4"}}),_e=new f({props:{title:"rocm",local:"rocm",headingTag:"h4"}}),Ie=new f({props:{title:"xpu",local:"xpu",headingTag:"h4"}}),Ve=new f({props:{title:"cpu",local:"cpu",headingTag:"h3"}}),Re=new f({props:{title:"Torch bindings",local:"torch-bindings",headingTag:"h2"}}),Be=new f({props:{title:"Defining bindings",local:"defining-bindings",headingTag:"h3"}}),Ee=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"><torch/torch.h></span></span> | |
| <span class="hljs-function"><span class="hljs-type">void</span> <span class="hljs-title">mykernel</span><span class="hljs-params">(torch::Tensor &out, torch::Tensor <span class="hljs-type">const</span> &input)</span></span>;`,lang:"cpp",wrap:!1}}),qe=new T({props:{code:"JTIzaW5jbHVkZSUyMCUzQ3RvcmNoJTJGbGlicmFyeS5oJTNFJTBBJTBBJTIzaW5jbHVkZSUyMCUyMnJlZ2lzdHJhdGlvbi5oJTIyJTBBJTIzaW5jbHVkZSUyMCUyMnRvcmNoX2JpbmRpbmcuaCUyMiUwQSUwQVRPUkNIX0xJQlJBUllfRVhQQU5EKFRPUkNIX0VYVEVOU0lPTl9OQU1FJTJDJTIwb3BzKSUyMCU3QiUwQSUyMCUyMG9wcy5kZWYoJTIybXlrZXJuZWwoVGVuc29yISUyMG91dCUyQyUyMFRlbnNvciUyMGlucHV0KSUyMC0lM0UlMjAoKSUyMiklM0IlMEElMjNpZiUyMGRlZmluZWQoQ1VEQV9LRVJORUwpJTIwJTdDJTdDJTIwZGVmaW5lZChST0NNX0tFUk5FTCklMEElMjAlMjBvcHMuaW1wbCglMjJteWtlcm5lbCUyMiUyQyUyMHRvcmNoJTNBJTNBa0NVREElMkMlMjAlMjZteWtlcm5lbCklM0IlMEElMjNlbmRpZiUwQSU3RCUwQSUwQVJFR0lTVEVSX0VYVEVOU0lPTihUT1JDSF9FWFRFTlNJT05fTkFNRSk=",highlighted:`<span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string"><torch/library.h></span></span> | |
| <span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">"registration.h"</span></span> | |
| <span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">"torch_binding.h"</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">"mykernel(Tensor! out, Tensor input) -> ()"</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">"mykernel"</span>, torch::kCUDA, &mykernel); | |
| <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span> | |
| } | |
| <span class="hljs-built_in">REGISTER_EXTENSION</span>(TORCH_EXTENSION_NAME)`,lang:"cpp",wrap:!1}}),Xe=new f({props:{title:"Using kernel functions from Python",local:"using-kernel-functions-from-python",headingTag:"h2"}}),Fe=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>) -> 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`,lang:"python",wrap:!1}}),Ye=new f({props:{title:"Registering Torch operators",local:"registering-torch-operators",headingTag:"h2"}}),De=new T({props:{code:"JTQwdG9yY2gubGlicmFyeS5yZWdpc3Rlcl9mYWtlKCUyMnJlbHUlM0ElM0FyZWx1X2Z3ZCUyMiklMEFkZWYlMjByZWx1X2Z3ZF9mYWtlKGlucHV0JTNBJTIwdG9yY2guVGVuc29yKSUyMC0lM0UlMjB0b3JjaC5UZW5zb3IlM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b3JjaC5lbXB0eV9saWtlKGlucHV0KQ==",highlighted:`<span class="hljs-meta">@torch.library.register_fake(<span class="hljs-params"><span class="hljs-string">"relu::relu_fwd"</span></span>)</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">relu_fwd_fake</span>(<span class="hljs-params"><span class="hljs-built_in">input</span>: torch.Tensor</span>) -> torch.Tensor: | |
| <span class="hljs-keyword">return</span> torch.empty_like(<span class="hljs-built_in">input</span>)`,lang:"python",wrap:!1}}),et=new T({props:{code:"ZnJvbSUyMC5fb3BzJTIwaW1wb3J0JTIwYWRkX29wX25hbWVzcGFjZV9wcmVmaXglMEElMEElNDB0b3JjaC5saWJyYXJ5LnJlZ2lzdGVyX2Zha2UoYWRkX29wX25hbWVzcGFjZV9wcmVmaXgoJTIycmVsdV9md2QlMjIpKSUwQWRlZiUyMHJlbHVfZndkX2Zha2UoaW5wdXQlM0ElMjB0b3JjaC5UZW5zb3IpJTIwLSUzRSUyMHRvcmNoLlRlbnNvciUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHRvcmNoLmVtcHR5X2xpa2UoaW5wdXQp",highlighted:`<span class="hljs-keyword">from</span> ._ops <span class="hljs-keyword">import</span> add_op_namespace_prefix | |
| <span class="hljs-meta">@torch.library.register_fake(<span class="hljs-params">add_op_namespace_prefix(<span class="hljs-params"><span class="hljs-string">"relu_fwd"</span></span>)</span>)</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">relu_fwd_fake</span>(<span class="hljs-params"><span class="hljs-built_in">input</span>: torch.Tensor</span>) -> torch.Tensor: | |
| <span class="hljs-keyword">return</span> torch.empty_like(<span class="hljs-built_in">input</span>)`,lang:"python",wrap:!1}}),nt=new T({props:{code:"JTQwc29tZV9pbmRpcmVjdGlvbl9mb3JfcmVnaXN0ZXJfZmFrZSglMjJyZWx1JTNBJTNBcmVsdV9md2QlMjIpJTBBZGVmJTIwcmVsdV9md2RfZmFrZShpbnB1dCUzQSUyMHRvcmNoLlRlbnNvciklMjAtJTNFJTIwdG9yY2guVGVuc29yJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9yY2guZW1wdHlfbGlrZShpbnB1dCk=",highlighted:`<span class="hljs-meta">@some_indirection_for_register_fake(<span class="hljs-params"><span class="hljs-string">"relu::relu_fwd"</span></span>)</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">relu_fwd_fake</span>(<span class="hljs-params"><span class="hljs-built_in">input</span>: torch.Tensor</span>) -> torch.Tensor: | |
| <span class="hljs-keyword">return</span> torch.empty_like(<span class="hljs-built_in">input</span>)`,lang:"python",wrap:!1}}),it=new f({props:{title:"Kernel tests",local:"kernel-tests",headingTag:"h2"}}),ot=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>(): | |
| ...`,lang:"python",wrap:!1}}),pt=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpLXRlc3Q=",highlighted:'$ nix run .<span class="hljs-comment">#ci-test</span>',lang:"bash",wrap:!1}}),dt=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpVGVzdHMudG9yY2gyMTAtY3h4MTEtY3B1LXg4Nl82NC1saW51eA==",highlighted:'$ nix run .<span class="hljs-comment">#ciTests.torch210-cxx11-cpu-x86_64-linux</span>',lang:"bash",wrap:!1}}),ut=new f({props:{title:"Kernel docs",local:"kernel-docs",headingTag:"h2"}}),yt=new Xi({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/writing-kernels.md"}}),{c(){y=o("meta"),kt=i(),bt=o("p"),gt=i(),p(M.$$.fragment),$t=i(),p(k.$$.fragment),wt=i(),p(g.$$.fragment),Ut=i(),$=o("p"),$.innerHTML=Cn,Jt=i(),w=o("ul"),w.innerHTML=vn,Ct=i(),U=o("p"),U.innerHTML=jn,vt=i(),J=o("ul"),J.innerHTML=xn,jt=i(),C=o("p"),C.innerHTML=_n,xt=i(),v=o("p"),v.innerHTML=Hn,_t=i(),b=o("blockquote"),b.innerHTML=In,Ht=i(),p(j.$$.fragment),It=i(),p(x.$$.fragment),Lt=i(),_=o("p"),_.innerHTML=Ln,Vt=i(),p(H.$$.fragment),Zt=i(),I=o("p"),I.textContent=Vn,Rt=i(),L=o("ol"),L.innerHTML=Zn,Bt=i(),V=o("p"),V.innerHTML=Rn,Nt=i(),p(Z.$$.fragment),Wt=i(),R=o("p"),R.innerHTML=Bn,Qt=i(),p(B.$$.fragment),Et=i(),N=o("p"),N.innerHTML=Nn,At=i(),W=o("p"),W.textContent=Wn,qt=i(),p(Q.$$.fragment),Gt=i(),E=o("p"),E.innerHTML=Qn,Xt=i(),p(A.$$.fragment),St=i(),q=o("p"),q.innerHTML=En,Pt=i(),G=o("p"),G.innerHTML=An,Ft=i(),p(X.$$.fragment),Yt=i(),S=o("p"),S.innerHTML=qn,Ot=i(),p(P.$$.fragment),zt=i(),F=o("p"),F.innerHTML=Gn,Dt=i(),p(Y.$$.fragment),Kt=i(),O=o("p"),O.textContent=Xn,el=i(),p(z.$$.fragment),tl=i(),D=o("p"),D.textContent=Sn,ll=i(),K=o("ul"),K.innerHTML=Pn,nl=i(),p(ee.$$.fragment),il=i(),te=o("p"),te.innerHTML=Fn,sl=i(),p(le.$$.fragment),ol=i(),ne=o("p"),ne.innerHTML=Yn,al=i(),p(ie.$$.fragment),rl=i(),se=o("ul"),se.innerHTML=On,pl=i(),p(oe.$$.fragment),cl=i(),ae=o("ul"),ae.innerHTML=zn,dl=i(),p(re.$$.fragment),ml=i(),pe=o("ul"),pe.innerHTML=Dn,ul=i(),p(ce.$$.fragment),hl=i(),de=o("p"),de.textContent=Kn,fl=i(),me=o("ul"),me.innerHTML=ei,Tl=i(),p(ue.$$.fragment),yl=i(),he=o("p"),he.textContent=ti,bl=i(),fe=o("ul"),fe.innerHTML=li,Ml=i(),p(Te.$$.fragment),kl=i(),ye=o("p"),ye.textContent=ni,gl=i(),be=o("ul"),be.innerHTML=ii,$l=i(),p(Me.$$.fragment),wl=i(),ke=o("p"),ke.innerHTML=si,Ul=i(),ge=o("p"),ge.innerHTML=oi,Jl=i(),$e=o("ul"),$e.innerHTML=ai,Cl=i(),p(we.$$.fragment),vl=i(),Ue=o("p"),Ue.innerHTML=ri,jl=i(),Je=o("p"),Je.textContent=pi,xl=i(),Ce=o("ul"),Ce.innerHTML=ci,_l=i(),ve=o("p"),ve.textContent=di,Hl=i(),p(je.$$.fragment),Il=i(),xe=o("ul"),xe.innerHTML=mi,Ll=i(),p(_e.$$.fragment),Vl=i(),He=o("ul"),He.innerHTML=ui,Zl=i(),p(Ie.$$.fragment),Rl=i(),Le=o("ul"),Le.innerHTML=hi,Bl=i(),p(Ve.$$.fragment),Nl=i(),Ze=o("ul"),Ze.innerHTML=fi,Wl=i(),p(Re.$$.fragment),Ql=i(),p(Be.$$.fragment),El=i(),Ne=o("p"),Ne.textContent=Ti,Al=i(),We=o("ul"),We.innerHTML=yi,ql=i(),Qe=o("p"),Qe.innerHTML=bi,Gl=i(),p(Ee.$$.fragment),Xl=i(),Ae=o("p"),Ae.innerHTML=Mi,Sl=i(),p(qe.$$.fragment),Pl=i(),Ge=o("p"),Ge.innerHTML=ki,Fl=i(),p(Xe.$$.fragment),Yl=i(),Se=o("p"),Se.innerHTML=gi,Ol=i(),Pe=o("p"),Pe.innerHTML=$i,zl=i(),p(Fe.$$.fragment),Dl=i(),p(Ye.$$.fragment),Kl=i(),Oe=o("p"),Oe.innerHTML=wi,en=i(),ze=o("p"),ze.innerHTML=Ui,tn=i(),p(De.$$.fragment),ln=i(),Ke=o("p"),Ke.textContent=Ji,nn=i(),p(et.$$.fragment),sn=i(),tt=o("p"),tt.innerHTML=Ci,on=i(),lt=o("p"),lt.innerHTML=vi,an=i(),p(nt.$$.fragment),rn=i(),p(it.$$.fragment),pn=i(),st=o("p"),st.innerHTML=ji,cn=i(),p(ot.$$.fragment),dn=i(),at=o("p"),at.textContent=xi,mn=i(),rt=o("p"),rt.textContent=_i,un=i(),p(pt.$$.fragment),hn=i(),ct=o("p"),ct.innerHTML=Hi,fn=i(),p(dt.$$.fragment),Tn=i(),mt=o("p"),mt.innerHTML=Ii,yn=i(),p(ut.$$.fragment),bn=i(),ht=o("p"),ht.innerHTML=Li,Mn=i(),ft=o("p"),ft.innerHTML=Vi,kn=i(),Tt=o("p"),Tt.innerHTML=Zi,gn=i(),p(yt.$$.fragment),$n=i(),Mt=o("p"),this.h()},l(e){const t=Ai("svelte-u9bgzb",document.head);y=a(t,"META",{name:!0,content:!0}),t.forEach(l),kt=s(e),bt=a(e,"P",{}),Ri(bt).forEach(l),gt=s(e),c(M.$$.fragment,e),$t=s(e),c(k.$$.fragment,e),wt=s(e),c(g.$$.fragment,e),Ut=s(e),$=a(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1i1c9ni"&&($.innerHTML=Cn),Jt=s(e),w=a(e,"UL",{"data-svelte-h":!0}),r(w)!=="svelte-1odnsz3"&&(w.innerHTML=vn),Ct=s(e),U=a(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1gp9ycj"&&(U.innerHTML=jn),vt=s(e),J=a(e,"UL",{"data-svelte-h":!0}),r(J)!=="svelte-ysrhph"&&(J.innerHTML=xn),jt=s(e),C=a(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-vy7wcb"&&(C.innerHTML=_n),xt=s(e),v=a(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-o9ssdv"&&(v.innerHTML=Hn),_t=s(e),b=a(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(b)!=="svelte-43d87d"&&(b.innerHTML=In),Ht=s(e),c(j.$$.fragment,e),It=s(e),c(x.$$.fragment,e),Lt=s(e),_=a(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-96m8sj"&&(_.innerHTML=Ln),Vt=s(e),c(H.$$.fragment,e),Zt=s(e),I=a(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-1b4vj4e"&&(I.textContent=Vn),Rt=s(e),L=a(e,"OL",{"data-svelte-h":!0}),r(L)!=="svelte-3arzgs"&&(L.innerHTML=Zn),Bt=s(e),V=a(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1ihjqjm"&&(V.innerHTML=Rn),Nt=s(e),c(Z.$$.fragment,e),Wt=s(e),R=a(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-1cac215"&&(R.innerHTML=Bn),Qt=s(e),c(B.$$.fragment,e),Et=s(e),N=a(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-4lye9k"&&(N.innerHTML=Nn),At=s(e),W=a(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-g5i707"&&(W.textContent=Wn),qt=s(e),c(Q.$$.fragment,e),Gt=s(e),E=a(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-cn9mkc"&&(E.innerHTML=Qn),Xt=s(e),c(A.$$.fragment,e),St=s(e),q=a(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1prqyz3"&&(q.innerHTML=En),Pt=s(e),G=a(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1exh4w8"&&(G.innerHTML=An),Ft=s(e),c(X.$$.fragment,e),Yt=s(e),S=a(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-1poutmy"&&(S.innerHTML=qn),Ot=s(e),c(P.$$.fragment,e),zt=s(e),F=a(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-s84xza"&&(F.innerHTML=Gn),Dt=s(e),c(Y.$$.fragment,e),Kt=s(e),O=a(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-6oo725"&&(O.textContent=Xn),el=s(e),c(z.$$.fragment,e),tl=s(e),D=a(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-1lqdx4"&&(D.textContent=Sn),ll=s(e),K=a(e,"UL",{"data-svelte-h":!0}),r(K)!=="svelte-c8vtob"&&(K.innerHTML=Pn),nl=s(e),c(ee.$$.fragment,e),il=s(e),te=a(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-1hgp1cr"&&(te.innerHTML=Fn),sl=s(e),c(le.$$.fragment,e),ol=s(e),ne=a(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-pgruc9"&&(ne.innerHTML=Yn),al=s(e),c(ie.$$.fragment,e),rl=s(e),se=a(e,"UL",{"data-svelte-h":!0}),r(se)!=="svelte-gz30jb"&&(se.innerHTML=On),pl=s(e),c(oe.$$.fragment,e),cl=s(e),ae=a(e,"UL",{"data-svelte-h":!0}),r(ae)!=="svelte-12rq95i"&&(ae.innerHTML=zn),dl=s(e),c(re.$$.fragment,e),ml=s(e),pe=a(e,"UL",{"data-svelte-h":!0}),r(pe)!=="svelte-1fzn2"&&(pe.innerHTML=Dn),ul=s(e),c(ce.$$.fragment,e),hl=s(e),de=a(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-gxdqgh"&&(de.textContent=Kn),fl=s(e),me=a(e,"UL",{"data-svelte-h":!0}),r(me)!=="svelte-124jabx"&&(me.innerHTML=ei),Tl=s(e),c(ue.$$.fragment,e),yl=s(e),he=a(e,"P",{"data-svelte-h":!0}),r(he)!=="svelte-kgzfey"&&(he.textContent=ti),bl=s(e),fe=a(e,"UL",{"data-svelte-h":!0}),r(fe)!=="svelte-7mmcol"&&(fe.innerHTML=li),Ml=s(e),c(Te.$$.fragment,e),kl=s(e),ye=a(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-o8lm5s"&&(ye.textContent=ni),gl=s(e),be=a(e,"UL",{"data-svelte-h":!0}),r(be)!=="svelte-1xjqtde"&&(be.innerHTML=ii),$l=s(e),c(Me.$$.fragment,e),wl=s(e),ke=a(e,"P",{"data-svelte-h":!0}),r(ke)!=="svelte-zn9bnz"&&(ke.innerHTML=si),Ul=s(e),ge=a(e,"P",{"data-svelte-h":!0}),r(ge)!=="svelte-1fs9ps3"&&(ge.innerHTML=oi),Jl=s(e),$e=a(e,"UL",{"data-svelte-h":!0}),r($e)!=="svelte-1oz6tus"&&($e.innerHTML=ai),Cl=s(e),c(we.$$.fragment,e),vl=s(e),Ue=a(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-1weg0gu"&&(Ue.innerHTML=ri),jl=s(e),Je=a(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-1al5myg"&&(Je.textContent=pi),xl=s(e),Ce=a(e,"UL",{"data-svelte-h":!0}),r(Ce)!=="svelte-1fbzu1m"&&(Ce.innerHTML=ci),_l=s(e),ve=a(e,"P",{"data-svelte-h":!0}),r(ve)!=="svelte-1mf578x"&&(ve.textContent=di),Hl=s(e),c(je.$$.fragment,e),Il=s(e),xe=a(e,"UL",{"data-svelte-h":!0}),r(xe)!=="svelte-3vtlb2"&&(xe.innerHTML=mi),Ll=s(e),c(_e.$$.fragment,e),Vl=s(e),He=a(e,"UL",{"data-svelte-h":!0}),r(He)!=="svelte-mx7mxt"&&(He.innerHTML=ui),Zl=s(e),c(Ie.$$.fragment,e),Rl=s(e),Le=a(e,"UL",{"data-svelte-h":!0}),r(Le)!=="svelte-1u3m3l7"&&(Le.innerHTML=hi),Bl=s(e),c(Ve.$$.fragment,e),Nl=s(e),Ze=a(e,"UL",{"data-svelte-h":!0}),r(Ze)!=="svelte-10okur"&&(Ze.innerHTML=fi),Wl=s(e),c(Re.$$.fragment,e),Ql=s(e),c(Be.$$.fragment,e),El=s(e),Ne=a(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-r7rot5"&&(Ne.textContent=Ti),Al=s(e),We=a(e,"UL",{"data-svelte-h":!0}),r(We)!=="svelte-poxr41"&&(We.innerHTML=yi),ql=s(e),Qe=a(e,"P",{"data-svelte-h":!0}),r(Qe)!=="svelte-1ikzb58"&&(Qe.innerHTML=bi),Gl=s(e),c(Ee.$$.fragment,e),Xl=s(e),Ae=a(e,"P",{"data-svelte-h":!0}),r(Ae)!=="svelte-5ja9lk"&&(Ae.innerHTML=Mi),Sl=s(e),c(qe.$$.fragment,e),Pl=s(e),Ge=a(e,"P",{"data-svelte-h":!0}),r(Ge)!=="svelte-ssih46"&&(Ge.innerHTML=ki),Fl=s(e),c(Xe.$$.fragment,e),Yl=s(e),Se=a(e,"P",{"data-svelte-h":!0}),r(Se)!=="svelte-1y8rjsx"&&(Se.innerHTML=gi),Ol=s(e),Pe=a(e,"P",{"data-svelte-h":!0}),r(Pe)!=="svelte-a3yu8e"&&(Pe.innerHTML=$i),zl=s(e),c(Fe.$$.fragment,e),Dl=s(e),c(Ye.$$.fragment,e),Kl=s(e),Oe=a(e,"P",{"data-svelte-h":!0}),r(Oe)!=="svelte-xosw3t"&&(Oe.innerHTML=wi),en=s(e),ze=a(e,"P",{"data-svelte-h":!0}),r(ze)!=="svelte-a5yx0v"&&(ze.innerHTML=Ui),tn=s(e),c(De.$$.fragment,e),ln=s(e),Ke=a(e,"P",{"data-svelte-h":!0}),r(Ke)!=="svelte-9b7ddb"&&(Ke.textContent=Ji),nn=s(e),c(et.$$.fragment,e),sn=s(e),tt=a(e,"P",{"data-svelte-h":!0}),r(tt)!=="svelte-4caz4s"&&(tt.innerHTML=Ci),on=s(e),lt=a(e,"P",{"data-svelte-h":!0}),r(lt)!=="svelte-hkktty"&&(lt.innerHTML=vi),an=s(e),c(nt.$$.fragment,e),rn=s(e),c(it.$$.fragment,e),pn=s(e),st=a(e,"P",{"data-svelte-h":!0}),r(st)!=="svelte-q979am"&&(st.innerHTML=ji),cn=s(e),c(ot.$$.fragment,e),dn=s(e),at=a(e,"P",{"data-svelte-h":!0}),r(at)!=="svelte-1uzdod8"&&(at.textContent=xi),mn=s(e),rt=a(e,"P",{"data-svelte-h":!0}),r(rt)!=="svelte-s01sgi"&&(rt.textContent=_i),un=s(e),c(pt.$$.fragment,e),hn=s(e),ct=a(e,"P",{"data-svelte-h":!0}),r(ct)!=="svelte-1ucbtrx"&&(ct.innerHTML=Hi),fn=s(e),c(dt.$$.fragment,e),Tn=s(e),mt=a(e,"P",{"data-svelte-h":!0}),r(mt)!=="svelte-gcopz4"&&(mt.innerHTML=Ii),yn=s(e),c(ut.$$.fragment,e),bn=s(e),ht=a(e,"P",{"data-svelte-h":!0}),r(ht)!=="svelte-11q3n4g"&&(ht.innerHTML=Li),Mn=s(e),ft=a(e,"P",{"data-svelte-h":!0}),r(ft)!=="svelte-zjr5ot"&&(ft.innerHTML=Vi),kn=s(e),Tt=a(e,"P",{"data-svelte-h":!0}),r(Tt)!=="svelte-rt0n0n"&&(Tt.innerHTML=Zi),gn=s(e),c(yt.$$.fragment,e),$n=s(e),Mt=a(e,"P",{}),Ri(Mt).forEach(l),this.h()},h(){Un(y,"name","hf:doc:metadata"),Un(y,"content",Pi),Un(b,"class","tip")},m(e,t){qi(document.head,y),n(e,kt,t),n(e,bt,t),n(e,gt,t),d(M,e,t),n(e,$t,t),d(k,e,t),n(e,wt,t),d(g,e,t),n(e,Ut,t),n(e,$,t),n(e,Jt,t),n(e,w,t),n(e,Ct,t),n(e,U,t),n(e,vt,t),n(e,J,t),n(e,jt,t),n(e,C,t),n(e,xt,t),n(e,v,t),n(e,_t,t),n(e,b,t),n(e,Ht,t),d(j,e,t),n(e,It,t),d(x,e,t),n(e,Lt,t),n(e,_,t),n(e,Vt,t),d(H,e,t),n(e,Zt,t),n(e,I,t),n(e,Rt,t),n(e,L,t),n(e,Bt,t),n(e,V,t),n(e,Nt,t),d(Z,e,t),n(e,Wt,t),n(e,R,t),n(e,Qt,t),d(B,e,t),n(e,Et,t),n(e,N,t),n(e,At,t),n(e,W,t),n(e,qt,t),d(Q,e,t),n(e,Gt,t),n(e,E,t),n(e,Xt,t),d(A,e,t),n(e,St,t),n(e,q,t),n(e,Pt,t),n(e,G,t),n(e,Ft,t),d(X,e,t),n(e,Yt,t),n(e,S,t),n(e,Ot,t),d(P,e,t),n(e,zt,t),n(e,F,t),n(e,Dt,t),d(Y,e,t),n(e,Kt,t),n(e,O,t),n(e,el,t),d(z,e,t),n(e,tl,t),n(e,D,t),n(e,ll,t),n(e,K,t),n(e,nl,t),d(ee,e,t),n(e,il,t),n(e,te,t),n(e,sl,t),d(le,e,t),n(e,ol,t),n(e,ne,t),n(e,al,t),d(ie,e,t),n(e,rl,t),n(e,se,t),n(e,pl,t),d(oe,e,t),n(e,cl,t),n(e,ae,t),n(e,dl,t),d(re,e,t),n(e,ml,t),n(e,pe,t),n(e,ul,t),d(ce,e,t),n(e,hl,t),n(e,de,t),n(e,fl,t),n(e,me,t),n(e,Tl,t),d(ue,e,t),n(e,yl,t),n(e,he,t),n(e,bl,t),n(e,fe,t),n(e,Ml,t),d(Te,e,t),n(e,kl,t),n(e,ye,t),n(e,gl,t),n(e,be,t),n(e,$l,t),d(Me,e,t),n(e,wl,t),n(e,ke,t),n(e,Ul,t),n(e,ge,t),n(e,Jl,t),n(e,$e,t),n(e,Cl,t),d(we,e,t),n(e,vl,t),n(e,Ue,t),n(e,jl,t),n(e,Je,t),n(e,xl,t),n(e,Ce,t),n(e,_l,t),n(e,ve,t),n(e,Hl,t),d(je,e,t),n(e,Il,t),n(e,xe,t),n(e,Ll,t),d(_e,e,t),n(e,Vl,t),n(e,He,t),n(e,Zl,t),d(Ie,e,t),n(e,Rl,t),n(e,Le,t),n(e,Bl,t),d(Ve,e,t),n(e,Nl,t),n(e,Ze,t),n(e,Wl,t),d(Re,e,t),n(e,Ql,t),d(Be,e,t),n(e,El,t),n(e,Ne,t),n(e,Al,t),n(e,We,t),n(e,ql,t),n(e,Qe,t),n(e,Gl,t),d(Ee,e,t),n(e,Xl,t),n(e,Ae,t),n(e,Sl,t),d(qe,e,t),n(e,Pl,t),n(e,Ge,t),n(e,Fl,t),d(Xe,e,t),n(e,Yl,t),n(e,Se,t),n(e,Ol,t),n(e,Pe,t),n(e,zl,t),d(Fe,e,t),n(e,Dl,t),d(Ye,e,t),n(e,Kl,t),n(e,Oe,t),n(e,en,t),n(e,ze,t),n(e,tn,t),d(De,e,t),n(e,ln,t),n(e,Ke,t),n(e,nn,t),d(et,e,t),n(e,sn,t),n(e,tt,t),n(e,on,t),n(e,lt,t),n(e,an,t),d(nt,e,t),n(e,rn,t),d(it,e,t),n(e,pn,t),n(e,st,t),n(e,cn,t),d(ot,e,t),n(e,dn,t),n(e,at,t),n(e,mn,t),n(e,rt,t),n(e,un,t),d(pt,e,t),n(e,hn,t),n(e,ct,t),n(e,fn,t),d(dt,e,t),n(e,Tn,t),n(e,mt,t),n(e,yn,t),d(ut,e,t),n(e,bn,t),n(e,ht,t),n(e,Mn,t),n(e,ft,t),n(e,kn,t),n(e,Tt,t),n(e,gn,t),d(yt,e,t),n(e,$n,t),n(e,Mt,t),wn=!0},p:Ni,i(e){wn||(m(M.$$.fragment,e),m(k.$$.fragment,e),m(g.$$.fragment,e),m(j.$$.fragment,e),m(x.$$.fragment,e),m(H.$$.fragment,e),m(Z.$$.fragment,e),m(B.$$.fragment,e),m(Q.$$.fragment,e),m(A.$$.fragment,e),m(X.$$.fragment,e),m(P.$$.fragment,e),m(Y.$$.fragment,e),m(z.$$.fragment,e),m(ee.$$.fragment,e),m(le.$$.fragment,e),m(ie.$$.fragment,e),m(oe.$$.fragment,e),m(re.$$.fragment,e),m(ce.$$.fragment,e),m(ue.$$.fragment,e),m(Te.$$.fragment,e),m(Me.$$.fragment,e),m(we.$$.fragment,e),m(je.$$.fragment,e),m(_e.$$.fragment,e),m(Ie.$$.fragment,e),m(Ve.$$.fragment,e),m(Re.$$.fragment,e),m(Be.$$.fragment,e),m(Ee.$$.fragment,e),m(qe.$$.fragment,e),m(Xe.$$.fragment,e),m(Fe.$$.fragment,e),m(Ye.$$.fragment,e),m(De.$$.fragment,e),m(et.$$.fragment,e),m(nt.$$.fragment,e),m(it.$$.fragment,e),m(ot.$$.fragment,e),m(pt.$$.fragment,e),m(dt.$$.fragment,e),m(ut.$$.fragment,e),m(yt.$$.fragment,e),wn=!0)},o(e){u(M.$$.fragment,e),u(k.$$.fragment,e),u(g.$$.fragment,e),u(j.$$.fragment,e),u(x.$$.fragment,e),u(H.$$.fragment,e),u(Z.$$.fragment,e),u(B.$$.fragment,e),u(Q.$$.fragment,e),u(A.$$.fragment,e),u(X.$$.fragment,e),u(P.$$.fragment,e),u(Y.$$.fragment,e),u(z.$$.fragment,e),u(ee.$$.fragment,e),u(le.$$.fragment,e),u(ie.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),u(ce.$$.fragment,e),u(ue.$$.fragment,e),u(Te.$$.fragment,e),u(Me.$$.fragment,e),u(we.$$.fragment,e),u(je.$$.fragment,e),u(_e.$$.fragment,e),u(Ie.$$.fragment,e),u(Ve.$$.fragment,e),u(Re.$$.fragment,e),u(Be.$$.fragment,e),u(Ee.$$.fragment,e),u(qe.$$.fragment,e),u(Xe.$$.fragment,e),u(Fe.$$.fragment,e),u(Ye.$$.fragment,e),u(De.$$.fragment,e),u(et.$$.fragment,e),u(nt.$$.fragment,e),u(it.$$.fragment,e),u(ot.$$.fragment,e),u(pt.$$.fragment,e),u(dt.$$.fragment,e),u(ut.$$.fragment,e),u(yt.$$.fragment,e),wn=!1},d(e){e&&(l(kt),l(bt),l(gt),l($t),l(wt),l(Ut),l($),l(Jt),l(w),l(Ct),l(U),l(vt),l(J),l(jt),l(C),l(xt),l(v),l(_t),l(b),l(Ht),l(It),l(Lt),l(_),l(Vt),l(Zt),l(I),l(Rt),l(L),l(Bt),l(V),l(Nt),l(Wt),l(R),l(Qt),l(Et),l(N),l(At),l(W),l(qt),l(Gt),l(E),l(Xt),l(St),l(q),l(Pt),l(G),l(Ft),l(Yt),l(S),l(Ot),l(zt),l(F),l(Dt),l(Kt),l(O),l(el),l(tl),l(D),l(ll),l(K),l(nl),l(il),l(te),l(sl),l(ol),l(ne),l(al),l(rl),l(se),l(pl),l(cl),l(ae),l(dl),l(ml),l(pe),l(ul),l(hl),l(de),l(fl),l(me),l(Tl),l(yl),l(he),l(bl),l(fe),l(Ml),l(kl),l(ye),l(gl),l(be),l($l),l(wl),l(ke),l(Ul),l(ge),l(Jl),l($e),l(Cl),l(vl),l(Ue),l(jl),l(Je),l(xl),l(Ce),l(_l),l(ve),l(Hl),l(Il),l(xe),l(Ll),l(Vl),l(He),l(Zl),l(Rl),l(Le),l(Bl),l(Nl),l(Ze),l(Wl),l(Ql),l(El),l(Ne),l(Al),l(We),l(ql),l(Qe),l(Gl),l(Xl),l(Ae),l(Sl),l(Pl),l(Ge),l(Fl),l(Yl),l(Se),l(Ol),l(Pe),l(zl),l(Dl),l(Kl),l(Oe),l(en),l(ze),l(tn),l(ln),l(Ke),l(nn),l(sn),l(tt),l(on),l(lt),l(an),l(rn),l(pn),l(st),l(cn),l(dn),l(at),l(mn),l(rt),l(un),l(hn),l(ct),l(fn),l(Tn),l(mt),l(yn),l(bn),l(ht),l(Mn),l(ft),l(kn),l(Tt),l(gn),l($n),l(Mt)),l(y),h(M,e),h(k,e),h(g,e),h(j,e),h(x,e),h(H,e),h(Z,e),h(B,e),h(Q,e),h(A,e),h(X,e),h(P,e),h(Y,e),h(z,e),h(ee,e),h(le,e),h(ie,e),h(oe,e),h(re,e),h(ce,e),h(ue,e),h(Te,e),h(Me,e),h(we,e),h(je,e),h(_e,e),h(Ie,e),h(Ve,e),h(Re,e),h(Be,e),h(Ee,e),h(qe,e),h(Xe,e),h(Fe,e),h(Ye,e),h(De,e),h(et,e),h(nt,e),h(it,e),h(ot,e),h(pt,e),h(dt,e),h(ut,e),h(yt,e)}}}const Pi='{"title":"Write kernels","local":"write-kernels","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":"Framework sections","local":"framework-sections","sections":[],"depth":3},{"title":"torch","local":"torch","sections":[],"depth":3},{"title":"tvm-ffi","local":"tvm-ffi","sections":[],"depth":3},{"title":"torch-noarch","local":"torch-noarch","sections":[],"depth":3},{"title":"kernel.<name>","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},{"title":"cpu","local":"cpu","sections":[],"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":"Registering Torch operators","local":"registering-torch-operators","sections":[],"depth":2},{"title":"Kernel tests","local":"kernel-tests","sections":[],"depth":2},{"title":"Kernel docs","local":"kernel-docs","sections":[],"depth":2}],"depth":1}';function Fi(Jn){return Wi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ki extends Qi{constructor(y){super(),Ei(this,y,Fi,Si,Bi,{})}}export{Ki as component}; | |
Xet Storage Details
- Size:
- 50.8 kB
- Xet hash:
- 9d0ddcd78d5ddbfa246653adc5999910841381af660f17ed62ff445a406e143b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.