import{s as ce,n as de,o as ue}from"../chunks/scheduler.f3b1e791.js";import{S as he,i as fe,e as i,s,c as m,h as ye,a as o,d as l,b as a,f as me,g as p,j as C,k as pe,l as Me,m as n,n as c,t as d,o as u,p as h}from"../chunks/index.023a9934.js";import{C as ke}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{C as ee}from"../chunks/CodeBlock.5aa52fca.js";import{H as O,E as ge}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function be(te){let r,U,I,G,f,X,y,W,M,V,k,le='Here is how you would use the <a href="https://huggingface.co/kernels-community/activation" rel="nofollow">activation</a> kernels from the Hugging Face Hub:',H,g,L,b,ne=`This fetches version <code>1</code> of the kernel <code>kernels-community/activation</code>.
Kernels are versioned using a major version number. Using <code>version=1</code> will
get the latest kernel build from the <code>v1</code> branch.`,Y,$,se=`Kernels within a version branch must never break the API or remove builds
for older PyTorch versions. This ensures that your code will continue to work.`,R,v,ae=`Some kernels have not yet been updated to use versioning yet. In these cases,
you can use <code>get_kernel</code> without the <code>version</code> argument.`,F,T,z,w,ie=`You can check if a particular version of a kernel supports the environment
that the program is running on:`,N,J,S,j,K,_,oe=`<code>get_loaded_kernels()</code> returns a snapshot of every kernel that has been loaded
into the current process. Each entry is a <code>LoadedKernel</code> namedtuple with the
imported <code>module</code>, the <code>package_name</code>, and <code>repo_infos</code> (repo id, resolved
revision, and the backend argument that was passed).`,P,Z,Q,x,re=`<code>repo_infos</code> is populated only for kernels loaded with <code>get_kernel</code>. Kernels
loaded from a local path (<code>get_local_kernel</code>) or via a lockfile
(<code>get_locked_kernel</code>, <code>load_kernel</code>) have <code>repo_infos=None</code>.`,q,B,D,E,A;return f=new ke({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new O({props:{title:"Quickstart",local:"quickstart",headingTag:"h1"}}),M=new O({props:{title:"Loading Kernels",local:"loading-kernels",headingTag:"h2"}}),g=new ee({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMGdldF9rZXJuZWwlMEElMEElMjMlMjBEb3dubG9hZCUyMG9wdGltaXplZCUyMGtlcm5lbHMlMjBmcm9tJTIwdGhlJTIwSHVnZ2luZyUyMEZhY2UlMjBodWIlMEFhY3RpdmF0aW9uJTIwJTNEJTIwZ2V0X2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEElMEElMjMlMjBDcmVhdGUlMjBhJTIwcmFuZG9tJTIwdGVuc29yJTBBeCUyMCUzRCUyMHRvcmNoLnJhbmRuKCgxMCUyQyUyMDEwKSUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTBBJTBBJTIzJTIwUnVuJTIwdGhlJTIwa2VybmVsJTBBeSUyMCUzRCUyMHRvcmNoLmVtcHR5X2xpa2UoeCklMEFhY3RpdmF0aW9uLmdlbHVfZmFzdCh5JTJDJTIweCklMEElMEFwcmludCh5KQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_kernel

<span class="hljs-comment"># Download optimized kernels from the Hugging Face hub</span>
activation = get_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>, version=<span class="hljs-number">1</span>)

<span class="hljs-comment"># Create a random tensor</span>
x = torch.randn((<span class="hljs-number">10</span>, <span class="hljs-number">10</span>), dtype=torch.float16, device=<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># Run the kernel</span>
y = torch.empty_like(x)
activation.gelu_fast(y, x)

<span class="hljs-built_in">print</span>(y)`,wrap:!1}}),T=new O({props:{title:"Checking Kernel Availability",local:"checking-kernel-availability",headingTag:"h2"}}),J=new ee({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBoYXNfa2VybmVsJTBBJTBBJTIzJTIwQ2hlY2slMjBpZiUyMGtlcm5lbCUyMGlzJTIwYXZhaWxhYmxlJTIwZm9yJTIwY3VycmVudCUyMGVudmlyb25tZW50JTBBaXNfYXZhaWxhYmxlJTIwJTNEJTIwaGFzX2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEFwcmludChmJTIyS2VybmVsJTIwYXZhaWxhYmxlJTNBJTIwJTdCaXNfYXZhaWxhYmxlJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> has_kernel

<span class="hljs-comment"># Check if kernel is available for current environment</span>
is_available = has_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>, version=<span class="hljs-number">1</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Kernel available: <span class="hljs-subst">{is_available}</span>&quot;</span>)`,wrap:!1}}),j=new O({props:{title:"Inspecting Loaded Kernels",local:"inspecting-loaded-kernels",headingTag:"h2"}}),Z=new ee({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBnZXRfa2VybmVsJTJDJTIwZ2V0X2xvYWRlZF9rZXJuZWxzJTBBJTBBZ2V0X2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEElMEFmb3IlMjBsb2FkZWQlMjBpbiUyMGdldF9sb2FkZWRfa2VybmVscygpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQobG9hZGVkLnBhY2thZ2VfbmFtZSUyQyUyMGxvYWRlZC5yZXBvX2luZm9zKQ==",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_kernel, get_loaded_kernels

get_kernel(<span class="hljs-string">&quot;kernels-community/activation&quot;</span>, version=<span class="hljs-number">1</span>)

<span class="hljs-keyword">for</span> loaded <span class="hljs-keyword">in</span> get_loaded_kernels():
    <span class="hljs-built_in">print</span>(loaded.package_name, loaded.repo_infos)`,wrap:!1}}),B=new ge({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/basic-usage.md"}}),{c(){r=i("meta"),U=s(),I=i("p"),G=s(),m(f.$$.fragment),X=s(),m(y.$$.fragment),W=s(),m(M.$$.fragment),V=s(),k=i("p"),k.innerHTML=le,H=s(),m(g.$$.fragment),L=s(),b=i("p"),b.innerHTML=ne,Y=s(),$=i("p"),$.textContent=se,R=s(),v=i("p"),v.innerHTML=ae,F=s(),m(T.$$.fragment),z=s(),w=i("p"),w.textContent=ie,N=s(),m(J.$$.fragment),S=s(),m(j.$$.fragment),K=s(),_=i("p"),_.innerHTML=oe,P=s(),m(Z.$$.fragment),Q=s(),x=i("p"),x.innerHTML=re,q=s(),m(B.$$.fragment),D=s(),E=i("p"),this.h()},l(e){const t=ye("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(l),U=a(e),I=o(e,"P",{}),me(I).forEach(l),G=a(e),p(f.$$.fragment,e),X=a(e),p(y.$$.fragment,e),W=a(e),p(M.$$.fragment,e),V=a(e),k=o(e,"P",{"data-svelte-h":!0}),C(k)!=="svelte-2utbko"&&(k.innerHTML=le),H=a(e),p(g.$$.fragment,e),L=a(e),b=o(e,"P",{"data-svelte-h":!0}),C(b)!=="svelte-1xtp1ii"&&(b.innerHTML=ne),Y=a(e),$=o(e,"P",{"data-svelte-h":!0}),C($)!=="svelte-sotpzr"&&($.textContent=se),R=a(e),v=o(e,"P",{"data-svelte-h":!0}),C(v)!=="svelte-1ucxhjf"&&(v.innerHTML=ae),F=a(e),p(T.$$.fragment,e),z=a(e),w=o(e,"P",{"data-svelte-h":!0}),C(w)!=="svelte-vgk28x"&&(w.textContent=ie),N=a(e),p(J.$$.fragment,e),S=a(e),p(j.$$.fragment,e),K=a(e),_=o(e,"P",{"data-svelte-h":!0}),C(_)!=="svelte-y003m3"&&(_.innerHTML=oe),P=a(e),p(Z.$$.fragment,e),Q=a(e),x=o(e,"P",{"data-svelte-h":!0}),C(x)!=="svelte-d9wfpl"&&(x.innerHTML=re),q=a(e),p(B.$$.fragment,e),D=a(e),E=o(e,"P",{}),me(E).forEach(l),this.h()},h(){pe(r,"name","hf:doc:metadata"),pe(r,"content",$e)},m(e,t){Me(document.head,r),n(e,U,t),n(e,I,t),n(e,G,t),c(f,e,t),n(e,X,t),c(y,e,t),n(e,W,t),c(M,e,t),n(e,V,t),n(e,k,t),n(e,H,t),c(g,e,t),n(e,L,t),n(e,b,t),n(e,Y,t),n(e,$,t),n(e,R,t),n(e,v,t),n(e,F,t),c(T,e,t),n(e,z,t),n(e,w,t),n(e,N,t),c(J,e,t),n(e,S,t),c(j,e,t),n(e,K,t),n(e,_,t),n(e,P,t),c(Z,e,t),n(e,Q,t),n(e,x,t),n(e,q,t),c(B,e,t),n(e,D,t),n(e,E,t),A=!0},p:de,i(e){A||(d(f.$$.fragment,e),d(y.$$.fragment,e),d(M.$$.fragment,e),d(g.$$.fragment,e),d(T.$$.fragment,e),d(J.$$.fragment,e),d(j.$$.fragment,e),d(Z.$$.fragment,e),d(B.$$.fragment,e),A=!0)},o(e){u(f.$$.fragment,e),u(y.$$.fragment,e),u(M.$$.fragment,e),u(g.$$.fragment,e),u(T.$$.fragment,e),u(J.$$.fragment,e),u(j.$$.fragment,e),u(Z.$$.fragment,e),u(B.$$.fragment,e),A=!1},d(e){e&&(l(U),l(I),l(G),l(X),l(W),l(V),l(k),l(H),l(L),l(b),l(Y),l($),l(R),l(v),l(F),l(z),l(w),l(N),l(S),l(K),l(_),l(P),l(Q),l(x),l(q),l(D),l(E)),l(r),h(f,e),h(y,e),h(M,e),h(g,e),h(T,e),h(J,e),h(j,e),h(Z,e),h(B,e)}}}const $e='{"title":"Quickstart","local":"quickstart","sections":[{"title":"Loading Kernels","local":"loading-kernels","sections":[],"depth":2},{"title":"Checking Kernel Availability","local":"checking-kernel-availability","sections":[],"depth":2},{"title":"Inspecting Loaded Kernels","local":"inspecting-loaded-kernels","sections":[],"depth":2}],"depth":1}';function ve(te){return ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends he{constructor(r){super(),fe(this,r,ve,be,ce,{})}}export{Ze as component};
