Buckets:
| import{s as Le,o as Ue,n as He}from"../chunks/scheduler.f3b1e791.js";import{S as Fe,i as Ve,e as u,s as r,c as i,h as Ze,a as f,d as n,b as o,f as R,g as d,j as E,k as W,l as g,m as l,n as c,t as p,o as m,p as k}from"../chunks/index.d8b6a549.js";import{C as qe}from"../chunks/CopyLLMTxtMenu.1edf0ddf.js";import{D as te,E as Se}from"../chunks/ExampleCodeBlock.d686d227.js";import{C as Re}from"../chunks/CodeBlock.05c913ee.js";import{H as N,E as We}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a742978a.js";function Xe(ne){let s,P="Example:",y,$,_;return $=new Re({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMGdldF9rZXJuZWwlMEElMEFhY3RpdmF0aW9uJTIwJTNEJTIwZ2V0X2tlcm5lbCglMjJrZXJuZWxzLWNvbW11bml0eSUyRnJlbHUlMjIlMkMlMjB2ZXJzaW9uJTNEMSklMEF4JTIwJTNEJTIwdG9yY2gucmFuZG4oMTAlMkMlMjAyMCUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTBBb3V0JTIwJTNEJTIwdG9yY2guZW1wdHlfbGlrZSh4KSUwQXJlc3VsdCUyMCUzRCUyMGFjdGl2YXRpb24ucmVsdShvdXQlMkMlMjB4KQ==",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> get_kernel | |
| activation = get_kernel(<span class="hljs-string">"kernels-community/relu"</span>, version=<span class="hljs-number">1</span>) | |
| x = torch.randn(<span class="hljs-number">10</span>, <span class="hljs-number">20</span>, device=<span class="hljs-string">"cuda"</span>) | |
| out = torch.empty_like(x) | |
| result = activation.relu(out, x)`,wrap:!1}}),{c(){s=u("p"),s.textContent=P,y=r(),i($.$$.fragment)},l(a){s=f(a,"P",{"data-svelte-h":!0}),E(s)!=="svelte-11lpom8"&&(s.textContent=P),y=o(a),d($.$$.fragment,a)},m(a,b){l(a,s,b),l(a,y,b),c($,a,b),_=!0},p:He,i(a){_||(p($.$$.fragment,a),_=!0)},o(a){m($.$$.fragment,a),_=!1},d(a){a&&(n(s),n(y)),k($,a)}}}function ze(ne){let s,P,y,$,_,a,b,re,I,oe,J,le,h,j,ve,X,Ee="Load a kernel from the kernel hub.",xe,z,Pe=`This function downloads a kernel to the local Hugging Face Hub cache directory (if it was not downloaded before) | |
| and then loads the kernel.`,ye,M,ae,D,se,T,G,Te,B,Ie="Import a kernel from a local kernel repository path.",ie,L,de,w,U,we,A,Je="Check whether a kernel build exists for the current environment (Torch version and compute framework).",ce,H,pe,F,me,v,V,Ce,Y,je="Get a pre-downloaded, locked kernel.",Me,K,De="If <code>lockfile</code> is not specified, the lockfile will be loaded from the caller’s package metadata.",ke,Z,ge,C,q,Ne,Q,Ge="Get a kernel using a lock file.",ue,S,fe,ee,he;return _=new qe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new N({props:{title:"Kernels API Reference",local:"kernels-api-reference",headingTag:"h1"}}),I=new N({props:{title:"Main Functions",local:"main-functions",headingTag:"h2"}}),J=new N({props:{title:"get_kernel",local:"kernels.get_kernel",headingTag:"h3"}}),j=new te({props:{name:"kernels.get_kernel",anchor:"kernels.get_kernel",parameters:[{name:"repo_id",val:": str"},{name:"revision",val:": str | None = None"},{name:"version",val:": int | str | None = None"},{name:"backend",val:": str | None = None"},{name:"user_agent",val:": str | dict | None = None"}],parametersDescription:[{anchor:"kernels.get_kernel.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) — | |
| The Hub repository containing the kernel.`,name:"repo_id"},{anchor:"kernels.get_kernel.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"main"</code>) — | |
| The specific revision (branch, tag, or commit) to download. Cannot be used together with <code>version</code>.`,name:"revision"},{anchor:"kernels.get_kernel.version",description:`<strong>version</strong> (<code>int|str</code>, <em>optional</em>) — | |
| The kernel version to download as an integer. The <code>str</code> variant is deprecated and will be | |
| removed in a future release. Cannot be used together with <code>revision</code>.`,name:"version"},{anchor:"kernels.get_kernel.backend",description:`<strong>backend</strong> (<code>str</code>, <em>optional</em>) — | |
| The backend to load the kernel for. Can only be <code>cpu</code> or the backend that Torch is compiled for. | |
| The backend will be detected automatically if not provided.`,name:"backend"},{anchor:"kernels.get_kernel.user_agent",description:`<strong>user_agent</strong> (<code>Union[str, dict]</code>, <em>optional</em>) — | |
| The <code>user_agent</code> info to pass to <code>snapshot_download()</code> for internal telemetry.`,name:"user_agent"}],source:"https://github.com/huggingface/kernels/blob/vr_321/src/kernels/utils.py#L354",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The imported kernel module.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ModuleType</code></p> | |
| `}}),M=new Se({props:{anchor:"kernels.get_kernel.example",$$slots:{default:[Xe]},$$scope:{ctx:ne}}}),D=new N({props:{title:"get_local_kernel",local:"kernels.get_local_kernel",headingTag:"h3"}}),G=new te({props:{name:"kernels.get_local_kernel",anchor:"kernels.get_local_kernel",parameters:[{name:"repo_path",val:": Path"},{name:"package_name",val:": str"},{name:"backend",val:": str | None = None"}],parametersDescription:[{anchor:"kernels.get_local_kernel.repo_path",description:`<strong>repo_path</strong> (<code>Path</code>) — | |
| The local path to the kernel repository.`,name:"repo_path"},{anchor:"kernels.get_local_kernel.package_name",description:`<strong>package_name</strong> (<code>str</code>) — | |
| The name of the package to import from the repository.`,name:"package_name"},{anchor:"kernels.get_local_kernel.backend",description:`<strong>backend</strong> (<code>str</code>, <em>optional</em>) — | |
| The backend to load the kernel for. Can only be <code>cpu</code> or the backend that Torch is compiled for. | |
| The backend will be detected automatically if not provided.`,name:"backend"}],source:"https://github.com/huggingface/kernels/blob/vr_321/src/kernels/utils.py#L406",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The imported kernel module.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ModuleType</code></p> | |
| `}}),L=new N({props:{title:"has_kernel",local:"kernels.has_kernel",headingTag:"h3"}}),U=new te({props:{name:"kernels.has_kernel",anchor:"kernels.has_kernel",parameters:[{name:"repo_id",val:": str"},{name:"revision",val:": str | None = None"},{name:"version",val:": int | str | None = None"},{name:"backend",val:": str | None = None"}],parametersDescription:[{anchor:"kernels.has_kernel.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) — | |
| The Hub repository containing the kernel.`,name:"repo_id"},{anchor:"kernels.has_kernel.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"main"</code>) — | |
| The specific revision (branch, tag, or commit) to download. Cannot be used together with <code>version</code>.`,name:"revision"},{anchor:"kernels.has_kernel.version",description:`<strong>version</strong> (<code>int|str</code>, <em>optional</em>) — | |
| The kernel version to download as an integer. The <code>str</code> variant is deprecated and will be | |
| removed in a future release. Cannot be used together with <code>revision</code>.`,name:"version"},{anchor:"kernels.has_kernel.backend",description:`<strong>backend</strong> (<code>str</code>, <em>optional</em>) — | |
| The backend to load the kernel for. Can only be <code>cpu</code> or the backend that Torch is compiled for. | |
| The backend will be detected automatically if not provided.`,name:"backend"}],source:"https://github.com/huggingface/kernels/blob/vr_321/src/kernels/utils.py#L442",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>True</code> if a kernel is available for the current environment.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>bool</code></p> | |
| `}}),H=new N({props:{title:"Loading locked kernels",local:"loading-locked-kernels",headingTag:"h2"}}),F=new N({props:{title:"load_kernel",local:"kernels.load_kernel",headingTag:"h3"}}),V=new te({props:{name:"kernels.load_kernel",anchor:"kernels.load_kernel",parameters:[{name:"repo_id",val:": str"},{name:"lockfile",val:": pathlib.Path | None"},{name:"backend",val:": str | None = None"}],parametersDescription:[{anchor:"kernels.load_kernel.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) — | |
| The Hub repository containing the kernel.`,name:"repo_id"},{anchor:"kernels.load_kernel.lockfile",description:`<strong>lockfile</strong> (<code>Path</code>, <em>optional</em>) — | |
| Path to the lockfile. If not provided, the lockfile will be loaded from the caller’s package metadata.`,name:"lockfile"},{anchor:"kernels.load_kernel.backend",description:`<strong>backend</strong> (<code>str</code>, <em>optional</em>) — | |
| The backend to load the kernel for. Can only be <code>cpu</code> or the backend that Torch is compiled for. | |
| The backend will be detected automatically if not provided.`,name:"backend"}],source:"https://github.com/huggingface/kernels/blob/vr_321/src/kernels/utils.py#L480",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The imported kernel module.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ModuleType</code></p> | |
| `}}),Z=new N({props:{title:"get_locked_kernel",local:"kernels.get_locked_kernel",headingTag:"h3"}}),q=new te({props:{name:"kernels.get_locked_kernel",anchor:"kernels.get_locked_kernel",parameters:[{name:"repo_id",val:": str"},{name:"local_files_only",val:": bool = False"}],parametersDescription:[{anchor:"kernels.get_locked_kernel.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) — | |
| The Hub repository containing the kernel.`,name:"repo_id"},{anchor:"kernels.get_locked_kernel.local_files_only",description:`<strong>local_files_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to only use local files and not download from the Hub.`,name:"local_files_only"}],source:"https://github.com/huggingface/kernels/blob/vr_321/src/kernels/utils.py#L541",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The imported kernel module.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>ModuleType</code></p> | |
| `}}),S=new We({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/api/kernels.md"}}),{c(){s=u("meta"),P=r(),y=u("p"),$=r(),i(_.$$.fragment),a=r(),i(b.$$.fragment),re=r(),i(I.$$.fragment),oe=r(),i(J.$$.fragment),le=r(),h=u("div"),i(j.$$.fragment),ve=r(),X=u("p"),X.textContent=Ee,xe=r(),z=u("p"),z.textContent=Pe,ye=r(),i(M.$$.fragment),ae=r(),i(D.$$.fragment),se=r(),T=u("div"),i(G.$$.fragment),Te=r(),B=u("p"),B.textContent=Ie,ie=r(),i(L.$$.fragment),de=r(),w=u("div"),i(U.$$.fragment),we=r(),A=u("p"),A.textContent=Je,ce=r(),i(H.$$.fragment),pe=r(),i(F.$$.fragment),me=r(),v=u("div"),i(V.$$.fragment),Ce=r(),Y=u("p"),Y.textContent=je,Me=r(),K=u("p"),K.innerHTML=De,ke=r(),i(Z.$$.fragment),ge=r(),C=u("div"),i(q.$$.fragment),Ne=r(),Q=u("p"),Q.textContent=Ge,ue=r(),i(S.$$.fragment),fe=r(),ee=u("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);s=f(t,"META",{name:!0,content:!0}),t.forEach(n),P=o(e),y=f(e,"P",{}),R(y).forEach(n),$=o(e),d(_.$$.fragment,e),a=o(e),d(b.$$.fragment,e),re=o(e),d(I.$$.fragment,e),oe=o(e),d(J.$$.fragment,e),le=o(e),h=f(e,"DIV",{class:!0});var x=R(h);d(j.$$.fragment,x),ve=o(x),X=f(x,"P",{"data-svelte-h":!0}),E(X)!=="svelte-v6pak5"&&(X.textContent=Ee),xe=o(x),z=f(x,"P",{"data-svelte-h":!0}),E(z)!=="svelte-1adbar6"&&(z.textContent=Pe),ye=o(x),d(M.$$.fragment,x),x.forEach(n),ae=o(e),d(D.$$.fragment,e),se=o(e),T=f(e,"DIV",{class:!0});var $e=R(T);d(G.$$.fragment,$e),Te=o($e),B=f($e,"P",{"data-svelte-h":!0}),E(B)!=="svelte-ysgxyb"&&(B.textContent=Ie),$e.forEach(n),ie=o(e),d(L.$$.fragment,e),de=o(e),w=f(e,"DIV",{class:!0});var _e=R(w);d(U.$$.fragment,_e),we=o(_e),A=f(_e,"P",{"data-svelte-h":!0}),E(A)!=="svelte-oel36i"&&(A.textContent=Je),_e.forEach(n),ce=o(e),d(H.$$.fragment,e),pe=o(e),d(F.$$.fragment,e),me=o(e),v=f(e,"DIV",{class:!0});var O=R(v);d(V.$$.fragment,O),Ce=o(O),Y=f(O,"P",{"data-svelte-h":!0}),E(Y)!=="svelte-1s7s7e5"&&(Y.textContent=je),Me=o(O),K=f(O,"P",{"data-svelte-h":!0}),E(K)!=="svelte-16266qf"&&(K.innerHTML=De),O.forEach(n),ke=o(e),d(Z.$$.fragment,e),ge=o(e),C=f(e,"DIV",{class:!0});var be=R(C);d(q.$$.fragment,be),Ne=o(be),Q=f(be,"P",{"data-svelte-h":!0}),E(Q)!=="svelte-ui0v8u"&&(Q.textContent=Ge),be.forEach(n),ue=o(e),d(S.$$.fragment,e),fe=o(e),ee=f(e,"P",{}),R(ee).forEach(n),this.h()},h(){W(s,"name","hf:doc:metadata"),W(s,"content",Be),W(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){g(document.head,s),l(e,P,t),l(e,y,t),l(e,$,t),c(_,e,t),l(e,a,t),c(b,e,t),l(e,re,t),c(I,e,t),l(e,oe,t),c(J,e,t),l(e,le,t),l(e,h,t),c(j,h,null),g(h,ve),g(h,X),g(h,xe),g(h,z),g(h,ye),c(M,h,null),l(e,ae,t),c(D,e,t),l(e,se,t),l(e,T,t),c(G,T,null),g(T,Te),g(T,B),l(e,ie,t),c(L,e,t),l(e,de,t),l(e,w,t),c(U,w,null),g(w,we),g(w,A),l(e,ce,t),c(H,e,t),l(e,pe,t),c(F,e,t),l(e,me,t),l(e,v,t),c(V,v,null),g(v,Ce),g(v,Y),g(v,Me),g(v,K),l(e,ke,t),c(Z,e,t),l(e,ge,t),l(e,C,t),c(q,C,null),g(C,Ne),g(C,Q),l(e,ue,t),c(S,e,t),l(e,fe,t),l(e,ee,t),he=!0},p(e,[t]){const x={};t&2&&(x.$$scope={dirty:t,ctx:e}),M.$set(x)},i(e){he||(p(_.$$.fragment,e),p(b.$$.fragment,e),p(I.$$.fragment,e),p(J.$$.fragment,e),p(j.$$.fragment,e),p(M.$$.fragment,e),p(D.$$.fragment,e),p(G.$$.fragment,e),p(L.$$.fragment,e),p(U.$$.fragment,e),p(H.$$.fragment,e),p(F.$$.fragment,e),p(V.$$.fragment,e),p(Z.$$.fragment,e),p(q.$$.fragment,e),p(S.$$.fragment,e),he=!0)},o(e){m(_.$$.fragment,e),m(b.$$.fragment,e),m(I.$$.fragment,e),m(J.$$.fragment,e),m(j.$$.fragment,e),m(M.$$.fragment,e),m(D.$$.fragment,e),m(G.$$.fragment,e),m(L.$$.fragment,e),m(U.$$.fragment,e),m(H.$$.fragment,e),m(F.$$.fragment,e),m(V.$$.fragment,e),m(Z.$$.fragment,e),m(q.$$.fragment,e),m(S.$$.fragment,e),he=!1},d(e){e&&(n(P),n(y),n($),n(a),n(re),n(oe),n(le),n(h),n(ae),n(se),n(T),n(ie),n(de),n(w),n(ce),n(pe),n(me),n(v),n(ke),n(ge),n(C),n(ue),n(fe),n(ee)),n(s),k(_,e),k(b,e),k(I,e),k(J,e),k(j),k(M),k(D,e),k(G),k(L,e),k(U),k(H,e),k(F,e),k(V),k(Z,e),k(q),k(S,e)}}}const Be='{"title":"Kernels API Reference","local":"kernels-api-reference","sections":[{"title":"Main Functions","local":"main-functions","sections":[{"title":"get_kernel","local":"kernels.get_kernel","sections":[],"depth":3},{"title":"get_local_kernel","local":"kernels.get_local_kernel","sections":[],"depth":3},{"title":"has_kernel","local":"kernels.has_kernel","sections":[],"depth":3}],"depth":2},{"title":"Loading locked kernels","local":"loading-locked-kernels","sections":[{"title":"load_kernel","local":"kernels.load_kernel","sections":[],"depth":3},{"title":"get_locked_kernel","local":"kernels.get_locked_kernel","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ae(ne){return Ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nt extends Fe{constructor(s){super(),Ve(this,s,Ae,ze,Le,{})}}export{nt as component}; | |
Xet Storage Details
- Size:
- 15.9 kB
- Xet hash:
- abfc3d99f8b066f1d073c8e99287cb49ea3d048cb9547f59a192c593a588ee53
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.