import{s as St,o as Wt,n as Gt}from"../chunks/scheduler.25b97de1.js";import{S as Vt,i as Rt,g as a,s,r as d,A as zt,h as i,f as n,c as o,j as kt,u as p,x as r,k as Ht,y as Qt,a as l,v as m,d as c,t as h,w as u}from"../chunks/index.d9030fc9.js";import{T as Nt}from"../chunks/Tip.baa67368.js";import{C as me}from"../chunks/CodeBlock.e6cd0d95.js";import{H as y,E as Et}from"../chunks/EditOnGithub.91d95064.js";function Xt(he){let f,T=`This is the very beginning of our experiments with TorchScript and we are still
exploring its capabilities with variable-input-size models. It is a focus of interest to
us and we will deepen our analysis in upcoming releases, with more code examples, a more
flexible implementation, and benchmarks comparing Python-based codes with compiled
TorchScript.`;return{c(){f=a("p"),f.textContent=T},l(M){f=i(M,"P",{"data-svelte-h":!0}),r(f)!=="svelte-3gxwq2"&&(f.textContent=T)},m(M,pe){l(M,f,pe)},p:Gt,d(M){M&&n(f)}}}function Lt(he){let f,T,M,pe,g,ue,w,fe,b,at='According to the <a href="https://pytorch.org/docs/stable/jit.html" rel="nofollow">TorchScript documentation</a>:',Me,J,it="<p>TorchScript is a way to create serializable and optimizable models from PyTorch code.</p>",ye,v,rt=`There are two PyTorch modules, <a href="https://pytorch.org/docs/stable/jit.html" rel="nofollow">JIT and
TRACE</a>, that allow developers to export their
models to be reused in other programs like efficiency-oriented C++ programs.`,we,$,dt=`We provide an interface that allows you to export 🤗 Transformers models to TorchScript
so they can be reused in a different environment than PyTorch-based Python programs.
Here, we explain how to export and use our models using TorchScript.`,Te,U,pt="Exporting a model requires two things:",ge,j,mt="<li>model instantiation with the <code>torchscript</code> flag</li> <li>a forward pass with dummy inputs</li>",be,Z,ct=`These necessities imply several things developers should be careful about as detailed
below.`,Je,C,ve,_,ht=`The <code>torchscript</code> flag is necessary because most of the 🤗 Transformers language models
have tied weights between their <code>Embedding</code> layer and their <code>Decoding</code> layer.
TorchScript does not allow you to export models that have tied weights, so it is
necessary to untie and clone the weights beforehand.`,$e,B,ut=`Models instantiated with the <code>torchscript</code> flag have their <code>Embedding</code> layer and
<code>Decoding</code> layer separated, which means that they should not be trained down the line.
Training would desynchronize the two layers, leading to unexpected results.`,Ue,x,ft=`This is not the case for models that do not have a language model head, as those do not
have tied weights. These models can be safely exported without the <code>torchscript</code> flag.`,je,I,Ze,k,Mt=`The dummy inputs are used for a models forward pass. While the inputs’ values are
propagated through the layers, PyTorch keeps track of the different operations executed
on each tensor. These recorded operations are then used to create the <em>trace</em> of the
model.`,Ce,H,yt=`The trace is created relative to the inputs’ dimensions. It is therefore constrained by
the dimensions of the dummy input, and will not work for any other sequence length or
batch size. When trying with a different size, the following error is raised:`,_e,S,Be,W,wt=`We recommended you trace the model with a dummy input size at least as large as the
largest input that will be fed to the model during inference. Padding can help fill the
missing values. However, since the model is traced with a larger input size, the
dimensions of the matrix will also be large, resulting in more calculations.`,xe,G,Tt=`Be careful of the total number of operations done on each input and follow the
performance closely when exporting varying sequence-length models.`,Ie,V,ke,R,gt=`This section demonstrates how to save and load models as well as how to use the trace
for inference.`,He,z,Se,Q,bt=`To export a <code>BertModel</code> with TorchScript, instantiate <code>BertModel</code> from the <code>BertConfig</code>
class and then save it to disk under the filename <code>traced_bert.pt</code>:`,We,N,Ge,E,Ve,X,Jt=`Now you can load the previously saved <code>BertModel</code>, <code>traced_bert.pt</code>, from disk and use
it on the previously initialised <code>dummy_input</code>:`,Re,L,ze,A,Qe,P,vt="Use the traced model for inference by using its <code>__call__</code> dunder method:",Ne,Y,Ee,F,Xe,D,$t=`AWS introduced the <a href="https://aws.amazon.com/ec2/instance-types/inf1/" rel="nofollow">Amazon EC2 Inf1</a>
instance family for low cost, high performance machine learning inference in the cloud.
The Inf1 instances are powered by the AWS Inferentia chip, a custom-built hardware
accelerator, specializing in deep learning inferencing workloads. <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/#" rel="nofollow">AWS
Neuron</a> is the SDK for
Inferentia that supports tracing and optimizing transformers models for deployment on
Inf1. The Neuron SDK provides:`,Le,q,Ut=`<li>Easy-to-use API with one line of code change to trace and optimize a TorchScript
model for inference in the cloud.</li> <li>Out of the box performance optimizations for <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/benchmark/%3E" rel="nofollow">improved
cost-performance</a>.</li> <li>Support for Hugging Face transformers models built with either
<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/bert_tutorial/tutorial_pretrained_bert.html" rel="nofollow">PyTorch</a>
or
<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/tensorflow/huggingface_bert/huggingface_bert.html" rel="nofollow">TensorFlow</a>.</li>`,Ae,K,Pe,O,jt=`Transformers models based on the <a href="https://huggingface.co/docs/transformers/main/model_doc/bert" rel="nofollow">BERT (Bidirectional Encoder Representations from
Transformers)</a>
architecture, or its variants such as
<a href="https://huggingface.co/docs/transformers/main/model_doc/distilbert" rel="nofollow">distilBERT</a> and
<a href="https://huggingface.co/docs/transformers/main/model_doc/roberta" rel="nofollow">roBERTa</a> run best on
Inf1 for non-generative tasks such as extractive question answering, sequence
classification, and token classification. However, text generation tasks can still be
adapted to run on Inf1 according to this <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/transformers-marianmt.html" rel="nofollow">AWS Neuron MarianMT
tutorial</a>.
More information about models that can be converted out of the box on Inferentia can be
found in the <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/models/models-inferentia.html#models-inferentia" rel="nofollow">Model Architecture
Fit</a>
section of the Neuron documentation.`,Ye,ee,Fe,te,Zt=`Using AWS Neuron to convert models requires a <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/neuron-frameworks/pytorch-neuron/index.html#installation-guide" rel="nofollow">Neuron SDK
environment</a>
which comes preconfigured on <a href="https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-inferentia-launching.html" rel="nofollow">AWS Deep Learning
AMI</a>.`,De,ne,qe,le,Ct=`Convert a model for AWS NEURON using the same code from <a href="torchscript#using-torchscript-in-python">Using TorchScript in
Python</a> to trace a <code>BertModel</code>. Import the
<code>torch.neuron</code> framework extension to access the components of the Neuron SDK through a
Python API:`,Ke,se,Oe,oe,_t="You only need to modify the following line:",et,ae,tt,ie,Bt="This enables the Neuron SDK to trace the model and optimize it for Inf1 instances.",nt,re,xt=`To learn more about AWS Neuron SDK features, tools, example tutorials and latest
updates, please see the <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html" rel="nofollow">AWS NeuronSDK
documentation</a>.`,lt,de,st,ce,ot;return g=new y({props:{title:"Export to TorchScript",local:"export-to-torchscript",headingTag:"h1"}}),w=new Nt({props:{$$slots:{default:[Xt]},$$scope:{ctx:he}}}),C=new y({props:{title:"TorchScript flag and tied weights",local:"torchscript-flag-and-tied-weights",headingTag:"h2"}}),I=new y({props:{title:"Dummy inputs and standard lengths",local:"dummy-inputs-and-standard-lengths",headingTag:"h2"}}),S=new me({props:{code:"JTYwVGhlJTIwZXhwYW5kZWQlMjBzaXplJTIwb2YlMjB0aGUlMjB0ZW5zb3IlMjAoMyklMjBtdXN0JTIwbWF0Y2glMjB0aGUlMjBleGlzdGluZyUyMHNpemUlMjAoNyklMjBhdCUyMG5vbi1zaW5nbGV0b24lMjBkaW1lbnNpb24lMjAyJTYw",highlighted:'`The expanded <span class="hljs-built_in">size</span> of the tensor (<span class="hljs-number">3</span>) must match the existing <span class="hljs-built_in">size</span> (<span class="hljs-number">7</span>) at non-singleton <span class="hljs-keyword">dimension</span> <span class="hljs-number">2</span>`',wrap:!1}}),V=new y({props:{title:"Using TorchScript in Python",local:"using-torchscript-in-python",headingTag:"h2"}}),z=new y({props:{title:"Saving a model",local:"saving-a-model",headingTag:"h3"}}),N=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElM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QlMjB0aGUlMjBUb3JjaFNjcmlwdCUyMGZsYWclMEFtb2RlbCUyMCUzRCUyMEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMHRvcmNoc2NyaXB0JTNEVHJ1ZSklMEElMEElMjMlMjBDcmVhdGluZyUyMHRoZSUyMHRyYWNlJTBBdHJhY2VkX21vZGVsJTIwJTNEJTIwdG9yY2guaml0LnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5zX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQpJTBBdG9yY2guaml0LnNhdmUodHJhY2VkX21vZGVsJTJDJTIwJTIydHJhY2VkX2JlcnQucHQlMjIp",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"># Tokenizing input text</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"># Masking one of the input tokens</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"># Creating a dummy input</span>
tokens_tensor = torch.tensor([indexed_tokens])
segments_tensors = torch.tensor([segments_ids])
dummy_input = [tokens_tensor, segments_tensors]

<span class="hljs-comment"># Initializing the model with the torchscript flag</span>
<span class="hljs-comment"># Flag set to True even though it is not necessary as this model does not have an LM Head.</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"># Instantiating the model</span>
model = BertModel(config)

<span class="hljs-comment"># The model needs to be in evaluation mode</span>
model.<span class="hljs-built_in">eval</span>()

<span class="hljs-comment"># If you are instantiating the model with *from_pretrained* you can also easily set the TorchScript flag</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"># Creating the 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}}),E=new y({props:{title:"Loading a model",local:"loading-a-model",headingTag:"h3"}}),L=new me({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}}),A=new y({props:{title:"Using a traced model for inference",local:"using-a-traced-model-for-inference",headingTag:"h3"}}),Y=new me({props:{code:"dHJhY2VkX21vZGVsKHRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzKQ==",highlighted:"traced_model(tokens_tensor, segments_tensors)",wrap:!1}}),F=new y({props:{title:"Deploy Hugging Face TorchScript models to AWS with the Neuron SDK",local:"deploy-hugging-face-torchscript-models-to-aws-with-the-neuron-sdk",headingTag:"h2"}}),K=new y({props:{title:"Implications",local:"implications",headingTag:"h3"}}),ee=new y({props:{title:"Dependencies",local:"dependencies",headingTag:"h3"}}),ne=new y({props:{title:"Converting a model for AWS Neuron",local:"converting-a-model-for-aws-neuron",headingTag:"h3"}}),se=new me({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 me({props:{code:"LSUyMHRvcmNoLmppdC50cmFjZShtb2RlbCUyQyUyMCU1QnRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzJTVEKSUwQSUyQiUyMHRvcmNoLm5ldXJvbi50cmFjZShtb2RlbCUyQyUyMCU1QnRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzJTVEKQ==",highlighted:`<span class="hljs-deletion">- torch.jit.trace(model, [tokens_tensor, segments_tensors])</span>
<span class="hljs-addition">+ torch.neuron.trace(model, [tokens_tensor, segments_tensors])</span>`,wrap:!1}}),de=new Et({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/torchscript.md"}}),{c(){f=a("meta"),T=s(),M=a("p"),pe=s(),d(g.$$.fragment),ue=s(),d(w.$$.fragment),fe=s(),b=a("p"),b.innerHTML=at,Me=s(),J=a("blockquote"),J.innerHTML=it,ye=s(),v=a("p"),v.innerHTML=rt,we=s(),$=a("p"),$.textContent=dt,Te=s(),U=a("p"),U.textContent=pt,ge=s(),j=a("ul"),j.innerHTML=mt,be=s(),Z=a("p"),Z.textContent=ct,Je=s(),d(C.$$.fragment),ve=s(),_=a("p"),_.innerHTML=ht,$e=s(),B=a("p"),B.innerHTML=ut,Ue=s(),x=a("p"),x.innerHTML=ft,je=s(),d(I.$$.fragment),Ze=s(),k=a("p"),k.innerHTML=Mt,Ce=s(),H=a("p"),H.textContent=yt,_e=s(),d(S.$$.fragment),Be=s(),W=a("p"),W.textContent=wt,xe=s(),G=a("p"),G.textContent=Tt,Ie=s(),d(V.$$.fragment),ke=s(),R=a("p"),R.textContent=gt,He=s(),d(z.$$.fragment),Se=s(),Q=a("p"),Q.innerHTML=bt,We=s(),d(N.$$.fragment),Ge=s(),d(E.$$.fragment),Ve=s(),X=a("p"),X.innerHTML=Jt,Re=s(),d(L.$$.fragment),ze=s(),d(A.$$.fragment),Qe=s(),P=a("p"),P.innerHTML=vt,Ne=s(),d(Y.$$.fragment),Ee=s(),d(F.$$.fragment),Xe=s(),D=a("p"),D.innerHTML=$t,Le=s(),q=a("ol"),q.innerHTML=Ut,Ae=s(),d(K.$$.fragment),Pe=s(),O=a("p"),O.innerHTML=jt,Ye=s(),d(ee.$$.fragment),Fe=s(),te=a("p"),te.innerHTML=Zt,De=s(),d(ne.$$.fragment),qe=s(),le=a("p"),le.innerHTML=Ct,Ke=s(),d(se.$$.fragment),Oe=s(),oe=a("p"),oe.textContent=_t,et=s(),d(ae.$$.fragment),tt=s(),ie=a("p"),ie.textContent=Bt,nt=s(),re=a("p"),re.innerHTML=xt,lt=s(),d(de.$$.fragment),st=s(),ce=a("p"),this.h()},l(e){const t=zt("svelte-u9bgzb",document.head);f=i(t,"META",{name:!0,content:!0}),t.forEach(n),T=o(e),M=i(e,"P",{}),kt(M).forEach(n),pe=o(e),p(g.$$.fragment,e),ue=o(e),p(w.$$.fragment,e),fe=o(e),b=i(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-16vv52d"&&(b.innerHTML=at),Me=o(e),J=i(e,"BLOCKQUOTE",{"data-svelte-h":!0}),r(J)!=="svelte-143rw8d"&&(J.innerHTML=it),ye=o(e),v=i(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1ntf3wg"&&(v.innerHTML=rt),we=o(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-3e4o7k"&&($.textContent=dt),Te=o(e),U=i(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1mmf9kh"&&(U.textContent=pt),ge=o(e),j=i(e,"UL",{"data-svelte-h":!0}),r(j)!=="svelte-1yusujd"&&(j.innerHTML=mt),be=o(e),Z=i(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-9awfof"&&(Z.textContent=ct),Je=o(e),p(C.$$.fragment,e),ve=o(e),_=i(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-qq8y9a"&&(_.innerHTML=ht),$e=o(e),B=i(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-rijh7h"&&(B.innerHTML=ut),Ue=o(e),x=i(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-1cg0vrq"&&(x.innerHTML=ft),je=o(e),p(I.$$.fragment,e),Ze=o(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1an8gt1"&&(k.innerHTML=Mt),Ce=o(e),H=i(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1pagcqs"&&(H.textContent=yt),_e=o(e),p(S.$$.fragment,e),Be=o(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-e7h40q"&&(W.textContent=wt),xe=o(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-k3vdvp"&&(G.textContent=Tt),Ie=o(e),p(V.$$.fragment,e),ke=o(e),R=i(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-3ddxtn"&&(R.textContent=gt),He=o(e),p(z.$$.fragment,e),Se=o(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1y405n0"&&(Q.innerHTML=bt),We=o(e),p(N.$$.fragment,e),Ge=o(e),p(E.$$.fragment,e),Ve=o(e),X=i(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-uqg1ob"&&(X.innerHTML=Jt),Re=o(e),p(L.$$.fragment,e),ze=o(e),p(A.$$.fragment,e),Qe=o(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-1prvnq1"&&(P.innerHTML=vt),Ne=o(e),p(Y.$$.fragment,e),Ee=o(e),p(F.$$.fragment,e),Xe=o(e),D=i(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-1kac3or"&&(D.innerHTML=$t),Le=o(e),q=i(e,"OL",{"data-svelte-h":!0}),r(q)!=="svelte-1h435mi"&&(q.innerHTML=Ut),Ae=o(e),p(K.$$.fragment,e),Pe=o(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1kv7oct"&&(O.innerHTML=jt),Ye=o(e),p(ee.$$.fragment,e),Fe=o(e),te=i(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-f2qubg"&&(te.innerHTML=Zt),De=o(e),p(ne.$$.fragment,e),qe=o(e),le=i(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-1flzoza"&&(le.innerHTML=Ct),Ke=o(e),p(se.$$.fragment,e),Oe=o(e),oe=i(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-uv51ic"&&(oe.textContent=_t),et=o(e),p(ae.$$.fragment,e),tt=o(e),ie=i(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-1dylit2"&&(ie.textContent=Bt),nt=o(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-u8nslf"&&(re.innerHTML=xt),lt=o(e),p(de.$$.fragment,e),st=o(e),ce=i(e,"P",{}),kt(ce).forEach(n),this.h()},h(){Ht(f,"name","hf:doc:metadata"),Ht(f,"content",At)},m(e,t){Qt(document.head,f),l(e,T,t),l(e,M,t),l(e,pe,t),m(g,e,t),l(e,ue,t),m(w,e,t),l(e,fe,t),l(e,b,t),l(e,Me,t),l(e,J,t),l(e,ye,t),l(e,v,t),l(e,we,t),l(e,$,t),l(e,Te,t),l(e,U,t),l(e,ge,t),l(e,j,t),l(e,be,t),l(e,Z,t),l(e,Je,t),m(C,e,t),l(e,ve,t),l(e,_,t),l(e,$e,t),l(e,B,t),l(e,Ue,t),l(e,x,t),l(e,je,t),m(I,e,t),l(e,Ze,t),l(e,k,t),l(e,Ce,t),l(e,H,t),l(e,_e,t),m(S,e,t),l(e,Be,t),l(e,W,t),l(e,xe,t),l(e,G,t),l(e,Ie,t),m(V,e,t),l(e,ke,t),l(e,R,t),l(e,He,t),m(z,e,t),l(e,Se,t),l(e,Q,t),l(e,We,t),m(N,e,t),l(e,Ge,t),m(E,e,t),l(e,Ve,t),l(e,X,t),l(e,Re,t),m(L,e,t),l(e,ze,t),m(A,e,t),l(e,Qe,t),l(e,P,t),l(e,Ne,t),m(Y,e,t),l(e,Ee,t),m(F,e,t),l(e,Xe,t),l(e,D,t),l(e,Le,t),l(e,q,t),l(e,Ae,t),m(K,e,t),l(e,Pe,t),l(e,O,t),l(e,Ye,t),m(ee,e,t),l(e,Fe,t),l(e,te,t),l(e,De,t),m(ne,e,t),l(e,qe,t),l(e,le,t),l(e,Ke,t),m(se,e,t),l(e,Oe,t),l(e,oe,t),l(e,et,t),m(ae,e,t),l(e,tt,t),l(e,ie,t),l(e,nt,t),l(e,re,t),l(e,lt,t),m(de,e,t),l(e,st,t),l(e,ce,t),ot=!0},p(e,[t]){const It={};t&2&&(It.$$scope={dirty:t,ctx:e}),w.$set(It)},i(e){ot||(c(g.$$.fragment,e),c(w.$$.fragment,e),c(C.$$.fragment,e),c(I.$$.fragment,e),c(S.$$.fragment,e),c(V.$$.fragment,e),c(z.$$.fragment,e),c(N.$$.fragment,e),c(E.$$.fragment,e),c(L.$$.fragment,e),c(A.$$.fragment,e),c(Y.$$.fragment,e),c(F.$$.fragment,e),c(K.$$.fragment,e),c(ee.$$.fragment,e),c(ne.$$.fragment,e),c(se.$$.fragment,e),c(ae.$$.fragment,e),c(de.$$.fragment,e),ot=!0)},o(e){h(g.$$.fragment,e),h(w.$$.fragment,e),h(C.$$.fragment,e),h(I.$$.fragment,e),h(S.$$.fragment,e),h(V.$$.fragment,e),h(z.$$.fragment,e),h(N.$$.fragment,e),h(E.$$.fragment,e),h(L.$$.fragment,e),h(A.$$.fragment,e),h(Y.$$.fragment,e),h(F.$$.fragment,e),h(K.$$.fragment,e),h(ee.$$.fragment,e),h(ne.$$.fragment,e),h(se.$$.fragment,e),h(ae.$$.fragment,e),h(de.$$.fragment,e),ot=!1},d(e){e&&(n(T),n(M),n(pe),n(ue),n(fe),n(b),n(Me),n(J),n(ye),n(v),n(we),n($),n(Te),n(U),n(ge),n(j),n(be),n(Z),n(Je),n(ve),n(_),n($e),n(B),n(Ue),n(x),n(je),n(Ze),n(k),n(Ce),n(H),n(_e),n(Be),n(W),n(xe),n(G),n(Ie),n(ke),n(R),n(He),n(Se),n(Q),n(We),n(Ge),n(Ve),n(X),n(Re),n(ze),n(Qe),n(P),n(Ne),n(Ee),n(Xe),n(D),n(Le),n(q),n(Ae),n(Pe),n(O),n(Ye),n(Fe),n(te),n(De),n(qe),n(le),n(Ke),n(Oe),n(oe),n(et),n(tt),n(ie),n(nt),n(re),n(lt),n(st),n(ce)),n(f),u(g,e),u(w,e),u(C,e),u(I,e),u(S,e),u(V,e),u(z,e),u(N,e),u(E,e),u(L,e),u(A,e),u(Y,e),u(F,e),u(K,e),u(ee,e),u(ne,e),u(se,e),u(ae,e),u(de,e)}}}const At='{"title":"Export to TorchScript","local":"export-to-torchscript","sections":[{"title":"TorchScript flag and tied weights","local":"torchscript-flag-and-tied-weights","sections":[],"depth":2},{"title":"Dummy inputs and standard lengths","local":"dummy-inputs-and-standard-lengths","sections":[],"depth":2},{"title":"Using TorchScript in Python","local":"using-torchscript-in-python","sections":[{"title":"Saving a model","local":"saving-a-model","sections":[],"depth":3},{"title":"Loading a model","local":"loading-a-model","sections":[],"depth":3},{"title":"Using a traced model for inference","local":"using-a-traced-model-for-inference","sections":[],"depth":3}],"depth":2},{"title":"Deploy Hugging Face TorchScript models to AWS with the Neuron SDK","local":"deploy-hugging-face-torchscript-models-to-aws-with-the-neuron-sdk","sections":[{"title":"Implications","local":"implications","sections":[],"depth":3},{"title":"Dependencies","local":"dependencies","sections":[],"depth":3},{"title":"Converting a model for AWS Neuron","local":"converting-a-model-for-aws-neuron","sections":[],"depth":3}],"depth":2}],"depth":1}';function Pt(he){return Wt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ot extends Vt{constructor(f){super(),Rt(this,f,Pt,Lt,St,{})}}export{Ot as component};
