import{s as St,o as Wt,n as Gt}from"../chunks/scheduler.25b97de1.js";import{S as Rt,i as Vt,g as a,s,r as p,A as Nt,h as i,f as n,c as o,j as kt,u as d,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 zt}from"../chunks/Tip.baa67368.js";import{C as me}from"../chunks/CodeBlock.e6cd0d95.js";import{H as y,E as Xt}from"../chunks/EditOnGithub.91d95064.js";function Et(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,de){l(M,f,de)},p:Gt,d(M){M&&n(f)}}}function Lt(he){let f,T,M,de,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,$,pt=`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,dt="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,C,ct=`These necessities imply several things developers should be careful about as detailed
below.`,Je,Z,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,x,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,B,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,Ce,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.`,Ze,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,xe,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.`,Be,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,R,ke,V,gt=`This section demonstrates how to save and load models as well as how to use the trace
for inference.`,He,N,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,z,Ge,X,Re,E,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>:`,Ve,L,Ne,A,Qe,P,vt="Use the traced model for inference by using its <code>__call__</code> dunder method:",ze,Y,Xe,F,Ee,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,Ct=`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,Zt=`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,xt="This enables the Neuron SDK to trace the model and optimize it for Inf1 instances.",nt,re,Bt=`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,pe,st,ce,ot;return g=new y({props:{title:"Export to TorchScript",local:"export-to-torchscript",headingTag:"h1"}}),w=new zt({props:{$$slots:{default:[Et]},$$scope:{ctx:he}}}),Z=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}}),R=new y({props:{title:"Using TorchScript in Python",local:"using-torchscript-in-python",headingTag:"h2"}}),N=new y({props:{title:"Saving a model",local:"saving-a-model",headingTag:"h3"}}),z=new me({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElMEFl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jB0aGUlMjBUb3JjaFNjcmlwdCUyMGZsYWclMEFtb2RlbCUyMCUzRCUyMEJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMHRvcmNoc2NyaXB0JTNEVHJ1ZSklMEElMEElMjMlMjBDcmVhdGluZyUyMHRoZSUyMHRyYWNlJTBBdHJhY2VkX21vZGVsJTIwJTNEJTIwdG9yY2guaml0LnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5zX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQpJTBBdG9yY2guaml0LnNhdmUodHJhY2VkX21vZGVsJTJDJTIwJTIydHJhY2VkX2JlcnQucHQlMjIp",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}}),X=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:"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 Xt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/torchscript.md"}}),{c(){f=a("meta"),T=s(),M=a("p"),de=s(),p(g.$$.fragment),ue=s(),p(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=pt,Te=s(),U=a("p"),U.textContent=dt,ge=s(),j=a("ul"),j.innerHTML=mt,be=s(),C=a("p"),C.textContent=ct,Je=s(),p(Z.$$.fragment),ve=s(),_=a("p"),_.innerHTML=ht,$e=s(),x=a("p"),x.innerHTML=ut,Ue=s(),B=a("p"),B.innerHTML=ft,je=s(),p(I.$$.fragment),Ce=s(),k=a("p"),k.innerHTML=Mt,Ze=s(),H=a("p"),H.textContent=yt,_e=s(),p(S.$$.fragment),xe=s(),W=a("p"),W.textContent=wt,Be=s(),G=a("p"),G.textContent=Tt,Ie=s(),p(R.$$.fragment),ke=s(),V=a("p"),V.textContent=gt,He=s(),p(N.$$.fragment),Se=s(),Q=a("p"),Q.innerHTML=bt,We=s(),p(z.$$.fragment),Ge=s(),p(X.$$.fragment),Re=s(),E=a("p"),E.innerHTML=Jt,Ve=s(),p(L.$$.fragment),Ne=s(),p(A.$$.fragment),Qe=s(),P=a("p"),P.innerHTML=vt,ze=s(),p(Y.$$.fragment),Xe=s(),p(F.$$.fragment),Ee=s(),D=a("p"),D.innerHTML=$t,Le=s(),q=a("ol"),q.innerHTML=Ut,Ae=s(),p(K.$$.fragment),Pe=s(),O=a("p"),O.innerHTML=jt,Ye=s(),p(ee.$$.fragment),Fe=s(),te=a("p"),te.innerHTML=Ct,De=s(),p(ne.$$.fragment),qe=s(),le=a("p"),le.innerHTML=Zt,Ke=s(),p(se.$$.fragment),Oe=s(),oe=a("p"),oe.textContent=_t,et=s(),p(ae.$$.fragment),tt=s(),ie=a("p"),ie.textContent=xt,nt=s(),re=a("p"),re.innerHTML=Bt,lt=s(),p(pe.$$.fragment),st=s(),ce=a("p"),this.h()},l(e){const t=Nt("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),de=o(e),d(g.$$.fragment,e),ue=o(e),d(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=pt),Te=o(e),U=i(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1mmf9kh"&&(U.textContent=dt),ge=o(e),j=i(e,"UL",{"data-svelte-h":!0}),r(j)!=="svelte-1yusujd"&&(j.innerHTML=mt),be=o(e),C=i(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-9awfof"&&(C.textContent=ct),Je=o(e),d(Z.$$.fragment,e),ve=o(e),_=i(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-qq8y9a"&&(_.innerHTML=ht),$e=o(e),x=i(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-rijh7h"&&(x.innerHTML=ut),Ue=o(e),B=i(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1cg0vrq"&&(B.innerHTML=ft),je=o(e),d(I.$$.fragment,e),Ce=o(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1an8gt1"&&(k.innerHTML=Mt),Ze=o(e),H=i(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1pagcqs"&&(H.textContent=yt),_e=o(e),d(S.$$.fragment,e),xe=o(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-e7h40q"&&(W.textContent=wt),Be=o(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-k3vdvp"&&(G.textContent=Tt),Ie=o(e),d(R.$$.fragment,e),ke=o(e),V=i(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-3ddxtn"&&(V.textContent=gt),He=o(e),d(N.$$.fragment,e),Se=o(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1y405n0"&&(Q.innerHTML=bt),We=o(e),d(z.$$.fragment,e),Ge=o(e),d(X.$$.fragment,e),Re=o(e),E=i(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-uqg1ob"&&(E.innerHTML=Jt),Ve=o(e),d(L.$$.fragment,e),Ne=o(e),d(A.$$.fragment,e),Qe=o(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-1prvnq1"&&(P.innerHTML=vt),ze=o(e),d(Y.$$.fragment,e),Xe=o(e),d(F.$$.fragment,e),Ee=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),d(K.$$.fragment,e),Pe=o(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1kv7oct"&&(O.innerHTML=jt),Ye=o(e),d(ee.$$.fragment,e),Fe=o(e),te=i(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-f2qubg"&&(te.innerHTML=Ct),De=o(e),d(ne.$$.fragment,e),qe=o(e),le=i(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-1flzoza"&&(le.innerHTML=Zt),Ke=o(e),d(se.$$.fragment,e),Oe=o(e),oe=i(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-uv51ic"&&(oe.textContent=_t),et=o(e),d(ae.$$.fragment,e),tt=o(e),ie=i(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-1dylit2"&&(ie.textContent=xt),nt=o(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-u8nslf"&&(re.innerHTML=Bt),lt=o(e),d(pe.$$.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,de,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,C,t),l(e,Je,t),m(Z,e,t),l(e,ve,t),l(e,_,t),l(e,$e,t),l(e,x,t),l(e,Ue,t),l(e,B,t),l(e,je,t),m(I,e,t),l(e,Ce,t),l(e,k,t),l(e,Ze,t),l(e,H,t),l(e,_e,t),m(S,e,t),l(e,xe,t),l(e,W,t),l(e,Be,t),l(e,G,t),l(e,Ie,t),m(R,e,t),l(e,ke,t),l(e,V,t),l(e,He,t),m(N,e,t),l(e,Se,t),l(e,Q,t),l(e,We,t),m(z,e,t),l(e,Ge,t),m(X,e,t),l(e,Re,t),l(e,E,t),l(e,Ve,t),m(L,e,t),l(e,Ne,t),m(A,e,t),l(e,Qe,t),l(e,P,t),l(e,ze,t),m(Y,e,t),l(e,Xe,t),m(F,e,t),l(e,Ee,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(pe,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(Z.$$.fragment,e),c(I.$$.fragment,e),c(S.$$.fragment,e),c(R.$$.fragment,e),c(N.$$.fragment,e),c(z.$$.fragment,e),c(X.$$.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(pe.$$.fragment,e),ot=!0)},o(e){h(g.$$.fragment,e),h(w.$$.fragment,e),h(Z.$$.fragment,e),h(I.$$.fragment,e),h(S.$$.fragment,e),h(R.$$.fragment,e),h(N.$$.fragment,e),h(z.$$.fragment,e),h(X.$$.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(pe.$$.fragment,e),ot=!1},d(e){e&&(n(T),n(M),n(de),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(C),n(Je),n(ve),n(_),n($e),n(x),n(Ue),n(B),n(je),n(Ce),n(k),n(Ze),n(H),n(_e),n(xe),n(W),n(Be),n(G),n(Ie),n(ke),n(V),n(He),n(Se),n(Q),n(We),n(Ge),n(Re),n(E),n(Ve),n(Ne),n(Qe),n(P),n(ze),n(Xe),n(Ee),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(Z,e),u(I,e),u(S,e),u(R,e),u(N,e),u(z,e),u(X,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(pe,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 Rt{constructor(f){super(),Vt(this,f,Pt,Lt,St,{})}}export{Ot as component};
