import{s as kt,o as Zt,n as Wt}from"../chunks/scheduler.25b97de1.js";import{S as Ft,i as Et,g as a,s,r as p,A as It,h as i,f as l,c as r,j as Bt,u as m,x as o,k as vt,y as xt,a as n,v as c,d as M,t as d,w as f}from"../chunks/index.d9030fc9.js";import{T as Ht}from"../chunks/Tip.baa67368.js";import{C as ce}from"../chunks/CodeBlock.b38ef023.js";import{H as u,E as zt}from"../chunks/index.676ef4be.js";function At(de){let T,y=`这是开始使用 TorchScript 进行实验的起点，我们仍在探索其在变量输入大小模型中的能力。
这是我们关注的焦点，我们将在即将发布的版本中深入分析，提供更多的代码示例、更灵活的实现以及比较
Python 代码与编译 TorchScript 的性能基准。`;return{c(){T=a("p"),T.textContent=y},l(h){T=i(h,"P",{"data-svelte-h":!0}),o(T)!=="svelte-1gfz947"&&(T.textContent=y)},m(h,me){n(h,T,me)},p:Wt,d(h){h&&l(T)}}}function Gt(de){let T,y,h,me,C,fe,U,Te,V,at='根据 <a href="https://pytorch.org/docs/stable/jit.html" rel="nofollow">TorchScript 文档</a>：',he,b,it="<p>TorchScript 是从 PyTorch 代码创建可序列化和可优化的模型的一种方式。</p>",ue,$,ot=`有两个 PyTorch 模块：<a href="https://pytorch.org/docs/stable/jit.html" rel="nofollow">JIT 和 TRACE</a>。
这两个模块允许开发人员将其模型导出到其他程序中重用，比如面向效率的 C++ 程序。`,Ue,J,pt=`我们提供了一个接口，允许您将 🤗 Transformers 模型导出为 TorchScript，
以便在与基于 PyTorch 的 Python 程序不同的环境中重用。
本文解释如何使用 TorchScript 导出并使用我们的模型。`,ye,w,mt="导出模型需要两个步骤：",Ce,j,ct="<li>使用 <code>torchscript</code> 参数实例化模型</li> <li>使用虚拟输入进行前向传递</li>",Ve,Q,Mt="这些必要条件意味着开发人员应该注意以下详细信息。",be,R,$e,S,dt=`<code>torchscript</code> 参数是必需的，因为大多数 🤗 Transformers 语言模型的 <code>Embedding</code> 层和
<code>Decoding</code> 层之间有绑定权重。TorchScript 不允许导出具有绑定权重的模型，因此必须事先解绑和克隆权重。`,Je,g,ft=`使用 <code>torchscript</code> 参数实例化的模型将其 <code>Embedding</code> 层和 <code>Decoding</code> 层分开，
这意味着它们不应该在后续进行训练。训练将导致这两层不同步，产生意外结果。`,we,N,Tt=`对于没有语言模型头部的模型，情况不同，因为这些模型没有绑定权重。
这些模型可以安全地导出而无需 <code>torchscript</code> 参数。`,je,_,Qe,B,ht=`虚拟输入用于模型的前向传递。当输入的值传播到各层时，PyTorch 会跟踪在每个张量上执行的不同操作。
然后使用记录的操作来创建模型的 <em>trace</em> 。`,Re,v,ut=`跟踪是相对于输入的维度创建的。因此，它受到虚拟输入的维度限制，对于任何其他序列长度或批量大小都不起作用。
当尝试使用不同大小时，会引发以下错误：`,Se,k,ge,Z,Ut=`我们建议使用至少与推断期间将馈送到模型的最大输入一样大的虚拟输入大小进行跟踪。
填充可以帮助填补缺失的值。然而，由于模型是使用更大的输入大小进行跟踪的，矩阵的维度也会很大，导致更多的计算。`,Ne,W,yt="在每个输入上执行的操作总数要仔细考虑，并在导出不同序列长度模型时密切关注性能。",_e,F,Be,E,Ct="本节演示了如何保存和加载模型以及如何使用 trace 进行推断。",ve,I,ke,x,Vt=`要使用 TorchScript 导出 <code>BertModel</code>，请从 <code>BertConfig</code> 类实例化 <code>BertModel</code>，
然后将其保存到名为 <code>traced_bert.pt</code> 的磁盘文件中：`,Ze,H,We,z,Fe,A,bt="现在，您可以从磁盘加载先前保存的 <code>BertModel</code>、<code>traced_bert.pt</code>，并在先前初始化的 <code>dummy_input</code> 上使用：",Ee,G,Ie,O,xe,X,$t="通过使用其 <code>__call__</code> dunder 方法使用 trace 模型进行推断：",He,L,ze,D,Ae,P,Jt=`AWS 引入了用于云端低成本、高性能机器学习推理的
<a href="https://aws.amazon.com/ec2/instance-types/inf1/" rel="nofollow">Amazon EC2 Inf1</a> 实例系列。
Inf1 实例由 AWS Inferentia 芯片提供支持，这是一款专为深度学习推理工作负载而构建的定制硬件加速器。
<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/#" rel="nofollow">AWS Neuron</a> 是
Inferentia 的 SDK，支持对 transformers 模型进行跟踪和优化，以便在 Inf1 上部署。Neuron SDK 提供：`,Ge,Y,wt=`<li>简单易用的 API，只需更改一行代码即可为云端推理跟踪和优化 TorchScript 模型。</li> <li>针对<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/benchmark/" rel="nofollow">改进的性能成本</a>的即插即用性能优化。</li> <li>支持使用 <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/bert_tutorial/tutorial_pretrained_bert.html" rel="nofollow">PyTorch</a>
或 <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/tensorflow/huggingface_bert/huggingface_bert.html" rel="nofollow">TensorFlow</a>
构建的 Hugging Face transformers 模型。</li>`,Oe,K,Xe,q,jt=`基于 <a href="https://huggingface.co/docs/transformers/main/model_doc/bert" rel="nofollow">BERT（来自 Transformers 的双向编码器表示）</a>架构的
transformers 模型，或其变体，如 <a href="https://huggingface.co/docs/transformers/main/model_doc/distilbert" rel="nofollow">distilBERT</a>
和 <a href="https://huggingface.co/docs/transformers/main/model_doc/roberta" rel="nofollow">roBERTa</a> 在 Inf1 上运行最佳，
可用于生成抽取式问答、序列分类和标记分类等任务。然而，文本生成任务仍可以适应在 Inf1 上运行，
如这篇 <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/transformers-marianmt.html" rel="nofollow">AWS Neuron MarianMT 教程</a>所述。
有关可以直接在 Inferentia 上转换的模型的更多信息，请参阅 Neuron 文档的<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/models/models-inferentia.html#models-inferentia" rel="nofollow">模型架构适配</a>章节。`,Le,ee,De,te,Qt=`使用 AWS Neuron 将模型转换为模型需要一个
<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/neuron-frameworks/pytorch-neuron/index.html#installation-guide" rel="nofollow">Neuron SDK 环境</a>，
它已经预先配置在 <a href="https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-inferentia-launching.html" rel="nofollow">AWS 深度学习 AMI</a>上。`,Pe,le,Ye,ne,Rt=`使用与 <a href="torchscript#using-torchscript-in-python">Python 中使用 TorchScript</a> 相同的代码来跟踪
<code>BertModel</code> 以将模型转换为 AWS NEURON。导入 <code>torch.neuron</code> 框架扩展以通过 Python API 访问 Neuron SDK 的组件：`,Ke,se,qe,re,St="您只需要修改下面这一行：",et,ae,tt,ie,gt="这样就能使 Neuron SDK 跟踪模型并对其进行优化，以在 Inf1 实例上运行。",lt,oe,Nt=`要了解有关 AWS Neuron SDK 功能、工具、示例教程和最新更新的更多信息，
请参阅 <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html" rel="nofollow">AWS NeuronSDK 文档</a>。`,nt,pe,st,Me,rt;return C=new u({props:{title:"导出为 TorchScript",local:"导出为-torchscript",headingTag:"h1"}}),U=new Ht({props:{$$slots:{default:[At]},$$scope:{ctx:de}}}),R=new u({props:{title:"TorchScript 参数和绑定权重",local:"torchscript-参数和绑定权重",headingTag:"h2"}}),_=new u({props:{title:"虚拟输入和标准长度",local:"虚拟输入和标准长度",headingTag:"h2"}}),k=new ce({props:{code:"JTYwVGhlJTIwZXhwYW5kZWQlMjBzaXplJTIwb2YlMjB0aGUlMjB0ZW5zb3IlMjAoMyklMjBtdXN0JTIwbWF0Y2glMjB0aGUlMjBleGlzdGluZyUyMHNpemUlMjAoNyklMjBhdCUyMG5vbi1zaW5nbGV0b24lMjBkaW1lbnNpb24lMjAyJTYw",highlighted:"`The expanded size of the tensor (3) must match the existing size (7) at non-singleton dimension 2`",wrap:!1}}),F=new u({props:{title:"在 Python 中使用 TorchScript",local:"在-python-中使用-torchscript",headingTag:"h2"}}),I=new u({props:{title:"保存模型",local:"保存模型",headingTag:"h3"}}),H=new ce({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJ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NiVBOCVBMSVFNSU5RSU4QiUwQW1vZGVsJTIwJTNEJTIwQmVydE1vZGVsKGNvbmZpZyklMEElMEElMjMlMjAlRTYlQTglQTElRTUlOUUlOEIlRTklOUMlODAlRTglQTYlODElRTUlQTQlODQlRTQlQkElOEUlRTglQUYlODQlRTQlQkMlQjAlRTYlQTglQTElRTUlQkMlOEYlMEFtb2RlbC5ldmFsKCklMEElMEElMjMlMjAlRTUlQTYlODIlRTYlOUUlOUMlRTYlODIlQTglRTQlQkQlQkYlRTclOTQlQTglMjAqZnJvbV9wcmV0cmFpbmVkKiUyMCVFNSVBRSU5RSVFNCVCRSU4QiVFNSU4QyU5NiVFNiVBOCVBMSVFNSU5RSU4QiVFRiVCQyU4QyVFOCVCRiU5OCVFNSU4RiVBRiVFNCVCQiVBNSVFOCVCRCVCQiVFNiU5RCVCRSVFOCVBRSVCRSVFNyVCRCVBRSUyMFRvcmNoU2NyaXB0JTIwJUU1JThGJTgyJUU2JTk1JUIwJTBBbW9kZWwlMjAlM0QlMjBCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjB0b3JjaHNjcmlwdCUzRFRydWUpJTBBJTBBJTIzJTIwJUU1JTg4JTlCJUU1JUJCJUJBJTIwdHJhY2UlMEF0cmFjZWRfbW9kZWwlMjAlM0QlMjB0b3JjaC5qaXQudHJhY2UobW9kZWwlMkMlMjAlNUJ0b2tlbnNfdGVuc29yJTJDJTIwc2VnbWVudHNfdGVuc29ycyU1RCklMEF0b3JjaC5qaXQuc2F2ZSh0cmFjZWRfbW9kZWwlMkMlMjAlMjJ0cmFjZWRfYmVydC5wdCUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel, BertTokenizer, BertConfig
<span class="hljs-keyword">import</span> torch

enc = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>)

<span class="hljs-comment"># 对输入文本分词</span>
text = <span class="hljs-string">&quot;[CLS] Who was Jim Henson ? [SEP] Jim Henson was a puppeteer [SEP]&quot;</span>
tokenized_text = enc.tokenize(text)

<span class="hljs-comment"># 屏蔽一个输入 token</span>
masked_index = <span class="hljs-number">8</span>
tokenized_text[masked_index] = <span class="hljs-string">&quot;[MASK]&quot;</span>
indexed_tokens = enc.convert_tokens_to_ids(tokenized_text)
segments_ids = [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]

<span class="hljs-comment"># 创建虚拟输入</span>
tokens_tensor = torch.tensor([indexed_tokens])
segments_tensors = torch.tensor([segments_ids])
dummy_input = [tokens_tensor, segments_tensors]

<span class="hljs-comment"># 使用 torchscript 参数初始化模型</span>
<span class="hljs-comment"># 即使此模型没有 LM Head，也将参数设置为 True。</span>
config = BertConfig(
    vocab_size_or_config_json_file=<span class="hljs-number">32000</span>,
    hidden_size=<span class="hljs-number">768</span>,
    num_hidden_layers=<span class="hljs-number">12</span>,
    num_attention_heads=<span class="hljs-number">12</span>,
    intermediate_size=<span class="hljs-number">3072</span>,
    torchscript=<span class="hljs-literal">True</span>,
)

<span class="hljs-comment"># 实例化模型</span>
model = BertModel(config)

<span class="hljs-comment"># 模型需要处于评估模式</span>
model.<span class="hljs-built_in">eval</span>()

<span class="hljs-comment"># 如果您使用 *from_pretrained* 实例化模型，还可以轻松设置 TorchScript 参数</span>
model = BertModel.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>, torchscript=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># 创建 trace</span>
traced_model = torch.jit.trace(model, [tokens_tensor, segments_tensors])
torch.jit.save(traced_model, <span class="hljs-string">&quot;traced_bert.pt&quot;</span>)`,wrap:!1}}),z=new u({props:{title:"加载模型",local:"加载模型",headingTag:"h3"}}),G=new ce({props:{code:"bG9hZGVkX21vZGVsJTIwJTNEJTIwdG9yY2guaml0LmxvYWQoJTIydHJhY2VkX2JlcnQucHQlMjIpJTBBbG9hZGVkX21vZGVsLmV2YWwoKSUwQSUwQWFsbF9lbmNvZGVyX2xheWVycyUyQyUyMHBvb2xlZF9vdXRwdXQlMjAlM0QlMjBsb2FkZWRfbW9kZWwoKmR1bW15X2lucHV0KQ==",highlighted:`loaded_model = torch.jit.load(<span class="hljs-string">&quot;traced_bert.pt&quot;</span>)
loaded_model.<span class="hljs-built_in">eval</span>()

all_encoder_layers, pooled_output = loaded_model(*dummy_input)`,wrap:!1}}),O=new u({props:{title:"使用 trace 模型进行推断",local:"使用-trace-模型进行推断",headingTag:"h3"}}),L=new ce({props:{code:"dHJhY2VkX21vZGVsKHRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzKQ==",highlighted:"traced_model(tokens_tensor, segments_tensors)",wrap:!1}}),D=new u({props:{title:"使用 Neuron SDK 将 Hugging Face TorchScript 模型部署到 AWS",local:"使用-neuron-sdk-将-hugging-face-torchscript-模型部署到-aws",headingTag:"h2"}}),K=new u({props:{title:"影响",local:"影响",headingTag:"h3"}}),ee=new u({props:{title:"依赖关系",local:"依赖关系",headingTag:"h3"}}),le=new u({props:{title:"将模型转换为 AWS Neuron",local:"将模型转换为-aws-neuron",headingTag:"h3"}}),se=new ce({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5uZXVyb24=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel, BertTokenizer, BertConfig
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.neuron`,wrap:!1}}),ae=new ce({props:{code:"LSUyMHRvcmNoLmppdC50cmFjZShtb2RlbCUyQyUyMCU1QnRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzJTVEKSUwQSUyQiUyMHRvcmNoLm5ldXJvbi50cmFjZShtb2RlbCUyQyUyMCU1QnRva2VuX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQp",highlighted:`<span class="hljs-deletion">- torch.jit.trace(model, [tokens_tensor, segments_tensors])</span>
<span class="hljs-addition">+ torch.neuron.trace(model, [token_tensor, segments_tensors])</span>`,wrap:!1}}),pe=new zt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/torchscript.md"}}),{c(){T=a("meta"),y=s(),h=a("p"),me=s(),p(C.$$.fragment),fe=s(),p(U.$$.fragment),Te=s(),V=a("p"),V.innerHTML=at,he=s(),b=a("blockquote"),b.innerHTML=it,ue=s(),$=a("p"),$.innerHTML=ot,Ue=s(),J=a("p"),J.textContent=pt,ye=s(),w=a("p"),w.textContent=mt,Ce=s(),j=a("ul"),j.innerHTML=ct,Ve=s(),Q=a("p"),Q.textContent=Mt,be=s(),p(R.$$.fragment),$e=s(),S=a("p"),S.innerHTML=dt,Je=s(),g=a("p"),g.innerHTML=ft,we=s(),N=a("p"),N.innerHTML=Tt,je=s(),p(_.$$.fragment),Qe=s(),B=a("p"),B.innerHTML=ht,Re=s(),v=a("p"),v.textContent=ut,Se=s(),p(k.$$.fragment),ge=s(),Z=a("p"),Z.textContent=Ut,Ne=s(),W=a("p"),W.textContent=yt,_e=s(),p(F.$$.fragment),Be=s(),E=a("p"),E.textContent=Ct,ve=s(),p(I.$$.fragment),ke=s(),x=a("p"),x.innerHTML=Vt,Ze=s(),p(H.$$.fragment),We=s(),p(z.$$.fragment),Fe=s(),A=a("p"),A.innerHTML=bt,Ee=s(),p(G.$$.fragment),Ie=s(),p(O.$$.fragment),xe=s(),X=a("p"),X.innerHTML=$t,He=s(),p(L.$$.fragment),ze=s(),p(D.$$.fragment),Ae=s(),P=a("p"),P.innerHTML=Jt,Ge=s(),Y=a("ol"),Y.innerHTML=wt,Oe=s(),p(K.$$.fragment),Xe=s(),q=a("p"),q.innerHTML=jt,Le=s(),p(ee.$$.fragment),De=s(),te=a("p"),te.innerHTML=Qt,Pe=s(),p(le.$$.fragment),Ye=s(),ne=a("p"),ne.innerHTML=Rt,Ke=s(),p(se.$$.fragment),qe=s(),re=a("p"),re.textContent=St,et=s(),p(ae.$$.fragment),tt=s(),ie=a("p"),ie.textContent=gt,lt=s(),oe=a("p"),oe.innerHTML=Nt,nt=s(),p(pe.$$.fragment),st=s(),Me=a("p"),this.h()},l(e){const t=It("svelte-u9bgzb",document.head);T=i(t,"META",{name:!0,content:!0}),t.forEach(l),y=r(e),h=i(e,"P",{}),Bt(h).forEach(l),me=r(e),m(C.$$.fragment,e),fe=r(e),m(U.$$.fragment,e),Te=r(e),V=i(e,"P",{"data-svelte-h":!0}),o(V)!=="svelte-s0qya2"&&(V.innerHTML=at),he=r(e),b=i(e,"BLOCKQUOTE",{"data-svelte-h":!0}),o(b)!=="svelte-rlo4iu"&&(b.innerHTML=it),ue=r(e),$=i(e,"P",{"data-svelte-h":!0}),o($)!=="svelte-n5bnu6"&&($.innerHTML=ot),Ue=r(e),J=i(e,"P",{"data-svelte-h":!0}),o(J)!=="svelte-13dtdru"&&(J.textContent=pt),ye=r(e),w=i(e,"P",{"data-svelte-h":!0}),o(w)!=="svelte-12yrypg"&&(w.textContent=mt),Ce=r(e),j=i(e,"UL",{"data-svelte-h":!0}),o(j)!=="svelte-1fh86cr"&&(j.innerHTML=ct),Ve=r(e),Q=i(e,"P",{"data-svelte-h":!0}),o(Q)!=="svelte-1fwt0g0"&&(Q.textContent=Mt),be=r(e),m(R.$$.fragment,e),$e=r(e),S=i(e,"P",{"data-svelte-h":!0}),o(S)!=="svelte-1xhai90"&&(S.innerHTML=dt),Je=r(e),g=i(e,"P",{"data-svelte-h":!0}),o(g)!=="svelte-1rblw4n"&&(g.innerHTML=ft),we=r(e),N=i(e,"P",{"data-svelte-h":!0}),o(N)!=="svelte-1rojuw1"&&(N.innerHTML=Tt),je=r(e),m(_.$$.fragment,e),Qe=r(e),B=i(e,"P",{"data-svelte-h":!0}),o(B)!=="svelte-3rxu07"&&(B.innerHTML=ht),Re=r(e),v=i(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-1ha254l"&&(v.textContent=ut),Se=r(e),m(k.$$.fragment,e),ge=r(e),Z=i(e,"P",{"data-svelte-h":!0}),o(Z)!=="svelte-19fynrt"&&(Z.textContent=Ut),Ne=r(e),W=i(e,"P",{"data-svelte-h":!0}),o(W)!=="svelte-1surt3l"&&(W.textContent=yt),_e=r(e),m(F.$$.fragment,e),Be=r(e),E=i(e,"P",{"data-svelte-h":!0}),o(E)!=="svelte-1d41jn5"&&(E.textContent=Ct),ve=r(e),m(I.$$.fragment,e),ke=r(e),x=i(e,"P",{"data-svelte-h":!0}),o(x)!=="svelte-1l6vll5"&&(x.innerHTML=Vt),Ze=r(e),m(H.$$.fragment,e),We=r(e),m(z.$$.fragment,e),Fe=r(e),A=i(e,"P",{"data-svelte-h":!0}),o(A)!=="svelte-8mcedk"&&(A.innerHTML=bt),Ee=r(e),m(G.$$.fragment,e),Ie=r(e),m(O.$$.fragment,e),xe=r(e),X=i(e,"P",{"data-svelte-h":!0}),o(X)!=="svelte-15zasob"&&(X.innerHTML=$t),He=r(e),m(L.$$.fragment,e),ze=r(e),m(D.$$.fragment,e),Ae=r(e),P=i(e,"P",{"data-svelte-h":!0}),o(P)!=="svelte-qtxveh"&&(P.innerHTML=Jt),Ge=r(e),Y=i(e,"OL",{"data-svelte-h":!0}),o(Y)!=="svelte-pj5pw8"&&(Y.innerHTML=wt),Oe=r(e),m(K.$$.fragment,e),Xe=r(e),q=i(e,"P",{"data-svelte-h":!0}),o(q)!=="svelte-8m4g1s"&&(q.innerHTML=jt),Le=r(e),m(ee.$$.fragment,e),De=r(e),te=i(e,"P",{"data-svelte-h":!0}),o(te)!=="svelte-y456f4"&&(te.innerHTML=Qt),Pe=r(e),m(le.$$.fragment,e),Ye=r(e),ne=i(e,"P",{"data-svelte-h":!0}),o(ne)!=="svelte-1u7opmj"&&(ne.innerHTML=Rt),Ke=r(e),m(se.$$.fragment,e),qe=r(e),re=i(e,"P",{"data-svelte-h":!0}),o(re)!=="svelte-1t1ndji"&&(re.textContent=St),et=r(e),m(ae.$$.fragment,e),tt=r(e),ie=i(e,"P",{"data-svelte-h":!0}),o(ie)!=="svelte-1t6xzzv"&&(ie.textContent=gt),lt=r(e),oe=i(e,"P",{"data-svelte-h":!0}),o(oe)!=="svelte-1tzl0b4"&&(oe.innerHTML=Nt),nt=r(e),m(pe.$$.fragment,e),st=r(e),Me=i(e,"P",{}),Bt(Me).forEach(l),this.h()},h(){vt(T,"name","hf:doc:metadata"),vt(T,"content",Ot)},m(e,t){xt(document.head,T),n(e,y,t),n(e,h,t),n(e,me,t),c(C,e,t),n(e,fe,t),c(U,e,t),n(e,Te,t),n(e,V,t),n(e,he,t),n(e,b,t),n(e,ue,t),n(e,$,t),n(e,Ue,t),n(e,J,t),n(e,ye,t),n(e,w,t),n(e,Ce,t),n(e,j,t),n(e,Ve,t),n(e,Q,t),n(e,be,t),c(R,e,t),n(e,$e,t),n(e,S,t),n(e,Je,t),n(e,g,t),n(e,we,t),n(e,N,t),n(e,je,t),c(_,e,t),n(e,Qe,t),n(e,B,t),n(e,Re,t),n(e,v,t),n(e,Se,t),c(k,e,t),n(e,ge,t),n(e,Z,t),n(e,Ne,t),n(e,W,t),n(e,_e,t),c(F,e,t),n(e,Be,t),n(e,E,t),n(e,ve,t),c(I,e,t),n(e,ke,t),n(e,x,t),n(e,Ze,t),c(H,e,t),n(e,We,t),c(z,e,t),n(e,Fe,t),n(e,A,t),n(e,Ee,t),c(G,e,t),n(e,Ie,t),c(O,e,t),n(e,xe,t),n(e,X,t),n(e,He,t),c(L,e,t),n(e,ze,t),c(D,e,t),n(e,Ae,t),n(e,P,t),n(e,Ge,t),n(e,Y,t),n(e,Oe,t),c(K,e,t),n(e,Xe,t),n(e,q,t),n(e,Le,t),c(ee,e,t),n(e,De,t),n(e,te,t),n(e,Pe,t),c(le,e,t),n(e,Ye,t),n(e,ne,t),n(e,Ke,t),c(se,e,t),n(e,qe,t),n(e,re,t),n(e,et,t),c(ae,e,t),n(e,tt,t),n(e,ie,t),n(e,lt,t),n(e,oe,t),n(e,nt,t),c(pe,e,t),n(e,st,t),n(e,Me,t),rt=!0},p(e,[t]){const _t={};t&2&&(_t.$$scope={dirty:t,ctx:e}),U.$set(_t)},i(e){rt||(M(C.$$.fragment,e),M(U.$$.fragment,e),M(R.$$.fragment,e),M(_.$$.fragment,e),M(k.$$.fragment,e),M(F.$$.fragment,e),M(I.$$.fragment,e),M(H.$$.fragment,e),M(z.$$.fragment,e),M(G.$$.fragment,e),M(O.$$.fragment,e),M(L.$$.fragment,e),M(D.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(le.$$.fragment,e),M(se.$$.fragment,e),M(ae.$$.fragment,e),M(pe.$$.fragment,e),rt=!0)},o(e){d(C.$$.fragment,e),d(U.$$.fragment,e),d(R.$$.fragment,e),d(_.$$.fragment,e),d(k.$$.fragment,e),d(F.$$.fragment,e),d(I.$$.fragment,e),d(H.$$.fragment,e),d(z.$$.fragment,e),d(G.$$.fragment,e),d(O.$$.fragment,e),d(L.$$.fragment,e),d(D.$$.fragment,e),d(K.$$.fragment,e),d(ee.$$.fragment,e),d(le.$$.fragment,e),d(se.$$.fragment,e),d(ae.$$.fragment,e),d(pe.$$.fragment,e),rt=!1},d(e){e&&(l(y),l(h),l(me),l(fe),l(Te),l(V),l(he),l(b),l(ue),l($),l(Ue),l(J),l(ye),l(w),l(Ce),l(j),l(Ve),l(Q),l(be),l($e),l(S),l(Je),l(g),l(we),l(N),l(je),l(Qe),l(B),l(Re),l(v),l(Se),l(ge),l(Z),l(Ne),l(W),l(_e),l(Be),l(E),l(ve),l(ke),l(x),l(Ze),l(We),l(Fe),l(A),l(Ee),l(Ie),l(xe),l(X),l(He),l(ze),l(Ae),l(P),l(Ge),l(Y),l(Oe),l(Xe),l(q),l(Le),l(De),l(te),l(Pe),l(Ye),l(ne),l(Ke),l(qe),l(re),l(et),l(tt),l(ie),l(lt),l(oe),l(nt),l(st),l(Me)),l(T),f(C,e),f(U,e),f(R,e),f(_,e),f(k,e),f(F,e),f(I,e),f(H,e),f(z,e),f(G,e),f(O,e),f(L,e),f(D,e),f(K,e),f(ee,e),f(le,e),f(se,e),f(ae,e),f(pe,e)}}}const Ot='{"title":"导出为 TorchScript","local":"导出为-torchscript","sections":[{"title":"TorchScript 参数和绑定权重","local":"torchscript-参数和绑定权重","sections":[],"depth":2},{"title":"虚拟输入和标准长度","local":"虚拟输入和标准长度","sections":[],"depth":2},{"title":"在 Python 中使用 TorchScript","local":"在-python-中使用-torchscript","sections":[{"title":"保存模型","local":"保存模型","sections":[],"depth":3},{"title":"加载模型","local":"加载模型","sections":[],"depth":3},{"title":"使用 trace 模型进行推断","local":"使用-trace-模型进行推断","sections":[],"depth":3}],"depth":2},{"title":"使用 Neuron SDK 将 Hugging Face TorchScript 模型部署到 AWS","local":"使用-neuron-sdk-将-hugging-face-torchscript-模型部署到-aws","sections":[{"title":"影响","local":"影响","sections":[],"depth":3},{"title":"依赖关系","local":"依赖关系","sections":[],"depth":3},{"title":"将模型转换为 AWS Neuron","local":"将模型转换为-aws-neuron","sections":[],"depth":3}],"depth":2}],"depth":1}';function Xt(de){return Zt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qt extends Ft{constructor(T){super(),Et(this,T,Xt,Gt,kt,{})}}export{qt as component};
