Buckets:
| import{s as oi,n as ri,o as pi}from"../chunks/scheduler.f3b1e791.js";import{S as ci,i as di,e as a,s as i,c as p,h as mi,a as o,d as l,b as s,f as si,g as c,j as r,k as ai,l as ui,m as n,n as d,t as m,o as u,p as h}from"../chunks/index.023a9934.js";import{C as hi}from"../chunks/CopyLLMTxtMenu.5f3b0c01.js";import{C as T}from"../chunks/CodeBlock.fbf79025.js";import{H as f,E as fi}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3cccf7b6.js";function Ti(tn){let y,pt,ot,ct,b,dt,M,mt,k,ut,g,ln=`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:`,ht,w,nn=`<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>`,ft,$,sn=`<code>kernel-builder</code> is a set of tools that can build conforming kernels. It | |
| takes care of:`,Tt,U,an=`<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>`,yt,J,on=`<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.`,bt,C,rn=`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.`,Mt,j,kt,v,gt,x,pn=`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:`,wt,I,$t,_,cn="This will:",Ut,H,dn=`<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>`,Jt,L,mn="To update <code>kernel-builder</code> later:",Ct,Z,jt,V,un=`For a step-by-step breakdown of what the script does, see | |
| <a href="nix">Using the kernel builder with Nix</a>.`,vt,N,xt,R,hn=`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.`,It,B,fn=`If you use a different provider, the Terraform bridges should be | |
| similar and straightforward to modify.`,_t,W,Ht,Q,Tn=`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:`,Lt,E,Zt,A,yn=`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.`,Vt,X,bn=`By default, the <code>init</code> subcommand creates a CUDA kernel. You can specify | |
| another backend with the <code>--backends</code> option:`,Nt,S,Rt,G,Mn=`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>:`,Bt,P,Wt,q,kn=`Finally, if you want to create a kernel for all supported backends, you | |
| can use <code>--backends all</code>.`,Qt,Y,Et,F,gn="Kernel projects follow this general directory layout:",At,O,Xt,z,wn="In this example we can find:",St,D,$n=`<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>`,Gt,K,Pt,ee,Un=`<code>build.toml</code> tells <code>kernel-builder</code> what to build and how. It looks as | |
| follows for the <code>mykernel</code> kernel:`,qt,te,Yt,le,Jn="The following sections enumerate all supported options for <code>build.toml</code>.",Ft,ne,Ot,ie,Cn=`<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>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>`,zt,se,Dt,ae,jn=`<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>`,Kt,oe,el,re,vn=`<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>`,tl,pe,ll,ce,xn=`This section describes the Torch extension. In the future, there may be | |
| similar sections for other frameworks. This section has the following | |
| options:`,nl,de,In=`<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>`,il,me,sl,ue,_n=`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.`,al,he,Hn="The following options can be set for a kernel:",ol,fe,Ln=`<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>`,rl,Te,Zn=`Besides these shared options, the following backend-specific options | |
| are available:`,pl,ye,cl,be,Vn=`<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>`,dl,Me,ml,ke,Nn=`<li><code>rocm-archs</code>: a list of ROCm architectures that the kernel should be | |
| compiled for.</li>`,ul,ge,hl,we,Rn=`<li><code>sycl-flags</code>: a list of additional flags to be passed to the SYCL | |
| compiler.</li>`,fl,$e,Tl,Ue,Bn=`<li><code>cxx-flags</code>: a list of additional flags to be passed to the C++ | |
| compiler.</li>`,yl,Je,bl,Ce,Ml,je,Wn="Torch bindings are defined in C++, kernels commonly use two files:",kl,ve,Qn="<li><code>torch_binding.h</code> containing function declarations.</li> <li><code>torch_binding.cpp</code> registering the functions as Torch ops.</li>",gl,xe,En=`For instance, the <code>mykernel</code> kernel discussed above has the following | |
| declaration in <code>torch_binding.h</code>:`,wl,Ie,$l,_e,An="This function is then registered as a Torch op in <code>torch_binding.cpp</code>:",Ul,He,Jl,Le,Xn=`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.`,Cl,Ze,jl,Ve,Sn=`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>.`,vl,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:`,xl,Re,Il,Be,_l,We,Pn=`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.`,Hl,Qe,qn=`You can use the <code>add_op_namespace_prefix</code> to prefix an op name with the | |
| correct prefix. So for instance, replace`,Ll,Ee,Zl,Ae,Yn="by",Vl,Xe,Nl,Se,Fn="As mentioned in the above, the <code>_ops</code> module is generated by kernel-builder.",Rl,Ge,On=`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:`,Bl,Pe,Wl,qe,Ql,Ye,zn=`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:`,El,Fe,Al,Oe,Dn=`We recommend that you to pick tests that together would catch most error | |
| cases while running within 60 seconds.`,Xl,ze,Kn="You can run the tests (e.g. in CI) using:",Sl,De,Gl,Ke,ei=`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:`,Pl,et,ql,tt,ti=`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>.`,Yl,lt,Fl,nt,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.`,Ol,it,ni=`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.`,zl,st,ii=`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.`,Dl,at,Kl,rt,en;return b=new hi({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),M=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"}}),j=new f({props:{title:"Setting up environment",local:"setting-up-environment",headingTag:"h2"}}),v=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",lang:"bash",wrap:!1}}),Z=new T({props:{code:"bml4JTIwcHJvZmlsZSUyMHVwZ3JhZGUlMjAtLWFsbA==",highlighted:"nix profile upgrade --all",lang:"bash",wrap:!1}}),N=new f({props:{title:"Cloud environment",local:"cloud-environment",headingTag:"h3"}}),W=new f({props:{title:"Starting a new kernel",local:"starting-a-new-kernel",headingTag:"h2"}}),E=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}}),S=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"}}),O=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}}),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">"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}}),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"}}),Me=new f({props:{title:"rocm",local:"rocm",headingTag:"h4"}}),ge=new f({props:{title:"xpu",local:"xpu",headingTag:"h4"}}),$e=new f({props:{title:"cpu",local:"cpu",headingTag:"h3"}}),Je=new f({props:{title:"Torch bindings",local:"torch-bindings",headingTag:"h2"}}),Ce=new f({props:{title:"Defining bindings",local:"defining-bindings",headingTag:"h3"}}),Ie=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}}),He=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}}),Ze=new f({props:{title:"Using kernel functions from Python",local:"using-kernel-functions-from-python",headingTag:"h2"}}),Re=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}}),Be=new f({props:{title:"Registering Torch operators",local:"registering-torch-operators",headingTag:"h2"}}),Ee=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}}),Xe=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}}),Pe=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}}),qe=new f({props:{title:"Kernel tests",local:"kernel-tests",headingTag:"h2"}}),Fe=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}}),De=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpLXRlc3Q=",highlighted:'$ nix run .<span class="hljs-comment">#ci-test</span>',lang:"bash",wrap:!1}}),et=new T({props:{code:"JTI0JTIwbml4JTIwcnVuJTIwLiUyM2NpVGVzdHMudG9yY2gyMTAtY3h4MTEtY3B1LXg4Nl82NC1saW51eA==",highlighted:'$ nix run .<span class="hljs-comment">#ciTests.torch210-cxx11-cpu-x86_64-linux</span>',lang:"bash",wrap:!1}}),lt=new f({props:{title:"Kernel docs",local:"kernel-docs",headingTag:"h2"}}),at=new fi({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/builder/writing-kernels.md"}}),{c(){y=a("meta"),pt=i(),ot=a("p"),ct=i(),p(b.$$.fragment),dt=i(),p(M.$$.fragment),mt=i(),p(k.$$.fragment),ut=i(),g=a("p"),g.innerHTML=ln,ht=i(),w=a("ul"),w.innerHTML=nn,ft=i(),$=a("p"),$.innerHTML=sn,Tt=i(),U=a("ul"),U.innerHTML=an,yt=i(),J=a("p"),J.innerHTML=on,bt=i(),C=a("p"),C.innerHTML=rn,Mt=i(),p(j.$$.fragment),kt=i(),p(v.$$.fragment),gt=i(),x=a("p"),x.innerHTML=pn,wt=i(),p(I.$$.fragment),$t=i(),_=a("p"),_.textContent=cn,Ut=i(),H=a("ol"),H.innerHTML=dn,Jt=i(),L=a("p"),L.innerHTML=mn,Ct=i(),p(Z.$$.fragment),jt=i(),V=a("p"),V.innerHTML=un,vt=i(),p(N.$$.fragment),xt=i(),R=a("p"),R.innerHTML=hn,It=i(),B=a("p"),B.textContent=fn,_t=i(),p(W.$$.fragment),Ht=i(),Q=a("p"),Q.innerHTML=Tn,Lt=i(),p(E.$$.fragment),Zt=i(),A=a("p"),A.innerHTML=yn,Vt=i(),X=a("p"),X.innerHTML=bn,Nt=i(),p(S.$$.fragment),Rt=i(),G=a("p"),G.innerHTML=Mn,Bt=i(),p(P.$$.fragment),Wt=i(),q=a("p"),q.innerHTML=kn,Qt=i(),p(Y.$$.fragment),Et=i(),F=a("p"),F.textContent=gn,At=i(),p(O.$$.fragment),Xt=i(),z=a("p"),z.textContent=wn,St=i(),D=a("ul"),D.innerHTML=$n,Gt=i(),p(K.$$.fragment),Pt=i(),ee=a("p"),ee.innerHTML=Un,qt=i(),p(te.$$.fragment),Yt=i(),le=a("p"),le.innerHTML=Jn,Ft=i(),p(ne.$$.fragment),Ot=i(),ie=a("ul"),ie.innerHTML=Cn,zt=i(),p(se.$$.fragment),Dt=i(),ae=a("ul"),ae.innerHTML=jn,Kt=i(),p(oe.$$.fragment),el=i(),re=a("ul"),re.innerHTML=vn,tl=i(),p(pe.$$.fragment),ll=i(),ce=a("p"),ce.textContent=xn,nl=i(),de=a("ul"),de.innerHTML=In,il=i(),p(me.$$.fragment),sl=i(),ue=a("p"),ue.innerHTML=_n,al=i(),he=a("p"),he.textContent=Hn,ol=i(),fe=a("ul"),fe.innerHTML=Ln,rl=i(),Te=a("p"),Te.textContent=Zn,pl=i(),p(ye.$$.fragment),cl=i(),be=a("ul"),be.innerHTML=Vn,dl=i(),p(Me.$$.fragment),ml=i(),ke=a("ul"),ke.innerHTML=Nn,ul=i(),p(ge.$$.fragment),hl=i(),we=a("ul"),we.innerHTML=Rn,fl=i(),p($e.$$.fragment),Tl=i(),Ue=a("ul"),Ue.innerHTML=Bn,yl=i(),p(Je.$$.fragment),bl=i(),p(Ce.$$.fragment),Ml=i(),je=a("p"),je.textContent=Wn,kl=i(),ve=a("ul"),ve.innerHTML=Qn,gl=i(),xe=a("p"),xe.innerHTML=En,wl=i(),p(Ie.$$.fragment),$l=i(),_e=a("p"),_e.innerHTML=An,Ul=i(),p(He.$$.fragment),Jl=i(),Le=a("p"),Le.innerHTML=Xn,Cl=i(),p(Ze.$$.fragment),jl=i(),Ve=a("p"),Ve.innerHTML=Sn,vl=i(),Ne=a("p"),Ne.innerHTML=Gn,xl=i(),p(Re.$$.fragment),Il=i(),p(Be.$$.fragment),_l=i(),We=a("p"),We.innerHTML=Pn,Hl=i(),Qe=a("p"),Qe.innerHTML=qn,Ll=i(),p(Ee.$$.fragment),Zl=i(),Ae=a("p"),Ae.textContent=Yn,Vl=i(),p(Xe.$$.fragment),Nl=i(),Se=a("p"),Se.innerHTML=Fn,Rl=i(),Ge=a("p"),Ge.innerHTML=On,Bl=i(),p(Pe.$$.fragment),Wl=i(),p(qe.$$.fragment),Ql=i(),Ye=a("p"),Ye.innerHTML=zn,El=i(),p(Fe.$$.fragment),Al=i(),Oe=a("p"),Oe.textContent=Dn,Xl=i(),ze=a("p"),ze.textContent=Kn,Sl=i(),p(De.$$.fragment),Gl=i(),Ke=a("p"),Ke.innerHTML=ei,Pl=i(),p(et.$$.fragment),ql=i(),tt=a("p"),tt.innerHTML=ti,Yl=i(),p(lt.$$.fragment),Fl=i(),nt=a("p"),nt.innerHTML=li,Ol=i(),it=a("p"),it.innerHTML=ni,zl=i(),st=a("p"),st.innerHTML=ii,Dl=i(),p(at.$$.fragment),Kl=i(),rt=a("p"),this.h()},l(e){const t=mi("svelte-u9bgzb",document.head);y=o(t,"META",{name:!0,content:!0}),t.forEach(l),pt=s(e),ot=o(e,"P",{}),si(ot).forEach(l),ct=s(e),c(b.$$.fragment,e),dt=s(e),c(M.$$.fragment,e),mt=s(e),c(k.$$.fragment,e),ut=s(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-1i1c9ni"&&(g.innerHTML=ln),ht=s(e),w=o(e,"UL",{"data-svelte-h":!0}),r(w)!=="svelte-1odnsz3"&&(w.innerHTML=nn),ft=s(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1gp9ycj"&&($.innerHTML=sn),Tt=s(e),U=o(e,"UL",{"data-svelte-h":!0}),r(U)!=="svelte-ysrhph"&&(U.innerHTML=an),yt=s(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-vy7wcb"&&(J.innerHTML=on),bt=s(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-o9ssdv"&&(C.innerHTML=rn),Mt=s(e),c(j.$$.fragment,e),kt=s(e),c(v.$$.fragment,e),gt=s(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-96m8sj"&&(x.innerHTML=pn),wt=s(e),c(I.$$.fragment,e),$t=s(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1b4vj4e"&&(_.textContent=cn),Ut=s(e),H=o(e,"OL",{"data-svelte-h":!0}),r(H)!=="svelte-3arzgs"&&(H.innerHTML=dn),Jt=s(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-1ihjqjm"&&(L.innerHTML=mn),Ct=s(e),c(Z.$$.fragment,e),jt=s(e),V=o(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1cac215"&&(V.innerHTML=un),vt=s(e),c(N.$$.fragment,e),xt=s(e),R=o(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-4lye9k"&&(R.innerHTML=hn),It=s(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-g5i707"&&(B.textContent=fn),_t=s(e),c(W.$$.fragment,e),Ht=s(e),Q=o(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-cn9mkc"&&(Q.innerHTML=Tn),Lt=s(e),c(E.$$.fragment,e),Zt=s(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1prqyz3"&&(A.innerHTML=yn),Vt=s(e),X=o(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-1exh4w8"&&(X.innerHTML=bn),Nt=s(e),c(S.$$.fragment,e),Rt=s(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1poutmy"&&(G.innerHTML=Mn),Bt=s(e),c(P.$$.fragment,e),Wt=s(e),q=o(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-s84xza"&&(q.innerHTML=kn),Qt=s(e),c(Y.$$.fragment,e),Et=s(e),F=o(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-6oo725"&&(F.textContent=gn),At=s(e),c(O.$$.fragment,e),Xt=s(e),z=o(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-1lqdx4"&&(z.textContent=wn),St=s(e),D=o(e,"UL",{"data-svelte-h":!0}),r(D)!=="svelte-c8vtob"&&(D.innerHTML=$n),Gt=s(e),c(K.$$.fragment,e),Pt=s(e),ee=o(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-1hgp1cr"&&(ee.innerHTML=Un),qt=s(e),c(te.$$.fragment,e),Yt=s(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-pgruc9"&&(le.innerHTML=Jn),Ft=s(e),c(ne.$$.fragment,e),Ot=s(e),ie=o(e,"UL",{"data-svelte-h":!0}),r(ie)!=="svelte-cm9oc9"&&(ie.innerHTML=Cn),zt=s(e),c(se.$$.fragment,e),Dt=s(e),ae=o(e,"UL",{"data-svelte-h":!0}),r(ae)!=="svelte-12rq95i"&&(ae.innerHTML=jn),Kt=s(e),c(oe.$$.fragment,e),el=s(e),re=o(e,"UL",{"data-svelte-h":!0}),r(re)!=="svelte-1fzn2"&&(re.innerHTML=vn),tl=s(e),c(pe.$$.fragment,e),ll=s(e),ce=o(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-3rear0"&&(ce.textContent=xn),nl=s(e),de=o(e,"UL",{"data-svelte-h":!0}),r(de)!=="svelte-1079mx2"&&(de.innerHTML=In),il=s(e),c(me.$$.fragment,e),sl=s(e),ue=o(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1weg0gu"&&(ue.innerHTML=_n),al=s(e),he=o(e,"P",{"data-svelte-h":!0}),r(he)!=="svelte-1al5myg"&&(he.textContent=Hn),ol=s(e),fe=o(e,"UL",{"data-svelte-h":!0}),r(fe)!=="svelte-1fbzu1m"&&(fe.innerHTML=Ln),rl=s(e),Te=o(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-1mf578x"&&(Te.textContent=Zn),pl=s(e),c(ye.$$.fragment,e),cl=s(e),be=o(e,"UL",{"data-svelte-h":!0}),r(be)!=="svelte-3vtlb2"&&(be.innerHTML=Vn),dl=s(e),c(Me.$$.fragment,e),ml=s(e),ke=o(e,"UL",{"data-svelte-h":!0}),r(ke)!=="svelte-mx7mxt"&&(ke.innerHTML=Nn),ul=s(e),c(ge.$$.fragment,e),hl=s(e),we=o(e,"UL",{"data-svelte-h":!0}),r(we)!=="svelte-1u3m3l7"&&(we.innerHTML=Rn),fl=s(e),c($e.$$.fragment,e),Tl=s(e),Ue=o(e,"UL",{"data-svelte-h":!0}),r(Ue)!=="svelte-10okur"&&(Ue.innerHTML=Bn),yl=s(e),c(Je.$$.fragment,e),bl=s(e),c(Ce.$$.fragment,e),Ml=s(e),je=o(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-r7rot5"&&(je.textContent=Wn),kl=s(e),ve=o(e,"UL",{"data-svelte-h":!0}),r(ve)!=="svelte-poxr41"&&(ve.innerHTML=Qn),gl=s(e),xe=o(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-1ikzb58"&&(xe.innerHTML=En),wl=s(e),c(Ie.$$.fragment,e),$l=s(e),_e=o(e,"P",{"data-svelte-h":!0}),r(_e)!=="svelte-5ja9lk"&&(_e.innerHTML=An),Ul=s(e),c(He.$$.fragment,e),Jl=s(e),Le=o(e,"P",{"data-svelte-h":!0}),r(Le)!=="svelte-ssih46"&&(Le.innerHTML=Xn),Cl=s(e),c(Ze.$$.fragment,e),jl=s(e),Ve=o(e,"P",{"data-svelte-h":!0}),r(Ve)!=="svelte-1y8rjsx"&&(Ve.innerHTML=Sn),vl=s(e),Ne=o(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-a3yu8e"&&(Ne.innerHTML=Gn),xl=s(e),c(Re.$$.fragment,e),Il=s(e),c(Be.$$.fragment,e),_l=s(e),We=o(e,"P",{"data-svelte-h":!0}),r(We)!=="svelte-xosw3t"&&(We.innerHTML=Pn),Hl=s(e),Qe=o(e,"P",{"data-svelte-h":!0}),r(Qe)!=="svelte-a5yx0v"&&(Qe.innerHTML=qn),Ll=s(e),c(Ee.$$.fragment,e),Zl=s(e),Ae=o(e,"P",{"data-svelte-h":!0}),r(Ae)!=="svelte-9b7ddb"&&(Ae.textContent=Yn),Vl=s(e),c(Xe.$$.fragment,e),Nl=s(e),Se=o(e,"P",{"data-svelte-h":!0}),r(Se)!=="svelte-4caz4s"&&(Se.innerHTML=Fn),Rl=s(e),Ge=o(e,"P",{"data-svelte-h":!0}),r(Ge)!=="svelte-hkktty"&&(Ge.innerHTML=On),Bl=s(e),c(Pe.$$.fragment,e),Wl=s(e),c(qe.$$.fragment,e),Ql=s(e),Ye=o(e,"P",{"data-svelte-h":!0}),r(Ye)!=="svelte-q979am"&&(Ye.innerHTML=zn),El=s(e),c(Fe.$$.fragment,e),Al=s(e),Oe=o(e,"P",{"data-svelte-h":!0}),r(Oe)!=="svelte-1uzdod8"&&(Oe.textContent=Dn),Xl=s(e),ze=o(e,"P",{"data-svelte-h":!0}),r(ze)!=="svelte-s01sgi"&&(ze.textContent=Kn),Sl=s(e),c(De.$$.fragment,e),Gl=s(e),Ke=o(e,"P",{"data-svelte-h":!0}),r(Ke)!=="svelte-1ucbtrx"&&(Ke.innerHTML=ei),Pl=s(e),c(et.$$.fragment,e),ql=s(e),tt=o(e,"P",{"data-svelte-h":!0}),r(tt)!=="svelte-gcopz4"&&(tt.innerHTML=ti),Yl=s(e),c(lt.$$.fragment,e),Fl=s(e),nt=o(e,"P",{"data-svelte-h":!0}),r(nt)!=="svelte-11q3n4g"&&(nt.innerHTML=li),Ol=s(e),it=o(e,"P",{"data-svelte-h":!0}),r(it)!=="svelte-zjr5ot"&&(it.innerHTML=ni),zl=s(e),st=o(e,"P",{"data-svelte-h":!0}),r(st)!=="svelte-rt0n0n"&&(st.innerHTML=ii),Dl=s(e),c(at.$$.fragment,e),Kl=s(e),rt=o(e,"P",{}),si(rt).forEach(l),this.h()},h(){ai(y,"name","hf:doc:metadata"),ai(y,"content",yi)},m(e,t){ui(document.head,y),n(e,pt,t),n(e,ot,t),n(e,ct,t),d(b,e,t),n(e,dt,t),d(M,e,t),n(e,mt,t),d(k,e,t),n(e,ut,t),n(e,g,t),n(e,ht,t),n(e,w,t),n(e,ft,t),n(e,$,t),n(e,Tt,t),n(e,U,t),n(e,yt,t),n(e,J,t),n(e,bt,t),n(e,C,t),n(e,Mt,t),d(j,e,t),n(e,kt,t),d(v,e,t),n(e,gt,t),n(e,x,t),n(e,wt,t),d(I,e,t),n(e,$t,t),n(e,_,t),n(e,Ut,t),n(e,H,t),n(e,Jt,t),n(e,L,t),n(e,Ct,t),d(Z,e,t),n(e,jt,t),n(e,V,t),n(e,vt,t),d(N,e,t),n(e,xt,t),n(e,R,t),n(e,It,t),n(e,B,t),n(e,_t,t),d(W,e,t),n(e,Ht,t),n(e,Q,t),n(e,Lt,t),d(E,e,t),n(e,Zt,t),n(e,A,t),n(e,Vt,t),n(e,X,t),n(e,Nt,t),d(S,e,t),n(e,Rt,t),n(e,G,t),n(e,Bt,t),d(P,e,t),n(e,Wt,t),n(e,q,t),n(e,Qt,t),d(Y,e,t),n(e,Et,t),n(e,F,t),n(e,At,t),d(O,e,t),n(e,Xt,t),n(e,z,t),n(e,St,t),n(e,D,t),n(e,Gt,t),d(K,e,t),n(e,Pt,t),n(e,ee,t),n(e,qt,t),d(te,e,t),n(e,Yt,t),n(e,le,t),n(e,Ft,t),d(ne,e,t),n(e,Ot,t),n(e,ie,t),n(e,zt,t),d(se,e,t),n(e,Dt,t),n(e,ae,t),n(e,Kt,t),d(oe,e,t),n(e,el,t),n(e,re,t),n(e,tl,t),d(pe,e,t),n(e,ll,t),n(e,ce,t),n(e,nl,t),n(e,de,t),n(e,il,t),d(me,e,t),n(e,sl,t),n(e,ue,t),n(e,al,t),n(e,he,t),n(e,ol,t),n(e,fe,t),n(e,rl,t),n(e,Te,t),n(e,pl,t),d(ye,e,t),n(e,cl,t),n(e,be,t),n(e,dl,t),d(Me,e,t),n(e,ml,t),n(e,ke,t),n(e,ul,t),d(ge,e,t),n(e,hl,t),n(e,we,t),n(e,fl,t),d($e,e,t),n(e,Tl,t),n(e,Ue,t),n(e,yl,t),d(Je,e,t),n(e,bl,t),d(Ce,e,t),n(e,Ml,t),n(e,je,t),n(e,kl,t),n(e,ve,t),n(e,gl,t),n(e,xe,t),n(e,wl,t),d(Ie,e,t),n(e,$l,t),n(e,_e,t),n(e,Ul,t),d(He,e,t),n(e,Jl,t),n(e,Le,t),n(e,Cl,t),d(Ze,e,t),n(e,jl,t),n(e,Ve,t),n(e,vl,t),n(e,Ne,t),n(e,xl,t),d(Re,e,t),n(e,Il,t),d(Be,e,t),n(e,_l,t),n(e,We,t),n(e,Hl,t),n(e,Qe,t),n(e,Ll,t),d(Ee,e,t),n(e,Zl,t),n(e,Ae,t),n(e,Vl,t),d(Xe,e,t),n(e,Nl,t),n(e,Se,t),n(e,Rl,t),n(e,Ge,t),n(e,Bl,t),d(Pe,e,t),n(e,Wl,t),d(qe,e,t),n(e,Ql,t),n(e,Ye,t),n(e,El,t),d(Fe,e,t),n(e,Al,t),n(e,Oe,t),n(e,Xl,t),n(e,ze,t),n(e,Sl,t),d(De,e,t),n(e,Gl,t),n(e,Ke,t),n(e,Pl,t),d(et,e,t),n(e,ql,t),n(e,tt,t),n(e,Yl,t),d(lt,e,t),n(e,Fl,t),n(e,nt,t),n(e,Ol,t),n(e,it,t),n(e,zl,t),n(e,st,t),n(e,Dl,t),d(at,e,t),n(e,Kl,t),n(e,rt,t),en=!0},p:ri,i(e){en||(m(b.$$.fragment,e),m(M.$$.fragment,e),m(k.$$.fragment,e),m(j.$$.fragment,e),m(v.$$.fragment,e),m(I.$$.fragment,e),m(Z.$$.fragment,e),m(N.$$.fragment,e),m(W.$$.fragment,e),m(E.$$.fragment,e),m(S.$$.fragment,e),m(P.$$.fragment,e),m(Y.$$.fragment,e),m(O.$$.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(Me.$$.fragment,e),m(ge.$$.fragment,e),m($e.$$.fragment,e),m(Je.$$.fragment,e),m(Ce.$$.fragment,e),m(Ie.$$.fragment,e),m(He.$$.fragment,e),m(Ze.$$.fragment,e),m(Re.$$.fragment,e),m(Be.$$.fragment,e),m(Ee.$$.fragment,e),m(Xe.$$.fragment,e),m(Pe.$$.fragment,e),m(qe.$$.fragment,e),m(Fe.$$.fragment,e),m(De.$$.fragment,e),m(et.$$.fragment,e),m(lt.$$.fragment,e),m(at.$$.fragment,e),en=!0)},o(e){u(b.$$.fragment,e),u(M.$$.fragment,e),u(k.$$.fragment,e),u(j.$$.fragment,e),u(v.$$.fragment,e),u(I.$$.fragment,e),u(Z.$$.fragment,e),u(N.$$.fragment,e),u(W.$$.fragment,e),u(E.$$.fragment,e),u(S.$$.fragment,e),u(P.$$.fragment,e),u(Y.$$.fragment,e),u(O.$$.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(Me.$$.fragment,e),u(ge.$$.fragment,e),u($e.$$.fragment,e),u(Je.$$.fragment,e),u(Ce.$$.fragment,e),u(Ie.$$.fragment,e),u(He.$$.fragment,e),u(Ze.$$.fragment,e),u(Re.$$.fragment,e),u(Be.$$.fragment,e),u(Ee.$$.fragment,e),u(Xe.$$.fragment,e),u(Pe.$$.fragment,e),u(qe.$$.fragment,e),u(Fe.$$.fragment,e),u(De.$$.fragment,e),u(et.$$.fragment,e),u(lt.$$.fragment,e),u(at.$$.fragment,e),en=!1},d(e){e&&(l(pt),l(ot),l(ct),l(dt),l(mt),l(ut),l(g),l(ht),l(w),l(ft),l($),l(Tt),l(U),l(yt),l(J),l(bt),l(C),l(Mt),l(kt),l(gt),l(x),l(wt),l($t),l(_),l(Ut),l(H),l(Jt),l(L),l(Ct),l(jt),l(V),l(vt),l(xt),l(R),l(It),l(B),l(_t),l(Ht),l(Q),l(Lt),l(Zt),l(A),l(Vt),l(X),l(Nt),l(Rt),l(G),l(Bt),l(Wt),l(q),l(Qt),l(Et),l(F),l(At),l(Xt),l(z),l(St),l(D),l(Gt),l(Pt),l(ee),l(qt),l(Yt),l(le),l(Ft),l(Ot),l(ie),l(zt),l(Dt),l(ae),l(Kt),l(el),l(re),l(tl),l(ll),l(ce),l(nl),l(de),l(il),l(sl),l(ue),l(al),l(he),l(ol),l(fe),l(rl),l(Te),l(pl),l(cl),l(be),l(dl),l(ml),l(ke),l(ul),l(hl),l(we),l(fl),l(Tl),l(Ue),l(yl),l(bl),l(Ml),l(je),l(kl),l(ve),l(gl),l(xe),l(wl),l($l),l(_e),l(Ul),l(Jl),l(Le),l(Cl),l(jl),l(Ve),l(vl),l(Ne),l(xl),l(Il),l(_l),l(We),l(Hl),l(Qe),l(Ll),l(Zl),l(Ae),l(Vl),l(Nl),l(Se),l(Rl),l(Ge),l(Bl),l(Wl),l(Ql),l(Ye),l(El),l(Al),l(Oe),l(Xl),l(ze),l(Sl),l(Gl),l(Ke),l(Pl),l(ql),l(tt),l(Yl),l(Fl),l(nt),l(Ol),l(it),l(zl),l(st),l(Dl),l(Kl),l(rt)),l(y),h(b,e),h(M,e),h(k,e),h(j,e),h(v,e),h(I,e),h(Z,e),h(N,e),h(W,e),h(E,e),h(S,e),h(P,e),h(Y,e),h(O,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(Me,e),h(ge,e),h($e,e),h(Je,e),h(Ce,e),h(Ie,e),h(He,e),h(Ze,e),h(Re,e),h(Be,e),h(Ee,e),h(Xe,e),h(Pe,e),h(qe,e),h(Fe,e),h(De,e),h(et,e),h(lt,e),h(at,e)}}}const yi='{"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.<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 bi(tn){return pi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ui extends ci{constructor(y){super(),di(this,y,bi,Ti,oi,{})}}export{Ui as component}; | |
Xet Storage Details
- Size:
- 45.8 kB
- Xet hash:
- b69b7f0327c88432128081b5b0f3000ed7613a1f71cab335861474a50bf6a8b8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.