import{s as Tt,o as Ut,n as P}from"../chunks/scheduler.f3b1e791.js";import{S as Jt,i as kt,e as w,s as a,c as d,h as bt,a as g,d as s,b as o,f as $,g as y,j as U,k as j,l as i,m as p,n as M,t as u,o as f,p as h}from"../chunks/index.023a9934.js";import{C as $t}from"../chunks/CopyLLMTxtMenu.ee636735.js";import{D as C,E as q}from"../chunks/ExampleCodeBlock.1b5fd494.js";import{C as K}from"../chunks/CodeBlock.5aa52fca.js";import{H as b,E as jt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.9b009efe.js";function _t(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5ubiUyMGFzJTIwbm4lMEElMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMHVzZV9rZXJuZWxfZm9yd2FyZF9mcm9tX2h1YiUwQWZyb20lMjBrZXJuZWxzJTIwaW1wb3J0JTIwTW9kZSUyQyUyMGtlcm5lbGl6ZSUwQSUwQSU0MHVzZV9rZXJuZWxfZm9yd2FyZF9mcm9tX2h1YiglMjJNeUN1c3RvbUxheWVyJTIyKSUwQWNsYXNzJTIwTXlDdXN0b21MYXllcihubi5Nb2R1bGUpJTNBJTBBJTIwJTIwJTIwJTIwZGVmJTIwX19pbml0X18oc2VsZiUyQyUyMGhpZGRlbl9zaXplKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN1cGVyKCkuX19pbml0X18oKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNlbGYuaGlkZGVuX3NpemUlMjAlM0QlMjBoaWRkZW5fc2l6ZSUwQSUwQSUyMCUyMCUyMCUyMGRlZiUyMGZvcndhcmQoc2VsZiUyQyUyMHglM0ElMjB0b3JjaC5UZW5zb3IpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwb3JpZ2luYWwlMjBpbXBsZW1lbnRhdGlvbiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMHglMEElMEFtb2RlbCUyMCUzRCUyME15Q3VzdG9tTGF5ZXIoNzY4KSUwQSUwQSUyMyUyMFRoZSUyMGxheWVyJTIwY2FuJTIwbm93JTIwYmUlMjBrZXJuZWxpemVkJTNBJTBBJTIzJTIwbW9kZWwlMjAlM0QlMjBrZXJuZWxpemUobW9kZWwlMkMlMjBtb2RlJTNETW9kZS5UUkFJTklORyUyMCU3QyUyME1vZGUuVE9SQ0hfQ09NUElMRSUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> use_kernel_forward_from_hub
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> Mode, kernelize

<span class="hljs-meta">@use_kernel_forward_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;MyCustomLayer&quot;</span></span>)</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyCustomLayer</span>(nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, hidden_size</span>):
        <span class="hljs-built_in">super</span>().__init__()
        self.hidden_size = hidden_size

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x: torch.Tensor</span>):
        <span class="hljs-comment"># original implementation</span>
        <span class="hljs-keyword">return</span> x

model = MyCustomLayer(<span class="hljs-number">768</span>)

<span class="hljs-comment"># The layer can now be kernelized:</span>
<span class="hljs-comment"># model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE, device=&quot;cuda&quot;)</span>`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p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jBtb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLlRSQUlOSU5HJTIwJTdDJTIwTW9kZS5UT1JDSF9DT01QSUxFJTJDJTIwZGV2aWNlJTNEJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> use_kernel_func_from_hub
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> Mode, kernelize

<span class="hljs-meta">@use_kernel_func_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;my_custom_func&quot;</span></span>)</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">my_custom_func</span>(<span class="hljs-params">x: torch.Tensor</span>):
    <span class="hljs-comment"># Original implementation</span>
    <span class="hljs-keyword">return</span> x

<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModel</span>(torch.nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):
        <span class="hljs-built_in">super</span>().__init__()
        self.fn = my_custom_func

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x</span>):
        <span class="hljs-keyword">return</span> self.fn(x)

model = MyModel()

<span class="hljs-comment"># The layer can now be kernelized:</span>
<span class="hljs-comment"># model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE, device=&quot;cuda&quot;)</span>`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Ct(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjByZXBsYWNlX2tlcm5lbF9mb3J3YXJkX2Zyb21faHViJTBBaW1wb3J0JTIwdG9yY2gubm4lMjBhcyUyMG5uJTBBJTBBcmVwbGFjZV9rZXJuZWxfZm9yd2FyZF9mcm9tX2h1Yihubi5MYXllck5vcm0lMkMlMjAlMjJMYXllck5vcm0lMjIp",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> replace_kernel_forward_from_hub
<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn

replace_kernel_forward_from_hub(nn.LayerNorm, <span class="hljs-string">&quot;LayerNorm&quot;</span>)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function vt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5ubiUyMGFzJTIwbm4lMEFmcm9tJTIwdG9yY2gubm4lMjBpbXBvcnQlMjBmdW5jdGlvbmFsJTIwYXMlMjBGJTBBJTBBZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjB1c2Vfa2VybmVsX2ZvcndhcmRfZnJvbV9odWIlMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMHVzZV9rZXJuZWxfbWFwcGluZyUyQyUyMExheWVyUmVwb3NpdG9yeSUyQyUyMERldmljZSUwQWZyb20lMjBrZXJuZWxzJTIwaW1wb3J0JTIwTW9kZSUyQyUyMGtlcm5lbGl6ZSUwQSUwQ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GUlMjBtYXBwaW5nJTIwZm9yJTIwdGhlJTIwZHVyYXRpb24lMjBvZiUyMHRoZSUyMGNvbnRleHQuJTBBd2l0aCUyMHVzZV9rZXJuZWxfbWFwcGluZyhtYXBwaW5nKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMGtlcm5lbGl6ZSUyMHVzZXMlMjB0aGUlMjB0ZW1wb3JhcnklMjBtYXBwaW5nJTBBJTIwJTIwJTIwJTIwbW9kZWwlMjAlM0QlMjBrZXJuZWxpemUobW9kZWwlMkMlMjBtb2RlJTNETW9kZS5UUkFJTklORyUyMCU3QyUyME1vZGUuVE9SQ0hfQ09NUElMRSUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTBBJTBBJTIzJTIwT3V0c2lkZSUyMHRoZSUyMGNvbnRleHQlMkMlMjBvcmlnaW5hbCUyMG1hcHBpbmdzJTIwYXJlJTIwcmVzdG9yZWQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn
<span class="hljs-keyword">from</span> torch.nn <span class="hljs-keyword">import</span> functional <span class="hljs-keyword">as</span> F

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> use_kernel_forward_from_hub
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> use_kernel_mapping, LayerRepository, Device
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> Mode, kernelize

<span class="hljs-comment"># Define a mapping</span>
mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>
        )
    }
}

<span class="hljs-meta">@use_kernel_forward_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;SiluAndMul&quot;</span></span>)</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">SiluAndMul</span>(nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x: torch.Tensor</span>) -&gt; torch.Tensor:
        d = x.shape[-<span class="hljs-number">1</span>] // <span class="hljs-number">2</span>
        <span class="hljs-keyword">return</span> F.silu(x[..., :d]) * x[..., d:]

model = SiluAndMul()

<span class="hljs-comment"># Use the mapping for the duration of the context.</span>
<span class="hljs-keyword">with</span> use_kernel_mapping(mapping):
    <span class="hljs-comment"># kernelize uses the temporary mapping</span>
    model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE, device=<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># Outside the context, original mappings are restored</span>`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function xt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBMYXllclJlcG9zaXRvcnklMkMlMjByZWdpc3Rlcl9rZXJuZWxfbWFwcGluZyUyQyUyME1vZGUlMEElMEElMjMlMjBTaW1wbGUlMjBtYXBwaW5nJTIwZm9yJTIwYSUyMHNpbmdsZSUyMGtlcm5lbCUyMHBlciUyMGRldmljZSUwQWtlcm5lbF9sYXllcl9tYXBwaW5nJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIyTGxhbWFSTVNOb3JtJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyY3VkYSUyMiUzQSUyMExheWVyUmVwb3NpdG9yeSglMEElMjA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JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmVyc2lvbiUzRDElMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwTW9kZS5JTkZFUkVOQ0UlM0ElMjBMYXllclJlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMnVzZXJuYW1lJTJGaW5mZXJlbmNlLWtlcm5lbHMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyRmFzdEF0dGVudGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHZlcnNpb24lM0QxJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMCU3RCUwQSU3RCUwQXJlZ2lzdGVyX2tlcm5lbF9tYXBwaW5nKGFkdmFuY2VkX21hcHBpbmcp",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> LayerRepository, register_kernel_mapping, Mode

<span class="hljs-comment"># Simple mapping for a single kernel per device</span>
kernel_layer_mapping = {
    <span class="hljs-string">&quot;LlamaRMSNorm&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/layer_norm&quot;</span>,
            layer_name=<span class="hljs-string">&quot;LlamaRMSNorm&quot;</span>,
            version=<span class="hljs-number">1</span>,
        ),
    },
}
register_kernel_mapping(kernel_layer_mapping)

<span class="hljs-comment"># Advanced mapping with mode-specific kernels</span>
advanced_mapping = {
    <span class="hljs-string">&quot;MultiHeadAttention&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: {
            Mode.TRAINING: LayerRepository(
                repo_id=<span class="hljs-string">&quot;username/training-kernels&quot;</span>,
                layer_name=<span class="hljs-string">&quot;TrainingAttention&quot;</span>,
                version=<span class="hljs-number">1</span>,
            ),
            Mode.INFERENCE: LayerRepository(
                repo_id=<span class="hljs-string">&quot;username/inference-kernels&quot;</span>,
                layer_name=<span class="hljs-string">&quot;FastAttention&quot;</span>,
                version=<span class="hljs-number">1</span>,
            ),
        }
    }
}
register_kernel_mapping(advanced_mapping)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Bt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5ubiUyMGFzJTIwbm4lMEElMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMGtlcm5lbGl6ZSUyQyUyME1vZGUlMkMlMjB1c2Vfa2VybmVsX21hcHBpbmclMkMlMjBMYXllclJlcG9zaXRvcnklMEFmcm9tJTIwa2VybmVscyUyMGltcG9ydCUyMHVzZV9rZXJuZWxfZm9yd2FyZF9mcm9tX2h1YiUwQSUwQSU0MHVzZV9rZXJuZWxfZm9yd2FyZF9mcm9tX2h1YiglMjJTaWx1QW5kTXVsJTIyKSUwQWNsYXNzJTIwU2lsdUFuZE11bChubi5Nb2R1bGUpJTNBJTBBJTIwJTIwJTIwJTIwZGVmJTIwZm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klMEElMEElMjMlMjBLZXJuZWxpemUlMjBmb3IlMjBpbmZlcmVuY2UlMEF3aXRoJTIwdXNlX2tlcm5lbF9tYXBwaW5nKG1hcHBpbmcpJTNBJTBBJTIwJTIwJTIwJTIwa2VybmVsaXplZF9tb2RlbCUyMCUzRCUyMGtlcm5lbGl6ZShtb2RlbCUyQyUyMG1vZGUlM0RNb2RlLlRSQUlOSU5HJTIwJTdDJTIwTW9kZS5UT1JDSF9DT01QSUxFKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> kernelize, Mode, use_kernel_mapping, LayerRepository
<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> use_kernel_forward_from_hub

<span class="hljs-meta">@use_kernel_forward_from_hub(<span class="hljs-params"><span class="hljs-string">&quot;SiluAndMul&quot;</span></span>)</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">SiluAndMul</span>(nn.Module):
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, x: torch.Tensor</span>) -&gt; torch.Tensor:
        d = x.shape[-<span class="hljs-number">1</span>] // <span class="hljs-number">2</span>
        <span class="hljs-keyword">return</span> F.silu(x[..., :d]) * x[..., d:]

mapping = {
    <span class="hljs-string">&quot;SiluAndMul&quot;</span>: {
        <span class="hljs-string">&quot;cuda&quot;</span>: LayerRepository(
            repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
            layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
            version=<span class="hljs-number">1</span>,
        )
    }
}

<span class="hljs-comment"># Create and kernelize a model</span>
model = nn.Sequential(
    nn.Linear(<span class="hljs-number">1024</span>, <span class="hljs-number">2048</span>, device=<span class="hljs-string">&quot;cuda&quot;</span>),
    SiluAndMul(),
)

<span class="hljs-comment"># Kernelize for inference</span>
<span class="hljs-keyword">with</span> use_kernel_mapping(mapping):
    kernelized_model = kernelize(model, mode=Mode.TRAINING | Mode.TORCH_COMPILE)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Zt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBEZXZpY2UlMkMlMjBDVURBUHJvcGVydGllcyUwQSUwQSUyMyUyMEJhc2ljJTIwQ1VEQSUyMGRldmljZSUwQWN1ZGFfZGV2aWNlJTIwJTNEJTIwRGV2aWNlKHR5cGUlM0QlMjJjdWRhJTIyKSUwQSUwQSUyMyUyMENVREElMjBkZXZpY2UlMjB3aXRoJTIwc3BlY2lmaWMlMjBjYXBhYmlsaXR5JTIwcmVxdWlyZW1lbnRzJTBBY3VkYV9kZXZpY2Vfd2l0aF9wcm9wcyUyMCUzRCUyMERldmljZSglMEElMjAlMjAlMjAlMjB0eXBlJTNEJTIyY3VkYSUyMiUyQyUwQSUyMCUyMCUyMCUyMHByb3BlcnRpZXMlM0RDVURBUHJvcGVydGllcyhtaW5fY2FwYWJpbGl0eSUzRDc1JTJDJTIwbWF4X2NhcGFiaWxpdHklM0Q5MCklMEEpJTBBJTBBJTIzJTIwTVBTJTIwZGV2aWNlJTIwZm9yJTIwQXBwbGUlMjBTaWxpY29uJTBBbXBzX2RldmljZSUyMCUzRCUyMERldmljZSh0eXBlJTNEJTIybXBzJTIyKSUwQSUwQSUyMyUyMFhQVSUyMGRldmljZSUyMChlLmcuJTJDJTIwSW50ZWwoUiklMjBEYXRhJTIwQ2VudGVyJTIwR1BVJTIwTWF4JTIwMTU1MCklMEF4cHVfZGV2aWNlJTIwJTNEJTIwRGV2aWNlKHR5cGUlM0QlMjJ4cHUlMjIpJTBBJTBBJTIzJTIwTlBVJTIwZGV2aWNlJTIwKEh1YXdlaSUyMEFzY2VuZCklMEFucHVfZGV2aWNlJTIwJTNEJTIwRGV2aWNlKHR5cGUlM0QlMjJucHUlMjIp",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> Device, CUDAProperties

<span class="hljs-comment"># Basic CUDA device</span>
cuda_device = Device(<span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># CUDA device with specific capability requirements</span>
cuda_device_with_props = Device(
    <span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;cuda&quot;</span>,
    properties=CUDAProperties(min_capability=<span class="hljs-number">75</span>, max_capability=<span class="hljs-number">90</span>)
)

<span class="hljs-comment"># MPS device for Apple Silicon</span>
mps_device = Device(<span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;mps&quot;</span>)

<span class="hljs-comment"># XPU device (e.g., Intel(R) Data Center GPU Max 1550)</span>
xpu_device = Device(<span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;xpu&quot;</span>)

<span class="hljs-comment"># NPU device (Huawei Ascend)</span>
npu_device = Device(<span class="hljs-built_in">type</span>=<span class="hljs-string">&quot;npu&quot;</span>)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Rt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBGdW5jUmVwb3NpdG9yeSUwQSUwQSUyMyUyMFJlZmVyZW5jZSUyMGElMjBzcGVjaWZpYyUyMGxheWVyJTIwYnklMjByZXZpc2lvbiUwQWxheWVyX3JlcG8lMjAlM0QlMjBGdW5jUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjByZXBvX2lkJTNEJTIya2VybmVscy1jb21tdW5pdHklMkZhY3RpdmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwZnVuY19uYW1lJTNEJTIyc2lsdV9hbmRfbXVsJTIyJTJDJTBBKSUwQSUwQSUyMyUyMFJlZmVyZW5jZSUyMGElMjBsYXllciUyMGJ5JTIwdmVyc2lvbiUwQWxheWVyX3JlcG9fdmVyc2lvbmVkJTIwJTNEJTIwRnVuY1JlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMmtlcm5lbHMtY29tbXVuaXR5JTJGcmVsdSUyMiUyQyUwQSUyMCUyMCUyMCUyMGZ1bmNfbmFtZSUzRCUyMnJlbHUlMjIlMkMlMEElMjAlMjAlMjAlMjB2ZXJzaW9uJTNEMSUwQSk=",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> FuncRepository

<span class="hljs-comment"># Reference a specific layer by revision</span>
layer_repo = FuncRepository(
    repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
    func_name=<span class="hljs-string">&quot;silu_and_mul&quot;</span>,
)

<span class="hljs-comment"># Reference a layer by version</span>
layer_repo_versioned = FuncRepository(
    repo_id=<span class="hljs-string">&quot;kernels-community/relu&quot;</span>,
    func_name=<span class="hljs-string">&quot;relu&quot;</span>,
    version=<span class="hljs-number">1</span>
)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Et(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBMYXllclJlcG9zaXRvcnklMEElMEElMjMlMjBSZWZlcmVuY2UlMjBhJTIwc3BlY2lmaWMlMjBsYXllciUyMGJ5JTIwcmV2aXNpb24lMEFsYXllcl9yZXBvJTIwJTNEJTIwTGF5ZXJSZXBvc2l0b3J5KCUwQSUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJrZXJuZWxzLWNvbW11bml0eSUyRmFjdGl2YXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyU2lsdUFuZE11bCUyMiUyQyUwQSUyMCUyMCUyMCUyMHZlcnNpb24lM0QxJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> LayerRepository

<span class="hljs-comment"># Reference a specific layer by revision</span>
layer_repo = LayerRepository(
    repo_id=<span class="hljs-string">&quot;kernels-community/activation&quot;</span>,
    layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
    version=<span class="hljs-number">1</span>,
)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Gt(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMHBhdGhsaWIlMjBpbXBvcnQlMjBQYXRoJTBBJTBBZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBMb2NhbEZ1bmNSZXBvc2l0b3J5JTBBJTBBJTIzJTIwUmVmZXJlbmNlJTIwYSUyMHNwZWNpZmljJTIwbGF5ZXIlMjBieSUyMHJldmlzaW9uJTBBbGF5ZXJfcmVwbyUyMCUzRCUyMExvY2FsRnVuY1JlcG9zaXRvcnkoJTBBJTIwJTIwJTIwJTIwcmVwb19wYXRoJTNEUGF0aCglMjIlMkZob21lJTJGZGFuaWVsJTJGa2VybmVscyUyRmFjdGl2YXRpb24lMjIpJTJDJTBBJTIwJTIwJTIwJTIwZnVuY19uYW1lJTNEJTIyc2lsdV9hbmRfbXVsJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> LocalFuncRepository

<span class="hljs-comment"># Reference a specific layer by revision</span>
layer_repo = LocalFuncRepository(
    repo_path=Path(<span class="hljs-string">&quot;/home/daniel/kernels/activation&quot;</span>),
    func_name=<span class="hljs-string">&quot;silu_and_mul&quot;</span>,
)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function St(k){let t,J="Example:",m,r,c;return r=new K({props:{code:"ZnJvbSUyMHBhdGhsaWIlMjBpbXBvcnQlMjBQYXRoJTBBJTBBZnJvbSUyMGtlcm5lbHMlMjBpbXBvcnQlMjBMb2NhbExheWVyUmVwb3NpdG9yeSUwQSUwQSUyMyUyMFJlZmVyZW5jZSUyMGElMjBzcGVjaWZpYyUyMGxheWVyJTIwYnklMjByZXZpc2lvbiUwQWxheWVyX3JlcG8lMjAlM0QlMjBMb2NhbExheWVyUmVwb3NpdG9yeSglMEElMjAlMjAlMjAlMjByZXBvX3BhdGglM0RQYXRoKCUyMiUyRmhvbWUlMkZkYW5pZWwlMkZrZXJuZWxzJTJGYWN0aXZhdGlvbiUyMiklMkMlMEElMjAlMjAlMjAlMjBsYXllcl9uYW1lJTNEJTIyU2lsdUFuZE11bCUyMiUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path

<span class="hljs-keyword">from</span> kernels <span class="hljs-keyword">import</span> LocalLayerRepository

<span class="hljs-comment"># Reference a specific layer by revision</span>
layer_repo = LocalLayerRepository(
    repo_path=Path(<span class="hljs-string">&quot;/home/daniel/kernels/activation&quot;</span>),
    layer_name=<span class="hljs-string">&quot;SiluAndMul&quot;</span>,
)`,wrap:!1}}),{c(){t=w("p"),t.textContent=J,m=a(),d(r.$$.fragment)},l(n){t=g(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-11lpom8"&&(t.textContent=J),m=o(n),y(r.$$.fragment,n)},m(n,T){p(n,t,T),p(n,m,T),M(r,n,T),c=!0},p:P,i(n){c||(u(r.$$.fragment,n),c=!0)},o(n){f(r.$$.fragment,n),c=!1},d(n){n&&(s(t),s(m)),h(r,n)}}}function Wt(k){let t,J,m,r,c,n,T,_n,ye,In,Me,Cn,v,ue,pl,He,Yl="Decorator factory that makes a layer extensible using the specified layer name.",il,De,Hl=`This is a decorator factory that returns a decorator which prepares a layer class to use kernels from the
Hugging Face Hub.`,cl,ne,vn,fe,xn,_,he,ml,qe,Dl="Decorator that makes a function extensible using the specified function name.",dl,Pe,ql=`This is a decorator factory that returns a decorator which prepares a function to use kernels from the
Hugging Face Hub.`,yl,Ke,Pl=`The function will be exposed as an instance of <code>torch.nn.Module</code> in which
the function is called in <code>forward</code>. For the function to be properly
kernelized, it <strong>must</strong> be a member of another <code>torch.nn.Module</code> that is
part of the model (see the example).`,Ml,le,Bn,we,Zn,x,ge,ul,Oe,Kl="Function that prepares a layer class to use kernels from the Hugging Face Hub.",fl,en,Ol=`It is recommended to use <a href="/docs/kernels/main/en/api/layers#kernels.use_kernel_forward_from_hub">use_kernel_forward_from_hub()</a> decorator instead.
This function should only be used as a last resort to extend third-party layers,
it is inherently fragile since the member variables and <code>forward</code> signature
of such a layer can change.`,hl,te,Rn,Te,En,Ue,Gn,B,Je,wl,nn,et="Context manager that sets a kernel mapping for the duration of the context.",gl,ln,nt=`This function allows temporary kernel mappings to be applied within a specific context, enabling different
kernel configurations for different parts of your code.`,Tl,se,Sn,ke,Wn,Z,be,Ul,tn,lt="Register a global mapping between layer names and their corresponding kernel implementations.",Jl,sn,tt=`This function allows you to register a mapping between a layer name and the corresponding kernel(s) to use,
depending on the device and mode. This should be used in conjunction with <a href="/docs/kernels/main/en/api/layers#kernels.kernelize">kernelize()</a>.`,kl,re,An,$e,Qn,je,Vn,R,_e,bl,rn,st="Replace layer forward methods with optimized kernel implementations.",$l,an,rt=`This function iterates over all modules in the model and replaces the <code>forward</code> method of extensible layers
for which kernels are registered using <a href="/docs/kernels/main/en/api/layers#kernels.register_kernel_mapping">register_kernel_mapping()</a> or <a href="/docs/kernels/main/en/api/layers#kernels.use_kernel_mapping">use_kernel_mapping()</a>.`,jl,ae,Nn,Ie,Xn,Ce,Fn,I,ve,_l,on,at="Represents a compute device with optional properties.",Il,pn,ot=`This class encapsulates device information including device type and optional device-specific properties
like CUDA capabilities.`,Cl,oe,vl,pe,xe,xl,cn,pt="Run class validators on the instance.",Ln,Be,zn,E,Ze,Bl,mn,it="Kernelize mode",Zl,dn,ct=`The <code>Mode</code> flag is used by <a href="/docs/kernels/main/en/api/layers#kernels.kernelize">kernelize()</a> to select kernels for the given mode. Mappings can be registered for
specific modes.`,Rl,yn,mt=`Note:
Different modes can be combined. For instance, <code>INFERENCE | TORCH_COMPILE</code> should be used for layers that
are used for inference <em>with</em> <code>torch.compile</code>.`,Yn,Re,Hn,W,Ee,El,Mn,dt="Repository and name of a function for kernel mapping.",Gl,ie,Dn,Ge,qn,A,Se,Sl,un,yt="Repository and name of a layer for kernel mapping.",Wl,ce,Pn,We,Kn,Q,Ae,Al,fn,Mt="Repository and function name from a local directory for kernel mapping.",Ql,me,On,Qe,el,V,Ve,Vl,hn,ut="Repository from a local directory for kernel mapping.",Nl,de,nl,Ne,ll,N,Xe,Xl,wn,ft="Repository and name of a function.",Fl,gn,ht=`In contrast to <code>FuncRepository</code>, this class uses repositories that
are locked inside a project.`,tl,Fe,sl,X,Le,Ll,Tn,wt="Repository and name of a layer.",zl,Un,gt=`In contrast to <code>LayerRepository</code>, this class uses repositories that
are locked inside a project.`,rl,ze,al,jn,ol;return c=new $t({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new b({props:{title:"Layers API Reference",local:"layers-api-reference",headingTag:"h1"}}),ye=new b({props:{title:"Making layers kernel-aware",local:"making-layers-kernel-aware",headingTag:"h2"}}),Me=new b({props:{title:"use_kernel_forward_from_hub",local:"kernels.use_kernel_forward_from_hub",headingTag:"h3"}}),ue=new C({props:{name:"kernels.use_kernel_forward_from_hub",anchor:"kernels.use_kernel_forward_from_hub",parameters:[{name:"layer_name",val:": str"}],parametersDescription:[{anchor:"kernels.use_kernel_forward_from_hub.layer_name",description:`<strong>layer_name</strong> (<code>str</code>) &#x2014;
The name of the layer to use for kernel lookup in registered mappings.`,name:"layer_name"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/layer.py#L240",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A decorator function that can be applied to layer classes.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Callable</code></p>
`}}),ne=new q({props:{anchor:"kernels.use_kernel_forward_from_hub.example",$$slots:{default:[_t]},$$scope:{ctx:k}}}),fe=new b({props:{title:"use_kernel_func_from_hub",local:"kernels.use_kernel_func_from_hub",headingTag:"h3"}}),he=new C({props:{name:"kernels.use_kernel_func_from_hub",anchor:"kernels.use_kernel_func_from_hub",parameters:[{name:"func_name",val:": str"}],parametersDescription:[{anchor:"kernels.use_kernel_func_from_hub.func_name",description:`<strong>func_name</strong> (<code>str</code>) &#x2014;
The name of the function name to use for kernel lookup in registered mappings.`,name:"func_name"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/func.py#L158",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A decorator function that can be applied to layer classes.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Callable</code></p>
`}}),le=new q({props:{anchor:"kernels.use_kernel_func_from_hub.example",$$slots:{default:[It]},$$scope:{ctx:k}}}),we=new b({props:{title:"replace_kernel_forward_from_hub",local:"kernels.replace_kernel_forward_from_hub",headingTag:"h3"}}),ge=new C({props:{name:"kernels.replace_kernel_forward_from_hub",anchor:"kernels.replace_kernel_forward_from_hub",parameters:[{name:"layer_name",val:": str"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/layer.py#L217"}}),te=new q({props:{anchor:"kernels.replace_kernel_forward_from_hub.example",$$slots:{default:[Ct]},$$scope:{ctx:k}}}),Te=new b({props:{title:"Registering kernel mappings",local:"registering-kernel-mappings",headingTag:"h2"}}),Ue=new b({props:{title:"use_kernel_mapping",local:"kernels.use_kernel_mapping",headingTag:"h3"}}),Je=new C({props:{name:"kernels.use_kernel_mapping",anchor:"kernels.use_kernel_mapping",parameters:[{name:"mapping",val:": dict[str, dict[Device | str, RepositoryProtocol | dict[Mode, RepositoryProtocol]]]"},{name:"inherit_mapping",val:": bool = True"}],parametersDescription:[{anchor:"kernels.use_kernel_mapping.mapping",description:`<strong>mapping</strong> (<code>dict[str, dict[Union[Device, str], Union[LayerRepositoryProtocol, dict[Mode, LayerRepositoryProtocol]]]]</code>) &#x2014;
The kernel mapping to apply. Maps layer names to device-specific kernel configurations.`,name:"mapping"},{anchor:"kernels.use_kernel_mapping.inherit_mapping",description:`<strong>inherit_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
When <code>True</code>, the current mapping will be extended by <code>mapping</code> inside the context. When <code>False</code>,
only <code>mapping</code> is used inside the context.`,name:"inherit_mapping"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/kernelize.py#L17",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Context manager that handles the temporary kernel mapping.</p>
`}}),se=new q({props:{anchor:"kernels.use_kernel_mapping.example",$$slots:{default:[vt]},$$scope:{ctx:k}}}),ke=new b({props:{title:"register_kernel_mapping",local:"kernels.register_kernel_mapping",headingTag:"h3"}}),be=new C({props:{name:"kernels.register_kernel_mapping",anchor:"kernels.register_kernel_mapping",parameters:[{name:"mapping",val:": dict[str, dict[Device | str, RepositoryProtocol | dict[Mode, RepositoryProtocol]]]"},{name:"inherit_mapping",val:": bool = True"}],parametersDescription:[{anchor:"kernels.register_kernel_mapping.mapping",description:`<strong>mapping</strong> (<code>dict[str, dict[Union[Device, str], Union[RepositoryProtocol, dict[Mode, RepositoryProtocol]]]]</code>) &#x2014;
The kernel mapping to register globally. Maps layer names to device-specific kernels.
The mapping can specify different kernels for different modes (training, inference, etc.).`,name:"mapping"},{anchor:"kernels.register_kernel_mapping.inherit_mapping",description:`<strong>inherit_mapping</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
When <code>True</code>, the current mapping will be extended by <code>mapping</code>. When <code>False</code>, the existing mappings
are erased before adding <code>mapping</code>.`,name:"inherit_mapping"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/kernelize.py#L97"}}),re=new q({props:{anchor:"kernels.register_kernel_mapping.example",$$slots:{default:[xt]},$$scope:{ctx:k}}}),$e=new b({props:{title:"Kernelizing a model",local:"kernelizing-a-model",headingTag:"h2"}}),je=new b({props:{title:"kernelize",local:"kernels.kernelize",headingTag:"h3"}}),_e=new C({props:{name:"kernels.kernelize",anchor:"kernels.kernelize",parameters:[{name:"model",val:": 'nn.Module'"},{name:"mode",val:": Mode"},{name:"device",val:": str | 'torch.device' | None = None"},{name:"use_fallback",val:": bool = True"}],parametersDescription:[{anchor:"kernels.kernelize.model",description:`<strong>model</strong> (<code>nn.Module</code>) &#x2014;
The PyTorch model to kernelize.`,name:"model"},{anchor:"kernels.kernelize.mode",description:`<strong>mode</strong> (<a href="/docs/kernels/main/en/api/layers#kernels.Mode">Mode</a>) &#x2014; The mode that the kernel is going to be used in. For example,
<code>Mode.TRAINING | Mode.TORCH_COMPILE</code> kernelizes the model for training with
<code>torch.compile</code>.`,name:"mode"},{anchor:"kernels.kernelize.device",description:`<strong>device</strong> (<code>Union[str, torch.device]</code>, <em>optional</em>) &#x2014;
The device type to load kernels for. Supported device types are: &#x201C;cuda&#x201D;, &#x201C;mps&#x201D;, &#x201C;npu&#x201D;, &#x201C;rocm&#x201D;, &#x201C;xpu&#x201D;.
The device type will be inferred from the model parameters when not provided.`,name:"device"},{anchor:"kernels.kernelize.use_fallback",description:`<strong>use_fallback</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use the original forward method of modules when no compatible kernel could be found.
If set to <code>False</code>, an exception will be raised in such cases.`,name:"use_fallback"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/kernelize.py#L175",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The kernelized model with optimized kernel implementations.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>nn.Module</code></p>
`}}),ae=new q({props:{anchor:"kernels.kernelize.example",$$slots:{default:[Bt]},$$scope:{ctx:k}}}),Ie=new b({props:{title:"Classes",local:"classes",headingTag:"h2"}}),Ce=new b({props:{title:"Device",local:"kernels.Device",headingTag:"h3"}}),ve=new C({props:{name:"class kernels.Device",anchor:"kernels.Device",parameters:[{name:"type",val:": str"},{name:"properties",val:": kernels.layer.device.CUDAProperties | None = None"}],parametersDescription:[{anchor:"kernels.Device.type",description:`<strong>type</strong> (<code>str</code>) &#x2014;
The device type (e.g., &#x201C;cuda&#x201D;, &#x201C;mps&#x201D;, &#x201C;npu&#x201D;, &#x201C;rocm&#x201D;, &#x201C;xpu&#x201D;).`,name:"type"},{anchor:"kernels.Device.properties",description:`<strong>properties</strong> (<code>CUDAProperties</code>, <em>optional</em>) &#x2014;
Device-specific properties. Currently only <code>CUDAProperties</code> is supported for CUDA devices.`,name:"properties"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/device.py#L106"}}),oe=new q({props:{anchor:"kernels.Device.example",$$slots:{default:[Zt]},$$scope:{ctx:k}}}),xe=new C({props:{name:"validate",anchor:"kernels.Device.validate",parameters:[],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/huggingface_hub/dataclasses.py#L247"}}),Be=new b({props:{title:"Mode",local:"kernels.Mode",headingTag:"h3"}}),Ze=new C({props:{name:"class kernels.Mode",anchor:"kernels.Mode",parameters:[{name:"value",val:""},{name:"names",val:" = None"},{name:"module",val:" = None"},{name:"qualname",val:" = None"},{name:"type",val:" = None"},{name:"start",val:" = 1"}],parametersDescription:[{anchor:"kernels.Mode.INFERENCE",description:"<strong>INFERENCE</strong> &#x2014; The kernel is used for inference.",name:"INFERENCE"},{anchor:"kernels.Mode.TRAINING",description:"<strong>TRAINING</strong> &#x2014; The kernel is used for training.",name:"TRAINING"},{anchor:"kernels.Mode.TORCH_COMPILE",description:"<strong>TORCH_COMPILE</strong> &#x2014; The kernel is used with <code>torch.compile</code>.",name:"TORCH_COMPILE"},{anchor:"kernels.Mode.FALLBACK",description:"<strong>FALLBACK</strong> &#x2014; In a kernel mapping, this kernel is used when no other mode matches.",name:"FALLBACK"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/mode.py#L4"}}),Re=new b({props:{title:"FuncRepository",local:"kernels.FuncRepository",headingTag:"h3"}}),Ee=new C({props:{name:"class kernels.FuncRepository",anchor:"kernels.FuncRepository",parameters:[{name:"repo_id",val:": str"},{name:"func_name",val:": str"},{name:"revision",val:": str | None = None"},{name:"version",val:": int | None = None"}],parametersDescription:[{anchor:"kernels.FuncRepository.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) &#x2014;
The Hub repository containing the layer.`,name:"repo_id"},{anchor:"kernels.FuncRepository.func_name",description:`<strong>func_name</strong> (<code>str</code>) &#x2014;
The name of the function within the kernel repository.`,name:"func_name"},{anchor:"kernels.FuncRepository.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific revision (branch, tag, or commit) to download. Cannot be used together with <code>version</code>.`,name:"revision"},{anchor:"kernels.FuncRepository.version",description:`<strong>version</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The kernel version to download. Cannot be used together with <code>revision</code>.`,name:"version"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/func.py#L27"}}),ie=new q({props:{anchor:"kernels.FuncRepository.example",$$slots:{default:[Rt]},$$scope:{ctx:k}}}),Ge=new b({props:{title:"LayerRepository",local:"kernels.LayerRepository",headingTag:"h3"}}),Se=new C({props:{name:"class kernels.LayerRepository",anchor:"kernels.LayerRepository",parameters:[{name:"repo_id",val:": str"},{name:"layer_name",val:": str"},{name:"revision",val:": str | None = None"},{name:"version",val:": int | None = None"}],parametersDescription:[{anchor:"kernels.LayerRepository.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) &#x2014;
The Hub repository containing the layer.`,name:"repo_id"},{anchor:"kernels.LayerRepository.layer_name",description:`<strong>layer_name</strong> (<code>str</code>) &#x2014;
The name of the layer within the kernel repository.`,name:"layer_name"},{anchor:"kernels.LayerRepository.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific revision (branch, tag, or commit) to download. Cannot be used together with <code>version</code>.`,name:"revision"},{anchor:"kernels.LayerRepository.version",description:`<strong>version</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The kernel version to download. Cannot be used together with <code>revision</code>.`,name:"version"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/layer.py#L32"}}),ce=new q({props:{anchor:"kernels.LayerRepository.example",$$slots:{default:[Et]},$$scope:{ctx:k}}}),We=new b({props:{title:"LocalFuncRepository",local:"kernels.LocalFuncRepository",headingTag:"h3"}}),Ae=new C({props:{name:"class kernels.LocalFuncRepository",anchor:"kernels.LocalFuncRepository",parameters:[{name:"repo_path",val:": Path"},{name:"func_name",val:": str"}],parametersDescription:[{anchor:"kernels.LocalFuncRepository.repo_path",description:`<strong>repo_path</strong> (<code>Path</code>) &#x2014;
The local repository containing the layer.`,name:"repo_path"},{anchor:"kernels.LocalFuncRepository.func_name",description:`<strong>func_name</strong> (<code>str</code>) &#x2014;
The name of the function within the kernel repository.`,name:"func_name"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/func.py#L107"}}),me=new q({props:{anchor:"kernels.LocalFuncRepository.example",$$slots:{default:[Gt]},$$scope:{ctx:k}}}),Qe=new b({props:{title:"LocalLayerRepository",local:"kernels.LocalLayerRepository",headingTag:"h3"}}),Ve=new C({props:{name:"class kernels.LocalLayerRepository",anchor:"kernels.LocalLayerRepository",parameters:[{name:"repo_path",val:": Path"},{name:"layer_name",val:": str"}],parametersDescription:[{anchor:"kernels.LocalLayerRepository.repo_path",description:`<strong>repo_path</strong> (<code>Path</code>) &#x2014;
The local repository containing the layer.`,name:"repo_path"},{anchor:"kernels.LocalLayerRepository.layer_name",description:`<strong>layer_name</strong> (<code>str</code>) &#x2014;
The name of the layer within the kernel repository.`,name:"layer_name"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/layer.py#L106"}}),de=new q({props:{anchor:"kernels.LocalLayerRepository.example",$$slots:{default:[St]},$$scope:{ctx:k}}}),Ne=new b({props:{title:"LockedFuncRepository",local:"kernels.LockedFuncRepository",headingTag:"h3"}}),Xe=new C({props:{name:"class kernels.LockedFuncRepository",anchor:"kernels.LockedFuncRepository",parameters:[{name:"repo_id",val:": str"},{name:"lockfile",val:": pathlib.Path | None = None"},{name:"func_name",val:": str"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/func.py#L213"}}),Fe=new b({props:{title:"LockedLayerRepository",local:"kernels.LockedLayerRepository",headingTag:"h3"}}),Le=new C({props:{name:"class kernels.LockedLayerRepository",anchor:"kernels.LockedLayerRepository",parameters:[{name:"repo_id",val:": str"},{name:"lockfile",val:": Path | None = None"},{name:"layer_name",val:": str"}],source:"https://github.com/huggingface/kernels/blob/main/kernels/src/kernels/layer/layer.py#L157"}}),ze=new jt({props:{source:"https://github.com/huggingface/kernels/blob/main/docs/source/api/layers.md"}}),{c(){t=w("meta"),J=a(),m=w("p"),r=a(),d(c.$$.fragment),n=a(),d(T.$$.fragment),_n=a(),d(ye.$$.fragment),In=a(),d(Me.$$.fragment),Cn=a(),v=w("div"),d(ue.$$.fragment),pl=a(),He=w("p"),He.textContent=Yl,il=a(),De=w("p"),De.textContent=Hl,cl=a(),d(ne.$$.fragment),vn=a(),d(fe.$$.fragment),xn=a(),_=w("div"),d(he.$$.fragment),ml=a(),qe=w("p"),qe.textContent=Dl,dl=a(),Pe=w("p"),Pe.textContent=ql,yl=a(),Ke=w("p"),Ke.innerHTML=Pl,Ml=a(),d(le.$$.fragment),Bn=a(),d(we.$$.fragment),Zn=a(),x=w("div"),d(ge.$$.fragment),ul=a(),Oe=w("p"),Oe.textContent=Kl,fl=a(),en=w("p"),en.innerHTML=Ol,hl=a(),d(te.$$.fragment),Rn=a(),d(Te.$$.fragment),En=a(),d(Ue.$$.fragment),Gn=a(),B=w("div"),d(Je.$$.fragment),wl=a(),nn=w("p"),nn.textContent=et,gl=a(),ln=w("p"),ln.textContent=nt,Tl=a(),d(se.$$.fragment),Sn=a(),d(ke.$$.fragment),Wn=a(),Z=w("div"),d(be.$$.fragment),Ul=a(),tn=w("p"),tn.textContent=lt,Jl=a(),sn=w("p"),sn.innerHTML=tt,kl=a(),d(re.$$.fragment),An=a(),d($e.$$.fragment),Qn=a(),d(je.$$.fragment),Vn=a(),R=w("div"),d(_e.$$.fragment),bl=a(),rn=w("p"),rn.textContent=st,$l=a(),an=w("p"),an.innerHTML=rt,jl=a(),d(ae.$$.fragment),Nn=a(),d(Ie.$$.fragment),Xn=a(),d(Ce.$$.fragment),Fn=a(),I=w("div"),d(ve.$$.fragment),_l=a(),on=w("p"),on.textContent=at,Il=a(),pn=w("p"),pn.textContent=ot,Cl=a(),d(oe.$$.fragment),vl=a(),pe=w("div"),d(xe.$$.fragment),xl=a(),cn=w("p"),cn.textContent=pt,Ln=a(),d(Be.$$.fragment),zn=a(),E=w("div"),d(Ze.$$.fragment),Bl=a(),mn=w("p"),mn.textContent=it,Zl=a(),dn=w("p"),dn.innerHTML=ct,Rl=a(),yn=w("p"),yn.innerHTML=mt,Yn=a(),d(Re.$$.fragment),Hn=a(),W=w("div"),d(Ee.$$.fragment),El=a(),Mn=w("p"),Mn.textContent=dt,Gl=a(),d(ie.$$.fragment),Dn=a(),d(Ge.$$.fragment),qn=a(),A=w("div"),d(Se.$$.fragment),Sl=a(),un=w("p"),un.textContent=yt,Wl=a(),d(ce.$$.fragment),Pn=a(),d(We.$$.fragment),Kn=a(),Q=w("div"),d(Ae.$$.fragment),Al=a(),fn=w("p"),fn.textContent=Mt,Ql=a(),d(me.$$.fragment),On=a(),d(Qe.$$.fragment),el=a(),V=w("div"),d(Ve.$$.fragment),Vl=a(),hn=w("p"),hn.textContent=ut,Nl=a(),d(de.$$.fragment),nl=a(),d(Ne.$$.fragment),ll=a(),N=w("div"),d(Xe.$$.fragment),Xl=a(),wn=w("p"),wn.textContent=ft,Fl=a(),gn=w("p"),gn.innerHTML=ht,tl=a(),d(Fe.$$.fragment),sl=a(),X=w("div"),d(Le.$$.fragment),Ll=a(),Tn=w("p"),Tn.textContent=wt,zl=a(),Un=w("p"),Un.innerHTML=gt,rl=a(),d(ze.$$.fragment),al=a(),jn=w("p"),this.h()},l(e){const l=bt("svelte-u9bgzb",document.head);t=g(l,"META",{name:!0,content:!0}),l.forEach(s),J=o(e),m=g(e,"P",{}),$(m).forEach(s),r=o(e),y(c.$$.fragment,e),n=o(e),y(T.$$.fragment,e),_n=o(e),y(ye.$$.fragment,e),In=o(e),y(Me.$$.fragment,e),Cn=o(e),v=g(e,"DIV",{class:!0});var F=$(v);y(ue.$$.fragment,F),pl=o(F),He=g(F,"P",{"data-svelte-h":!0}),U(He)!=="svelte-17ebw3h"&&(He.textContent=Yl),il=o(F),De=g(F,"P",{"data-svelte-h":!0}),U(De)!=="svelte-wgdatn"&&(De.textContent=Hl),cl=o(F),y(ne.$$.fragment,F),F.forEach(s),vn=o(e),y(fe.$$.fragment,e),xn=o(e),_=g(e,"DIV",{class:!0});var G=$(_);y(he.$$.fragment,G),ml=o(G),qe=g(G,"P",{"data-svelte-h":!0}),U(qe)!=="svelte-1gabpyp"&&(qe.textContent=Dl),dl=o(G),Pe=g(G,"P",{"data-svelte-h":!0}),U(Pe)!=="svelte-nc81mu"&&(Pe.textContent=ql),yl=o(G),Ke=g(G,"P",{"data-svelte-h":!0}),U(Ke)!=="svelte-1fgrp05"&&(Ke.innerHTML=Pl),Ml=o(G),y(le.$$.fragment,G),G.forEach(s),Bn=o(e),y(we.$$.fragment,e),Zn=o(e),x=g(e,"DIV",{class:!0});var L=$(x);y(ge.$$.fragment,L),ul=o(L),Oe=g(L,"P",{"data-svelte-h":!0}),U(Oe)!=="svelte-17bjf1v"&&(Oe.textContent=Kl),fl=o(L),en=g(L,"P",{"data-svelte-h":!0}),U(en)!=="svelte-1jnus3p"&&(en.innerHTML=Ol),hl=o(L),y(te.$$.fragment,L),L.forEach(s),Rn=o(e),y(Te.$$.fragment,e),En=o(e),y(Ue.$$.fragment,e),Gn=o(e),B=g(e,"DIV",{class:!0});var z=$(B);y(Je.$$.fragment,z),wl=o(z),nn=g(z,"P",{"data-svelte-h":!0}),U(nn)!=="svelte-4v5vcp"&&(nn.textContent=et),gl=o(z),ln=g(z,"P",{"data-svelte-h":!0}),U(ln)!=="svelte-124m5et"&&(ln.textContent=nt),Tl=o(z),y(se.$$.fragment,z),z.forEach(s),Sn=o(e),y(ke.$$.fragment,e),Wn=o(e),Z=g(e,"DIV",{class:!0});var Y=$(Z);y(be.$$.fragment,Y),Ul=o(Y),tn=g(Y,"P",{"data-svelte-h":!0}),U(tn)!=="svelte-h5yso0"&&(tn.textContent=lt),Jl=o(Y),sn=g(Y,"P",{"data-svelte-h":!0}),U(sn)!=="svelte-wk1xob"&&(sn.innerHTML=tt),kl=o(Y),y(re.$$.fragment,Y),Y.forEach(s),An=o(e),y($e.$$.fragment,e),Qn=o(e),y(je.$$.fragment,e),Vn=o(e),R=g(e,"DIV",{class:!0});var H=$(R);y(_e.$$.fragment,H),bl=o(H),rn=g(H,"P",{"data-svelte-h":!0}),U(rn)!=="svelte-11gfrdt"&&(rn.textContent=st),$l=o(H),an=g(H,"P",{"data-svelte-h":!0}),U(an)!=="svelte-d4cjbf"&&(an.innerHTML=rt),jl=o(H),y(ae.$$.fragment,H),H.forEach(s),Nn=o(e),y(Ie.$$.fragment,e),Xn=o(e),y(Ce.$$.fragment,e),Fn=o(e),I=g(e,"DIV",{class:!0});var S=$(I);y(ve.$$.fragment,S),_l=o(S),on=g(S,"P",{"data-svelte-h":!0}),U(on)!=="svelte-19eu2wi"&&(on.textContent=at),Il=o(S),pn=g(S,"P",{"data-svelte-h":!0}),U(pn)!=="svelte-9t0i4c"&&(pn.textContent=ot),Cl=o(S),y(oe.$$.fragment,S),vl=o(S),pe=g(S,"DIV",{class:!0});var Ye=$(pe);y(xe.$$.fragment,Ye),xl=o(Ye),cn=g(Ye,"P",{"data-svelte-h":!0}),U(cn)!=="svelte-3wcl39"&&(cn.textContent=pt),Ye.forEach(s),S.forEach(s),Ln=o(e),y(Be.$$.fragment,e),zn=o(e),E=g(e,"DIV",{class:!0});var D=$(E);y(Ze.$$.fragment,D),Bl=o(D),mn=g(D,"P",{"data-svelte-h":!0}),U(mn)!=="svelte-wlnf64"&&(mn.textContent=it),Zl=o(D),dn=g(D,"P",{"data-svelte-h":!0}),U(dn)!=="svelte-fr29on"&&(dn.innerHTML=ct),Rl=o(D),yn=g(D,"P",{"data-svelte-h":!0}),U(yn)!=="svelte-x58jtu"&&(yn.innerHTML=mt),D.forEach(s),Yn=o(e),y(Re.$$.fragment,e),Hn=o(e),W=g(e,"DIV",{class:!0});var O=$(W);y(Ee.$$.fragment,O),El=o(O),Mn=g(O,"P",{"data-svelte-h":!0}),U(Mn)!=="svelte-1fbxeta"&&(Mn.textContent=dt),Gl=o(O),y(ie.$$.fragment,O),O.forEach(s),Dn=o(e),y(Ge.$$.fragment,e),qn=o(e),A=g(e,"DIV",{class:!0});var ee=$(A);y(Se.$$.fragment,ee),Sl=o(ee),un=g(ee,"P",{"data-svelte-h":!0}),U(un)!=="svelte-1foq575"&&(un.textContent=yt),Wl=o(ee),y(ce.$$.fragment,ee),ee.forEach(s),Pn=o(e),y(We.$$.fragment,e),Kn=o(e),Q=g(e,"DIV",{class:!0});var Jn=$(Q);y(Ae.$$.fragment,Jn),Al=o(Jn),fn=g(Jn,"P",{"data-svelte-h":!0}),U(fn)!=="svelte-1nb80ft"&&(fn.textContent=Mt),Ql=o(Jn),y(me.$$.fragment,Jn),Jn.forEach(s),On=o(e),y(Qe.$$.fragment,e),el=o(e),V=g(e,"DIV",{class:!0});var kn=$(V);y(Ve.$$.fragment,kn),Vl=o(kn),hn=g(kn,"P",{"data-svelte-h":!0}),U(hn)!=="svelte-17opoc3"&&(hn.textContent=ut),Nl=o(kn),y(de.$$.fragment,kn),kn.forEach(s),nl=o(e),y(Ne.$$.fragment,e),ll=o(e),N=g(e,"DIV",{class:!0});var bn=$(N);y(Xe.$$.fragment,bn),Xl=o(bn),wn=g(bn,"P",{"data-svelte-h":!0}),U(wn)!=="svelte-10rrvzk"&&(wn.textContent=ft),Fl=o(bn),gn=g(bn,"P",{"data-svelte-h":!0}),U(gn)!=="svelte-1m7rt2a"&&(gn.innerHTML=ht),bn.forEach(s),tl=o(e),y(Fe.$$.fragment,e),sl=o(e),X=g(e,"DIV",{class:!0});var $n=$(X);y(Le.$$.fragment,$n),Ll=o($n),Tn=g($n,"P",{"data-svelte-h":!0}),U(Tn)!=="svelte-10njn0v"&&(Tn.textContent=wt),zl=o($n),Un=g($n,"P",{"data-svelte-h":!0}),U(Un)!=="svelte-1u9ojx1"&&(Un.innerHTML=gt),$n.forEach(s),rl=o(e),y(ze.$$.fragment,e),al=o(e),jn=g(e,"P",{}),$(jn).forEach(s),this.h()},h(){j(t,"name","hf:doc:metadata"),j(t,"content",At),j(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(pe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(X,"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,l){i(document.head,t),p(e,J,l),p(e,m,l),p(e,r,l),M(c,e,l),p(e,n,l),M(T,e,l),p(e,_n,l),M(ye,e,l),p(e,In,l),M(Me,e,l),p(e,Cn,l),p(e,v,l),M(ue,v,null),i(v,pl),i(v,He),i(v,il),i(v,De),i(v,cl),M(ne,v,null),p(e,vn,l),M(fe,e,l),p(e,xn,l),p(e,_,l),M(he,_,null),i(_,ml),i(_,qe),i(_,dl),i(_,Pe),i(_,yl),i(_,Ke),i(_,Ml),M(le,_,null),p(e,Bn,l),M(we,e,l),p(e,Zn,l),p(e,x,l),M(ge,x,null),i(x,ul),i(x,Oe),i(x,fl),i(x,en),i(x,hl),M(te,x,null),p(e,Rn,l),M(Te,e,l),p(e,En,l),M(Ue,e,l),p(e,Gn,l),p(e,B,l),M(Je,B,null),i(B,wl),i(B,nn),i(B,gl),i(B,ln),i(B,Tl),M(se,B,null),p(e,Sn,l),M(ke,e,l),p(e,Wn,l),p(e,Z,l),M(be,Z,null),i(Z,Ul),i(Z,tn),i(Z,Jl),i(Z,sn),i(Z,kl),M(re,Z,null),p(e,An,l),M($e,e,l),p(e,Qn,l),M(je,e,l),p(e,Vn,l),p(e,R,l),M(_e,R,null),i(R,bl),i(R,rn),i(R,$l),i(R,an),i(R,jl),M(ae,R,null),p(e,Nn,l),M(Ie,e,l),p(e,Xn,l),M(Ce,e,l),p(e,Fn,l),p(e,I,l),M(ve,I,null),i(I,_l),i(I,on),i(I,Il),i(I,pn),i(I,Cl),M(oe,I,null),i(I,vl),i(I,pe),M(xe,pe,null),i(pe,xl),i(pe,cn),p(e,Ln,l),M(Be,e,l),p(e,zn,l),p(e,E,l),M(Ze,E,null),i(E,Bl),i(E,mn),i(E,Zl),i(E,dn),i(E,Rl),i(E,yn),p(e,Yn,l),M(Re,e,l),p(e,Hn,l),p(e,W,l),M(Ee,W,null),i(W,El),i(W,Mn),i(W,Gl),M(ie,W,null),p(e,Dn,l),M(Ge,e,l),p(e,qn,l),p(e,A,l),M(Se,A,null),i(A,Sl),i(A,un),i(A,Wl),M(ce,A,null),p(e,Pn,l),M(We,e,l),p(e,Kn,l),p(e,Q,l),M(Ae,Q,null),i(Q,Al),i(Q,fn),i(Q,Ql),M(me,Q,null),p(e,On,l),M(Qe,e,l),p(e,el,l),p(e,V,l),M(Ve,V,null),i(V,Vl),i(V,hn),i(V,Nl),M(de,V,null),p(e,nl,l),M(Ne,e,l),p(e,ll,l),p(e,N,l),M(Xe,N,null),i(N,Xl),i(N,wn),i(N,Fl),i(N,gn),p(e,tl,l),M(Fe,e,l),p(e,sl,l),p(e,X,l),M(Le,X,null),i(X,Ll),i(X,Tn),i(X,zl),i(X,Un),p(e,rl,l),M(ze,e,l),p(e,al,l),p(e,jn,l),ol=!0},p(e,[l]){const F={};l&2&&(F.$$scope={dirty:l,ctx:e}),ne.$set(F);const G={};l&2&&(G.$$scope={dirty:l,ctx:e}),le.$set(G);const L={};l&2&&(L.$$scope={dirty:l,ctx:e}),te.$set(L);const z={};l&2&&(z.$$scope={dirty:l,ctx:e}),se.$set(z);const Y={};l&2&&(Y.$$scope={dirty:l,ctx:e}),re.$set(Y);const H={};l&2&&(H.$$scope={dirty:l,ctx:e}),ae.$set(H);const S={};l&2&&(S.$$scope={dirty:l,ctx:e}),oe.$set(S);const Ye={};l&2&&(Ye.$$scope={dirty:l,ctx:e}),ie.$set(Ye);const D={};l&2&&(D.$$scope={dirty:l,ctx:e}),ce.$set(D);const O={};l&2&&(O.$$scope={dirty:l,ctx:e}),me.$set(O);const ee={};l&2&&(ee.$$scope={dirty:l,ctx:e}),de.$set(ee)},i(e){ol||(u(c.$$.fragment,e),u(T.$$.fragment,e),u(ye.$$.fragment,e),u(Me.$$.fragment,e),u(ue.$$.fragment,e),u(ne.$$.fragment,e),u(fe.$$.fragment,e),u(he.$$.fragment,e),u(le.$$.fragment,e),u(we.$$.fragment,e),u(ge.$$.fragment,e),u(te.$$.fragment,e),u(Te.$$.fragment,e),u(Ue.$$.fragment,e),u(Je.$$.fragment,e),u(se.$$.fragment,e),u(ke.$$.fragment,e),u(be.$$.fragment,e),u(re.$$.fragment,e),u($e.$$.fragment,e),u(je.$$.fragment,e),u(_e.$$.fragment,e),u(ae.$$.fragment,e),u(Ie.$$.fragment,e),u(Ce.$$.fragment,e),u(ve.$$.fragment,e),u(oe.$$.fragment,e),u(xe.$$.fragment,e),u(Be.$$.fragment,e),u(Ze.$$.fragment,e),u(Re.$$.fragment,e),u(Ee.$$.fragment,e),u(ie.$$.fragment,e),u(Ge.$$.fragment,e),u(Se.$$.fragment,e),u(ce.$$.fragment,e),u(We.$$.fragment,e),u(Ae.$$.fragment,e),u(me.$$.fragment,e),u(Qe.$$.fragment,e),u(Ve.$$.fragment,e),u(de.$$.fragment,e),u(Ne.$$.fragment,e),u(Xe.$$.fragment,e),u(Fe.$$.fragment,e),u(Le.$$.fragment,e),u(ze.$$.fragment,e),ol=!0)},o(e){f(c.$$.fragment,e),f(T.$$.fragment,e),f(ye.$$.fragment,e),f(Me.$$.fragment,e),f(ue.$$.fragment,e),f(ne.$$.fragment,e),f(fe.$$.fragment,e),f(he.$$.fragment,e),f(le.$$.fragment,e),f(we.$$.fragment,e),f(ge.$$.fragment,e),f(te.$$.fragment,e),f(Te.$$.fragment,e),f(Ue.$$.fragment,e),f(Je.$$.fragment,e),f(se.$$.fragment,e),f(ke.$$.fragment,e),f(be.$$.fragment,e),f(re.$$.fragment,e),f($e.$$.fragment,e),f(je.$$.fragment,e),f(_e.$$.fragment,e),f(ae.$$.fragment,e),f(Ie.$$.fragment,e),f(Ce.$$.fragment,e),f(ve.$$.fragment,e),f(oe.$$.fragment,e),f(xe.$$.fragment,e),f(Be.$$.fragment,e),f(Ze.$$.fragment,e),f(Re.$$.fragment,e),f(Ee.$$.fragment,e),f(ie.$$.fragment,e),f(Ge.$$.fragment,e),f(Se.$$.fragment,e),f(ce.$$.fragment,e),f(We.$$.fragment,e),f(Ae.$$.fragment,e),f(me.$$.fragment,e),f(Qe.$$.fragment,e),f(Ve.$$.fragment,e),f(de.$$.fragment,e),f(Ne.$$.fragment,e),f(Xe.$$.fragment,e),f(Fe.$$.fragment,e),f(Le.$$.fragment,e),f(ze.$$.fragment,e),ol=!1},d(e){e&&(s(J),s(m),s(r),s(n),s(_n),s(In),s(Cn),s(v),s(vn),s(xn),s(_),s(Bn),s(Zn),s(x),s(Rn),s(En),s(Gn),s(B),s(Sn),s(Wn),s(Z),s(An),s(Qn),s(Vn),s(R),s(Nn),s(Xn),s(Fn),s(I),s(Ln),s(zn),s(E),s(Yn),s(Hn),s(W),s(Dn),s(qn),s(A),s(Pn),s(Kn),s(Q),s(On),s(el),s(V),s(nl),s(ll),s(N),s(tl),s(sl),s(X),s(rl),s(al),s(jn)),s(t),h(c,e),h(T,e),h(ye,e),h(Me,e),h(ue),h(ne),h(fe,e),h(he),h(le),h(we,e),h(ge),h(te),h(Te,e),h(Ue,e),h(Je),h(se),h(ke,e),h(be),h(re),h($e,e),h(je,e),h(_e),h(ae),h(Ie,e),h(Ce,e),h(ve),h(oe),h(xe),h(Be,e),h(Ze),h(Re,e),h(Ee),h(ie),h(Ge,e),h(Se),h(ce),h(We,e),h(Ae),h(me),h(Qe,e),h(Ve),h(de),h(Ne,e),h(Xe),h(Fe,e),h(Le),h(ze,e)}}}const At='{"title":"Layers API Reference","local":"layers-api-reference","sections":[{"title":"Making layers kernel-aware","local":"making-layers-kernel-aware","sections":[{"title":"use_kernel_forward_from_hub","local":"kernels.use_kernel_forward_from_hub","sections":[],"depth":3},{"title":"use_kernel_func_from_hub","local":"kernels.use_kernel_func_from_hub","sections":[],"depth":3},{"title":"replace_kernel_forward_from_hub","local":"kernels.replace_kernel_forward_from_hub","sections":[],"depth":3}],"depth":2},{"title":"Registering kernel mappings","local":"registering-kernel-mappings","sections":[{"title":"use_kernel_mapping","local":"kernels.use_kernel_mapping","sections":[],"depth":3},{"title":"register_kernel_mapping","local":"kernels.register_kernel_mapping","sections":[],"depth":3}],"depth":2},{"title":"Kernelizing a model","local":"kernelizing-a-model","sections":[{"title":"kernelize","local":"kernels.kernelize","sections":[],"depth":3}],"depth":2},{"title":"Classes","local":"classes","sections":[{"title":"Device","local":"kernels.Device","sections":[],"depth":3},{"title":"Mode","local":"kernels.Mode","sections":[],"depth":3},{"title":"FuncRepository","local":"kernels.FuncRepository","sections":[],"depth":3},{"title":"LayerRepository","local":"kernels.LayerRepository","sections":[],"depth":3},{"title":"LocalFuncRepository","local":"kernels.LocalFuncRepository","sections":[],"depth":3},{"title":"LocalLayerRepository","local":"kernels.LocalLayerRepository","sections":[],"depth":3},{"title":"LockedFuncRepository","local":"kernels.LockedFuncRepository","sections":[],"depth":3},{"title":"LockedLayerRepository","local":"kernels.LockedLayerRepository","sections":[],"depth":3}],"depth":2}],"depth":1}';function Qt(k){return Ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Yt extends Jt{constructor(t){super(),kt(this,t,Qt,Wt,Tt,{})}}export{Yt as component};
