import{s as Zs,o as Bs,n as As}from"../chunks/scheduler.5f3e6389.js";import{S as gs,i as Gs,e as M,s as n,c as J,h as Ns,a as o,d as s,b as a,f as bs,g as i,j as T,k as Cs,l as xs,m as t,n as w,t as p,o as y,p as j}from"../chunks/index.373ab25c.js";import{T as fs}from"../chunks/Tip.3e202241.js";import{C as Ws,H as f}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a89e955d.js";import{C as m}from"../chunks/CodeBlock.d66e8072.js";function Xs(xl){let c,h=`Once exported, a model can be optimized for inference via techniques such as
graph optimization and quantization. Check the <code>optimum.onnxruntime</code> subpackage to optimize and run ONNX models!`;return{c(){c=M("p"),c.innerHTML=h},l(I){c=o(I,"P",{"data-svelte-h":!0}),T(c)!=="svelte-ejb35d"&&(c.innerHTML=h)},m(I,d){t(I,c,d)},p:As,d(I){I&&s(c)}}}function Vs(xl){let c,h="It is also possible to export the model to ONNX directly from the <code>ORTModelForQuestionAnswering</code> class by doing the following:",I,d,U,u,b='For more information, check the <code>optimum.onnxruntime</code> documentation <a href="/onnxruntime/overview">page on this topic</a>.',A;return d=new m({props:{code:"bW9kZWwlMjAlM0QlMjBPUlRNb2RlbEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1kaXN0aWxsZWQtc3F1YWQlMjIlMkMlMjBleHBvcnQlM0RUcnVlKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased-distilled-squad&quot;</span>, export=<span class="hljs-literal">True</span>)',wrap:!1}}),{c(){c=M("p"),c.innerHTML=h,I=n(),J(d.$$.fragment),U=n(),u=M("p"),u.innerHTML=b},l(r){c=o(r,"P",{"data-svelte-h":!0}),T(c)!=="svelte-xle6cn"&&(c.innerHTML=h),I=a(r),i(d.$$.fragment,r),U=a(r),u=o(r,"P",{"data-svelte-h":!0}),T(u)!=="svelte-ythc6"&&(u.innerHTML=b)},m(r,C){t(r,c,C),t(r,I,C),w(d,r,C),t(r,U,C),t(r,u,C),A=!0},p:As,i(r){A||(p(d.$$.fragment,r),A=!0)},o(r){y(d.$$.fragment,r),A=!1},d(r){r&&(s(c),s(I),s(U),s(u)),j(d,r)}}}function _s(xl){let c,h,I,d,U,u,b,A,r,C,g,Ee="Exporting a model to ONNX is as simple as",Xl,G,Vl,N,Qe="Check out the help for more options:",_l,x,kl,W,Rl,X,Fe=`If you need to deploy 🤗 Transformers or 🤗 Diffusers models in production environments, we recommend
exporting them to a serialized format that can be loaded and executed on specialized
runtimes and hardware. In this guide, we’ll show you how to export these
models to <a href="http://onnx.ai" rel="nofollow">ONNX (Open Neural Network eXchange)</a>.`,vl,V,He=`ONNX is an open standard that defines a common set of operators and a common file format
to represent deep learning models in a wide variety of frameworks, including PyTorch and
TensorFlow. When a model is exported to the ONNX format, these operators are used to
construct a computational graph (often called an <em>intermediate representation</em>) which
represents the flow of data through the neural network.`,El,_,ze=`By exposing a graph with standardized operators and data types, ONNX makes it easy to
switch between frameworks. For example, a model trained in PyTorch can be exported to
ONNX format and then imported in TensorRT or OpenVINO.`,Ql,Z,Fl,k,Se=`🤗 Optimum provides support for the ONNX export by leveraging configuration objects.
These configuration objects come ready made for a number of model architectures, and are
designed to be easily extendable to other architectures.`,Hl,R,Ye='<strong>To check the supported architectures, go to the <a href="../package_reference/configuration#supported-architectures">configuration reference page</a>.</strong>',zl,v,Sl,E,$e=`To export a 🤗 Transformers or 🤗 Diffusers model to ONNX, you’ll first need to install some extra
dependencies:`,Yl,Q,$l,F,Le="The Optimum ONNX export can be used through Optimum command-line:",Ll,H,ql,z,qe="Exporting a checkpoint can be done as follows:",Ol,S,Dl,Y,Oe="You should see the following logs (along with potential logs from PyTorch that were hidden here for clarity):",Pl,$,Kl,L,De=`This exports an ONNX graph of the checkpoint defined by the <code>--model</code> argument.
As you can see, the task was automatically detected. This was possible because the model was on the Hub.`,le,q,Pe="For local models, providing the <code>--task</code> argument is needed or it will default to the model architecture without any task specific head:",ee,O,se,D,Ke="Note that providing the <code>--task</code> argument for a model on the Hub will disable the automatic task detection.",te,P,ls=`The resulting <code>model.onnx</code> file can then be run on one of the <a href="https://onnx.ai/supported-tools.html#deployModel" rel="nofollow">many
accelerators</a> that support the ONNX
standard. For example, we can load and run the model with <a href="https://onnxruntime.ai/" rel="nofollow">ONNX
Runtime</a> using the <code>optimum.onnxruntime</code> package as follows:`,ne,K,ae,ll,es="Printing the outputs would give that:",Me,el,oe,sl,ss="As you can see, converting a model to ONNX does not mean leaving the Hugging Face ecosystem. You end up with a similar API as regular 🤗 Transformers models!",Te,B,Je,tl,ie,nl,ts='Models exported through <code>optimum-cli export onnx</code> can be used directly in <a href="/docs/optimum/main/en/onnxruntime/package_reference/modeling#optimum.onnxruntime.ORTModel">ORTModel</a>. This is especially useful for encoder-decoder models, where in this case the export will split the encoder and decoder into two <code>.onnx</code> files, as the encoder is usually only run once while the decoder may be run several times in autogenerative tasks.',we,al,pe,Ml,ns='When exporting a decoder model used for generation, it can be useful to encapsulate in the exported ONNX the <a href="https://discuss.huggingface.co/t/what-is-the-purpose-of-use-cache-in-decoder/958/2" rel="nofollow">reuse of past keys and values</a>. This allows to avoid recomputing the same intermediate activations during the generation.',ye,ol,as="In the ONNX export, the past keys/values are reused by default. This behavior corresponds to <code>--task text2text-generation-with-past</code>, <code>--task text-generation-with-past</code>, or <code>--task automatic-speech-recognition-with-past</code>. If for any purpose you would like to disable the export with past keys/values reuse, passing explicitly to <code>optimum-cli export onnx</code> the task <code>text2text-generation</code>, <code>text-generation</code> or <code>automatic-speech-recognition</code> is required.",je,Tl,Ms='A model exported using past key/values can be reused directly into Optimum’s <a href="/docs/optimum/main/en/onnxruntime/package_reference/modeling#optimum.onnxruntime.ORTModel">ORTModel</a>:',re,Jl,ce,il,os="and",Ie,wl,me,pl,de,yl,Ts="Specifying a <code>--task</code> should not be necessary in most cases when exporting from a model on the Hugging Face Hub.",Ue,jl,Js='However, in case you need to check for a given a model architecture what tasks the ONNX export supports, we got you covered. First, you can check the list of supported tasks for both PyTorch <a href="/exporters/task_manager">here</a>.',ue,rl,is="For each model architecture, you can find the list of supported tasks via the <code>TasksManager</code>. For example, for DistilBERT, for the ONNX export, we have:",he,cl,be,Il,ws="You can then pass one of these tasks to the <code>--task</code> argument in the <code>optimum-cli export onnx</code> command, as mentioned above.",Ce,ml,fe,dl,Ae,Ul,ps="Optimum allows for advanced users a finer-grained control over the configuration for the ONNX export. This is especially useful if you would like to export models with different keyword arguments, for example using <code>output_attentions=True</code> or <code>output_hidden_states=True</code>.",Ze,ul,ys="To support these use cases, <code>~exporters.main_export</code> supports two arguments: <code>model_kwargs</code> and <code>custom_onnx_configs</code>, which are used in the following fashion:",Be,hl,js='<li><code>model_kwargs</code> allows to override some of the default arguments to the models <code>forward</code>, in practice as <code>model(**reference_model_inputs, **model_kwargs)</code>.</li> <li><code>custom_onnx_configs</code> should be a <code>Dict[str, OnnxConfig]</code>, mapping from the submodel name (usually <code>model</code>, <code>encoder_model</code>, <code>decoder_model</code>, or <code>decoder_model_with_past</code> - <a href="https://github.com/huggingface/optimum/blob/main/optimum/exporters/onnx/constants.py" rel="nofollow">reference</a>) to a custom ONNX configuration for the given submodel.</li>',ge,bl,rs="A complete example is given below, allowing to export models with <code>output_attentions=True</code>.",Ge,Cl,Ne,fl,cs='For tasks that require only a single ONNX file (e.g. encoder-only), an exported model with custom inputs/outputs can then be used with the class <a href="/docs/optimum/main/en/onnxruntime/package_reference/modeling#optimum.onnxruntime.ORTModelForCustomTasks">optimum.onnxruntime.ORTModelForCustomTasks</a> for inference with ONNX Runtime on CPU or GPU.',xe,Al,We,Zl,Is='Optimum supports the export of Transformers models with custom modeling that use <a href="https://huggingface.co/docs/transformers/en/model_doc/auto#transformers.AutoModel.from_pretrained.trust_remote_code" rel="nofollow"><code>trust_remote_code=True</code></a>, not officially supported in the Transformers library but usable with its functionality as <a href="https://huggingface.co/docs/transformers/main_classes/pipelines" rel="nofollow">pipelines</a> and <a href="https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.GenerationMixin.generate" rel="nofollow">generation</a>.',Xe,Bl,ms='Examples of such models are <a href="https://huggingface.co/THUDM/chatglm2-6b" rel="nofollow">THUDM/chatglm2-6b</a> and <a href="https://huggingface.co/mosaicml/mpt-30b" rel="nofollow">mosaicml/mpt-30b</a>.',Ve,gl,ds='To export custom models, a dictionary <code>custom_onnx_configs</code> needs to be passed to <a href="/docs/optimum/main/en/onnx/package_reference/export#optimum.exporters.onnx.main_export">main_export()</a>, with the ONNX config definition for all the subparts of the model to export (for example, encoder and decoder subparts). The example below allows to export <code>mosaicml/mpt-7b</code> model:',_e,Gl,ke,Nl,Us="Moreover, the advanced argument <code>fn_get_submodels</code> to <code>main_export</code> allows to customize how the submodels are extracted in case the model needs to be exported in several submodels. Examples of such functions can be [consulted here](link to utils.py relevant code once merged).",Re,Wl,ve;return U=new Ws({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new f({props:{title:"Export a model to ONNX with optimum.exporters.onnx",local:"export-a-model-to-onnx-with-optimumexportersonnx",headingTag:"h1"}}),r=new f({props:{title:"Summary",local:"summary",headingTag:"h2"}}),G=new m({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGdwdDIlMjBncHQyX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model gpt2 gpt2_onnx/',wrap:!1}}),x=new m({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1oZWxw",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --<span class="hljs-built_in">help</span>',wrap:!1}}),W=new f({props:{title:"Why use ONNX?",local:"why-use-onnx",headingTag:"h2"}}),Z=new fs({props:{$$slots:{default:[Xs]},$$scope:{ctx:xl}}}),v=new f({props:{title:"Exporting a model to ONNX using the CLI",local:"exporting-a-model-to-onnx-using-the-cli",headingTag:"h2"}}),Q=new m({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJvbm54JTVE",highlighted:"pip install optimum[onnx]",wrap:!1}}),H=new m({props:{code:" ",highlighted:`optimum-cli <span class="hljs-built_in">export</span> onnx --<span class="hljs-built_in">help</span>

usage: optimum-cli &lt;<span class="hljs-built_in">command</span>&gt; [&lt;args&gt;] <span class="hljs-built_in">export</span> onnx [-h] -m MODEL [--task TASK] [--monolith] [--device DEVICE] [--opset OPSET] [--atol ATOL]
                                                  [--framework {pt}] [--pad_token_id PAD_TOKEN_ID] [--cache_dir CACHE_DIR] [--trust-remote-code]
                                                  [--no-post-process] [--optimize {O1,O2,O3,O4}] [--batch_size BATCH_SIZE]
                                                  [--sequence_length SEQUENCE_LENGTH] [--num_choices NUM_CHOICES] [--width WIDTH] [--height HEIGHT]
                                                  [--num_channels NUM_CHANNELS] [--feature_size FEATURE_SIZE] [--nb_max_frames NB_MAX_FRAMES]
                                                  [--audio_sequence_length AUDIO_SEQUENCE_LENGTH]
                                                  output

optional arguments:
  -h, --<span class="hljs-built_in">help</span>            show this <span class="hljs-built_in">help</span> message and <span class="hljs-built_in">exit</span>

Required arguments:
  -m MODEL, --model MODEL
                        Model ID on huggingface.co or path on disk to load model from.
  output                Path indicating the directory <span class="hljs-built_in">where</span> to store generated ONNX model.

Optional arguments:
  --task TASK           The task to <span class="hljs-built_in">export</span> the model <span class="hljs-keyword">for</span>. If not specified, the task will be auto-inferred based on the model. Available tasks depend on the model, but are among: [<span class="hljs-string">&#x27;default&#x27;</span>, <span class="hljs-string">&#x27;fill-mask&#x27;</span>, <span class="hljs-string">&#x27;text-generation&#x27;</span>, <span class="hljs-string">&#x27;text2text-generation&#x27;</span>, <span class="hljs-string">&#x27;text-classification&#x27;</span>, <span class="hljs-string">&#x27;token-classification&#x27;</span>, <span class="hljs-string">&#x27;multiple-choice&#x27;</span>, <span class="hljs-string">&#x27;object-detection&#x27;</span>, <span class="hljs-string">&#x27;question-answering&#x27;</span>, <span class="hljs-string">&#x27;image-classification&#x27;</span>, <span class="hljs-string">&#x27;image-segmentation&#x27;</span>, <span class="hljs-string">&#x27;masked-im&#x27;</span>, <span class="hljs-string">&#x27;semantic-segmentation&#x27;</span>, <span class="hljs-string">&#x27;automatic-speech-recognition&#x27;</span>, <span class="hljs-string">&#x27;audio-classification&#x27;</span>, <span class="hljs-string">&#x27;audio-frame-classification&#x27;</span>, <span class="hljs-string">&#x27;automatic-speech-recognition&#x27;</span>, <span class="hljs-string">&#x27;audio-xvector&#x27;</span>, <span class="hljs-string">&#x27;image-to-text&#x27;</span>, <span class="hljs-string">&#x27;zero-shot-object-detection&#x27;</span>, <span class="hljs-string">&#x27;image-to-image&#x27;</span>, <span class="hljs-string">&#x27;inpainting&#x27;</span>, <span class="hljs-string">&#x27;text-to-image&#x27;</span>]. For decoder models, use \`xxx-with-past\` to <span class="hljs-built_in">export</span> the model using past key values <span class="hljs-keyword">in</span> the decoder.
  --monolith            Force to <span class="hljs-built_in">export</span> the model as a single ONNX file. By default, the ONNX exporter may <span class="hljs-built_in">break</span> the model <span class="hljs-keyword">in</span> several ONNX files, <span class="hljs-keyword">for</span> example <span class="hljs-keyword">for</span> encoder-decoder models <span class="hljs-built_in">where</span> the encoder should be run only once <span class="hljs-keyword">while</span> the decoder is looped over.
  --device DEVICE       The device to use to <span class="hljs-keyword">do</span> the <span class="hljs-built_in">export</span>. Defaults to <span class="hljs-string">&quot;cpu&quot;</span>.
  --opset OPSET         If specified, ONNX opset version to <span class="hljs-built_in">export</span> the model with. Otherwise, the default opset will be used.
  --atol ATOL           If specified, the absolute difference tolerance when validating the model. Otherwise, the default atol <span class="hljs-keyword">for</span> the model will be used.
  --framework {pt}      The framework to use <span class="hljs-keyword">for</span> the ONNX <span class="hljs-built_in">export</span>. If not provided, will attempt to use the <span class="hljs-built_in">local</span> checkpoint<span class="hljs-string">&#x27;s original framework or what is available in the environment.
  --pad_token_id PAD_TOKEN_ID
                        This is needed by some models, for some tasks. If not provided, will attempt to use the tokenizer to guess it.
  --cache_dir CACHE_DIR
                        Path indicating where to store cache.
  --trust-remote-code   Allows to use custom code for the modeling hosted in the model repository. This option should only be set for repositories you trust and in which you have read the code, as it will execute on your local machine arbitrary code present in the model repository.
  --no-post-process     Allows to disable any post-processing done by default on the exported ONNX models. For example, the merging of decoder and decoder-with-past models into a single ONNX model file to reduce memory usage.
  --optimize {O1,O2,O3,O4}
                        Allows to run ONNX Runtime optimizations directly during the export. Some of these optimizations are specific to ONNX Runtime, and the resulting ONNX will not be usable with other runtime as OpenVINO or TensorRT. Possible options:
                            - O1: Basic general optimizations
                            - O2: Basic and extended general optimizations, transformers-specific fusions
                            - O3: Same as O2 with GELU approximation
                            - O4: Same as O3 with mixed precision (fp16, GPU-only, requires \`--device cuda\`)
</span>`,wrap:!1}}),S=new m({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGRpc3RpbGJlcnQtYmFzZS11bmNhc2VkLWRpc3RpbGxlZC1zcXVhZCUyMGRpc3RpbGJlcnRfYmFzZV91bmNhc2VkX3NxdWFkX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model distilbert-base-uncased-distilled-squad distilbert_base_uncased_squad_onnx/',wrap:!1}}),$=new m({props:{code:"QXV0b21hdGljJTIwdGFzayUyMGRldGVjdGlvbiUyMHRvJTIwcXVlc3Rpb24tYW5zd2VyaW5nLiUwQUZyYW1ld29yayUyMG5vdCUyMHNwZWNpZmllZC4lMjBVc2luZyUyMHB0JTIwdG8lMjBleHBvcnQlMjB0aGUlMjBtb2RlbC4lMEFVc2luZyUyMGZyYW1ld29yayUyMFB5VG9yY2glM0ElMjAxLjEyLjElMEElMEFWYWxpZGF0aW5nJTIwT05OWCUyMG1vZGVsLi4uJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyME9OTlglMjBtb2RlbCUyMG91dHB1dCUyMG5hbWVzJTIwbWF0Y2glMjByZWZlcmVuY2UlMjBtb2RlbCUyMChzdGFydF9sb2dpdHMlMkMlMjBlbmRfbG9naXRzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0lMjBWYWxpZGF0aW5nJTIwT05OWCUyME1vZGVsJTIwb3V0cHV0JTIwJTIyc3RhcnRfbG9naXRzJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSUyMFZhbGlkYXRpbmclMjBPTk5YJTIwTW9kZWwlMjBvdXRwdXQlMjAlMjJlbmRfbG9naXRzJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBQWxsJTIwZ29vZCUyQyUyMG1vZGVsJTIwc2F2ZWQlMjBhdCUzQSUyMGRpc3RpbGJlcnRfYmFzZV91bmNhc2VkX3NxdWFkX29ubnglMkZtb2RlbC5vbm54",highlighted:`Automatic task detection to question-answering.
Framework not specified. Using pt to <span class="hljs-built_in">export</span> the model.
Using framework PyTorch: 1.12.1

Validating ONNX model...
        -[✓] ONNX model output names match reference model (start_logits, end_logits)
        - Validating ONNX Model output <span class="hljs-string">&quot;start_logits&quot;</span>:
                -[✓] (2, 16) matches (2, 16)
                -[✓] all values close (atol: 0.0001)
        - Validating ONNX Model output <span class="hljs-string">&quot;end_logits&quot;</span>:
                -[✓] (2, 16) matches (2, 16)
                -[✓] all values close (atol: 0.0001)
All good, model saved at: distilbert_base_uncased_squad_onnx/model.onnx`,wrap:!1}}),O=new m({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGxvY2FsX3BhdGglMjAtLXRhc2slMjBxdWVzdGlvbi1hbnN3ZXJpbmclMjBkaXN0aWxiZXJ0X2Jhc2VfdW5jYXNlZF9zcXVhZF9vbm54JTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model local_path --task question-answering distilbert_base_uncased_squad_onnx/',wrap:!1}}),K=new m({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb3B0aW11bS5vbm54cnVudGltZSUyMGltcG9ydCUyME9SVE1vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0X2Jhc2VfdW5jYXNlZF9zcXVhZF9vbm54JTIyKSUwQW1vZGVsJTIwJTNEJTIwT1JUTW9kZWxGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydF9iYXNlX3VuY2FzZWRfc3F1YWRfb25ueCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyV2hhdCUyMGFtJTIwSSUyMHVzaW5nJTNGJTIyJTJDJTIwJTIyVXNpbmclMjBEaXN0aWxCRVJUJTIwd2l0aCUyME9OTlglMjBSdW50aW1lISUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert_base_uncased_squad_onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert_base_uncased_squad_onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;What am I using?&quot;</span>, <span class="hljs-string">&quot;Using DistilBERT with ONNX Runtime!&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)`,wrap:!1}}),el=new m({props:{code:"UXVlc3Rpb25BbnN3ZXJpbmdNb2RlbE91dHB1dChsb3NzJTNETm9uZSUyQyUyMHN0YXJ0X2xvZ2l0cyUzRHRlbnNvciglNUIlNUItNC43NjUyJTJDJTIwLTEuMDQ1MiUyQyUyMC03LjA0MDklMkMlMjAtNC42ODY0JTJDJTIwLTQuMDI3NyUyQyUyMC02LjIwMjElMkMlMjAtNC45NDczJTJDJTIwJTIwMi42Mjg3JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwNy42MTExJTJDJTIwLTEuMjQ4OCUyQyUyMC0yLjA1NTElMkMlMjAtMC45MzUwJTJDJTIwJTIwNC45NzU4JTJDJTIwLTAuNzcwNyUyQyUyMCUyMDIuMTQ5MyUyQyUyMC0yLjA3MDMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtNC4zMjMyJTJDJTIwLTQuOTQ3MiU1RCU1RCklMkMlMjBlbmRfbG9naXRzJTNEdGVuc29yKCU1QiU1QiUyMDAuNDM4MiUyQyUyMC0xLjY1MDIlMkMlMjAtNi4zNjU0JTJDJTIwLTYuMDY2MSUyQyUyMC00LjE0ODIlMkMlMjAtMy41Nzc5JTJDJTIwLTAuMDc3NCUyQyUyMC0zLjYxNjglMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtMS44NzUwJTJDJTIwLTIuODkxMCUyQyUyMCUyMDYuMjU4MiUyQyUyMCUyMDAuNTQyNSUyQyUyMC0zLjc2OTklMkMlMjAlMjAzLjgyMzIlMkMlMjAtMS41MDczJTJDJTIwJTIwNi4yMzExJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwMy4zNjA0JTJDJTIwLTAuMDc3MiU1RCU1RCklMkMlMjBoaWRkZW5fc3RhdGVzJTNETm9uZSUyQyUyMGF0dGVudGlvbnMlM0ROb25lKQ==",highlighted:`QuestionAnsweringModelOutput(loss=None, start_logits=tensor([[-4.7652, -1.0452, -7.0409, -4.6864, -4.0277, -6.2021, -4.9473,  2.6287,
          7.6111, -1.2488, -2.0551, -0.9350,  4.9758, -0.7707,  2.1493, -2.0703,
         -4.3232, -4.9472]]), end_logits=tensor([[ 0.4382, -1.6502, -6.3654, -6.0661, -4.1482, -3.5779, -0.0774, -3.6168,
         -1.8750, -2.8910,  6.2582,  0.5425, -3.7699,  3.8232, -1.5073,  6.2311,
          3.3604, -0.0772]]), hidden_states=None, attentions=None)`,wrap:!1}}),B=new fs({props:{$$slots:{default:[Vs]},$$scope:{ctx:xl}}}),tl=new f({props:{title:"Exporting a model to be used with Optimum’s ORTModel",local:"exporting-a-model-to-be-used-with-optimums-ortmodel",headingTag:"h3"}}),al=new f({props:{title:"Exporting a model using past keys/values in the decoder",local:"exporting-a-model-using-past-keysvalues-in-the-decoder",headingTag:"h3"}}),Jl=new m({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGdwdDIlMjBncHQyX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model gpt2 gpt2_onnx/',wrap:!1}}),wl=new m({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb3B0aW11bS5vbm54cnVudGltZSUyMGltcG9ydCUyME9SVE1vZGVsRm9yQ2F1c2FsTE0lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjIuJTJGZ3B0Ml9vbm54JTJGJTIyKSUwQW1vZGVsJTIwJTNEJTIwT1JUTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRmdwdDJfb25ueCUyRiUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyTXklMjBuYW1lJTIwaXMlMjBBcnRodXIlMjBhbmQlMjBJJTIwbGl2ZSUyMGluJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFnZW5fdG9rZW5zJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMpJTBBcHJpbnQodG9rZW5pemVyLmJhdGNoX2RlY29kZShnZW5fdG9rZW5zKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;./gpt2_onnx/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;./gpt2_onnx/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;My name is Arthur and I live in&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>gen_tokens = model.generate(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(gen_tokens))
<span class="hljs-comment"># prints [&#x27;My name is Arthur and I live in the United States of America. I am a member of the&#x27;]</span>`,wrap:!1}}),pl=new f({props:{title:"Selecting a task",local:"selecting-a-task",headingTag:"h2"}}),cl=new m({props:{code:"ZnJvbSUyMG9wdGltdW0uZXhwb3J0ZXJzLnRhc2tzJTIwaW1wb3J0JTIwVGFza3NNYW5hZ2VyJTBBJTBBZGlzdGlsYmVydF90YXNrcyUyMCUzRCUyMGxpc3QoVGFza3NNYW5hZ2VyLmdldF9zdXBwb3J0ZWRfdGFza3NfZm9yX21vZGVsX3R5cGUoJTIyZGlzdGlsYmVydCUyMiUyQyUyMCUyMm9ubnglMjIpLmtleXMoKSklMEFwcmludChkaXN0aWxiZXJ0X3Rhc2tzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.exporters.tasks <span class="hljs-keyword">import</span> TasksManager

<span class="hljs-meta">&gt;&gt;&gt; </span>distilbert_tasks = <span class="hljs-built_in">list</span>(TasksManager.get_supported_tasks_for_model_type(<span class="hljs-string">&quot;distilbert&quot;</span>, <span class="hljs-string">&quot;onnx&quot;</span>).keys())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(distilbert_tasks)
[<span class="hljs-string">&#x27;default&#x27;</span>, <span class="hljs-string">&#x27;fill-mask&#x27;</span>, <span class="hljs-string">&#x27;text-classification&#x27;</span>, <span class="hljs-string">&#x27;multiple-choice&#x27;</span>, <span class="hljs-string">&#x27;token-classification&#x27;</span>, <span class="hljs-string">&#x27;question-answering&#x27;</span>]`,wrap:!1}}),ml=new f({props:{title:"Custom export of Transformers models",local:"custom-export-of-transformers-models",headingTag:"h2"}}),dl=new f({props:{title:"Customize the export of official Transformers models",local:"customize-the-export-of-official-transformers-models",headingTag:"h3"}}),Cl=new m({props:{code:" ",highlighted:`<span class="hljs-keyword">from</span> optimum.exporters.onnx <span class="hljs-keyword">import</span> main_export
<span class="hljs-keyword">from</span> optimum.exporters.onnx.model_configs <span class="hljs-keyword">import</span> WhisperOnnxConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-keyword">from</span> optimum.exporters.onnx.base <span class="hljs-keyword">import</span> ConfigBehavior
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Dict</span>

<span class="hljs-keyword">class</span> <span class="hljs-title class_">CustomWhisperOnnxConfig</span>(<span class="hljs-title class_ inherited__">WhisperOnnxConfig</span>):
<span class="hljs-meta">    @property</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">outputs</span>(<span class="hljs-params">self</span>) -&gt; <span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, <span class="hljs-type">Dict</span>[<span class="hljs-built_in">int</span>, <span class="hljs-built_in">str</span>]]:
        common_outputs = <span class="hljs-built_in">super</span>().outputs

        <span class="hljs-keyword">if</span> self._behavior <span class="hljs-keyword">is</span> ConfigBehavior.ENCODER:
            <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(self._config.encoder_layers):
                common_outputs[<span class="hljs-string">f&quot;encoder_attentions.<span class="hljs-subst">{i}</span>&quot;</span>] = {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch_size&quot;</span>}
        <span class="hljs-keyword">elif</span> self._behavior <span class="hljs-keyword">is</span> ConfigBehavior.DECODER:
            <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(self._config.decoder_layers):
                common_outputs[<span class="hljs-string">f&quot;decoder_attentions.<span class="hljs-subst">{i}</span>&quot;</span>] = {
                    <span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch_size&quot;</span>,
                    <span class="hljs-number">2</span>: <span class="hljs-string">&quot;decoder_sequence_length&quot;</span>,
                    <span class="hljs-number">3</span>: <span class="hljs-string">&quot;past_decoder_sequence_length + 1&quot;</span>
                }
            <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(self._config.decoder_layers):
                common_outputs[<span class="hljs-string">f&quot;cross_attentions.<span class="hljs-subst">{i}</span>&quot;</span>] = {
                    <span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch_size&quot;</span>,
                    <span class="hljs-number">2</span>: <span class="hljs-string">&quot;decoder_sequence_length&quot;</span>,
                    <span class="hljs-number">3</span>: <span class="hljs-string">&quot;encoder_sequence_length_out&quot;</span>
                }

        <span class="hljs-keyword">return</span> common_outputs

<span class="hljs-meta">    @property</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">torch_to_onnx_output_map</span>(<span class="hljs-params">self</span>):
        <span class="hljs-keyword">if</span> self._behavior <span class="hljs-keyword">is</span> ConfigBehavior.ENCODER:
            <span class="hljs-comment"># The encoder export uses WhisperEncoder that returns the key &quot;attentions&quot;</span>
            <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;attentions&quot;</span>: <span class="hljs-string">&quot;encoder_attentions&quot;</span>}
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> {}

model_id = <span class="hljs-string">&quot;openai/whisper-tiny.en&quot;</span>
config = AutoConfig.from_pretrained(model_id)

custom_whisper_onnx_config = CustomWhisperOnnxConfig(
        config=config,
        task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>,
)

encoder_config = custom_whisper_onnx_config.with_behavior(<span class="hljs-string">&quot;encoder&quot;</span>)
decoder_config = custom_whisper_onnx_config.with_behavior(<span class="hljs-string">&quot;decoder&quot;</span>, use_past=<span class="hljs-literal">False</span>)
decoder_with_past_config = custom_whisper_onnx_config.with_behavior(<span class="hljs-string">&quot;decoder&quot;</span>, use_past=<span class="hljs-literal">True</span>)

custom_onnx_configs={
    <span class="hljs-string">&quot;encoder_model&quot;</span>: encoder_config,
    <span class="hljs-string">&quot;decoder_model&quot;</span>: decoder_config,
    <span class="hljs-string">&quot;decoder_with_past_model&quot;</span>: decoder_with_past_config,
}

main_export(
    model_id,
    output=<span class="hljs-string">&quot;custom_whisper_onnx&quot;</span>,
    no_post_process=<span class="hljs-literal">True</span>,
    model_kwargs={<span class="hljs-string">&quot;output_attentions&quot;</span>: <span class="hljs-literal">True</span>},
    custom_onnx_configs=custom_onnx_configs
)`,wrap:!1}}),Al=new f({props:{title:"Customize the export of Transformers models with custom modeling",local:"customize-the-export-of-transformers-models-with-custom-modeling",headingTag:"h3"}}),Gl=new m({props:{code:" ",highlighted:`<span class="hljs-keyword">from</span> optimum.exporters.onnx <span class="hljs-keyword">import</span> main_export

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-keyword">from</span> optimum.exporters.onnx.config <span class="hljs-keyword">import</span> TextDecoderOnnxConfig
<span class="hljs-keyword">from</span> optimum.utils <span class="hljs-keyword">import</span> NormalizedTextConfig, DummyPastKeyValuesGenerator
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Dict</span>


<span class="hljs-keyword">class</span> <span class="hljs-title class_">MPTDummyPastKeyValuesGenerator</span>(<span class="hljs-title class_ inherited__">DummyPastKeyValuesGenerator</span>):
    <span class="hljs-string">&quot;&quot;&quot;
    MPT swaps the two last dimensions for the key cache compared to usual transformers
    decoder models, thus the redefinition here.
    &quot;&quot;&quot;</span>
    <span class="hljs-keyword">def</span> <span class="hljs-title function_">generate</span>(<span class="hljs-params">self, input_name: <span class="hljs-built_in">str</span>, framework: <span class="hljs-built_in">str</span> = <span class="hljs-string">&quot;pt&quot;</span></span>):
        past_key_shape = (
            self.batch_size,
            self.num_attention_heads,
            self.hidden_size // self.num_attention_heads,
            self.sequence_length,
        )
        past_value_shape = (
            self.batch_size,
            self.num_attention_heads,
            self.sequence_length,
            self.hidden_size // self.num_attention_heads,
        )
        <span class="hljs-keyword">return</span> [
            (
                self.random_float_tensor(past_key_shape, framework=framework),
                self.random_float_tensor(past_value_shape, framework=framework),
            )
            <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(self.num_layers)
        ]

<span class="hljs-keyword">class</span> <span class="hljs-title class_">CustomMPTOnnxConfig</span>(<span class="hljs-title class_ inherited__">TextDecoderOnnxConfig</span>):
    DUMMY_INPUT_GENERATOR_CLASSES = (MPTDummyPastKeyValuesGenerator,) + TextDecoderOnnxConfig.DUMMY_INPUT_GENERATOR_CLASSES
    DUMMY_PKV_GENERATOR_CLASS = MPTDummyPastKeyValuesGenerator

    DEFAULT_ONNX_OPSET = <span class="hljs-number">18</span>
    NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args(
        hidden_size=<span class="hljs-string">&quot;d_model&quot;</span>,
        num_layers=<span class="hljs-string">&quot;n_layers&quot;</span>,
        num_attention_heads=<span class="hljs-string">&quot;n_heads&quot;</span>
    )

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">add_past_key_values</span>(<span class="hljs-params">self, inputs_or_outputs: <span class="hljs-type">Dict</span>[<span class="hljs-built_in">str</span>, <span class="hljs-type">Dict</span>[<span class="hljs-built_in">int</span>, <span class="hljs-built_in">str</span>]], direction: <span class="hljs-built_in">str</span></span>):
        <span class="hljs-string">&quot;&quot;&quot;
        Adapted from https://github.com/huggingface/optimum/blob/v1.9.0/optimum/exporters/onnx/base.py#L625
        &quot;&quot;&quot;</span>
        <span class="hljs-keyword">if</span> direction <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;inputs&quot;</span>, <span class="hljs-string">&quot;outputs&quot;</span>]:
            <span class="hljs-keyword">raise</span> ValueError(<span class="hljs-string">f&#x27;direction must either be &quot;inputs&quot; or &quot;outputs&quot;, but <span class="hljs-subst">{direction}</span> was given&#x27;</span>)

        <span class="hljs-keyword">if</span> direction == <span class="hljs-string">&quot;inputs&quot;</span>:
            decoder_sequence_name = <span class="hljs-string">&quot;past_sequence_length&quot;</span>
            name = <span class="hljs-string">&quot;past_key_values&quot;</span>
        <span class="hljs-keyword">else</span>:
            decoder_sequence_name = <span class="hljs-string">&quot;past_sequence_length + 1&quot;</span>
            name = <span class="hljs-string">&quot;present&quot;</span>

        <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(self._normalized_config.num_layers):
            inputs_or_outputs[<span class="hljs-string">f&quot;<span class="hljs-subst">{name}</span>.<span class="hljs-subst">{i}</span>.key&quot;</span>] = {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch_size&quot;</span>, <span class="hljs-number">3</span>: decoder_sequence_name}
            inputs_or_outputs[<span class="hljs-string">f&quot;<span class="hljs-subst">{name}</span>.<span class="hljs-subst">{i}</span>.value&quot;</span>] = {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch_size&quot;</span>, <span class="hljs-number">2</span>: decoder_sequence_name}


model_id = <span class="hljs-string">&quot;fxmarty/tiny-mpt-random-remote-code&quot;</span>
config = AutoConfig.from_pretrained(model_id, trust_remote_code=<span class="hljs-literal">True</span>)
onnx_config_with_past = CustomMPTOnnxConfig(config, task=<span class="hljs-string">&quot;text-generation&quot;</span>, use_past=<span class="hljs-literal">True</span>)

custom_onnx_configs = {<span class="hljs-string">&quot;model&quot;</span>: onnx_config_with_past}

main_export(
    model_id,
    output=<span class="hljs-string">&quot;mpt_onnx&quot;</span>,
    task=<span class="hljs-string">&quot;text-generation-with-past&quot;</span>,
    trust_remote_code=<span class="hljs-literal">True</span>,
    custom_onnx_configs=custom_onnx_configs,
    no_post_process=<span class="hljs-literal">True</span>,
    opset=<span class="hljs-number">14</span>
)`,wrap:!1}}),{c(){c=M("meta"),h=n(),I=M("p"),d=n(),J(U.$$.fragment),u=n(),J(b.$$.fragment),A=n(),J(r.$$.fragment),C=n(),g=M("p"),g.textContent=Ee,Xl=n(),J(G.$$.fragment),Vl=n(),N=M("p"),N.textContent=Qe,_l=n(),J(x.$$.fragment),kl=n(),J(W.$$.fragment),Rl=n(),X=M("p"),X.innerHTML=Fe,vl=n(),V=M("p"),V.innerHTML=He,El=n(),_=M("p"),_.textContent=ze,Ql=n(),J(Z.$$.fragment),Fl=n(),k=M("p"),k.textContent=Se,Hl=n(),R=M("p"),R.innerHTML=Ye,zl=n(),J(v.$$.fragment),Sl=n(),E=M("p"),E.textContent=$e,Yl=n(),J(Q.$$.fragment),$l=n(),F=M("p"),F.textContent=Le,Ll=n(),J(H.$$.fragment),ql=n(),z=M("p"),z.textContent=qe,Ol=n(),J(S.$$.fragment),Dl=n(),Y=M("p"),Y.textContent=Oe,Pl=n(),J($.$$.fragment),Kl=n(),L=M("p"),L.innerHTML=De,le=n(),q=M("p"),q.innerHTML=Pe,ee=n(),J(O.$$.fragment),se=n(),D=M("p"),D.innerHTML=Ke,te=n(),P=M("p"),P.innerHTML=ls,ne=n(),J(K.$$.fragment),ae=n(),ll=M("p"),ll.textContent=es,Me=n(),J(el.$$.fragment),oe=n(),sl=M("p"),sl.textContent=ss,Te=n(),J(B.$$.fragment),Je=n(),J(tl.$$.fragment),ie=n(),nl=M("p"),nl.innerHTML=ts,we=n(),J(al.$$.fragment),pe=n(),Ml=M("p"),Ml.innerHTML=ns,ye=n(),ol=M("p"),ol.innerHTML=as,je=n(),Tl=M("p"),Tl.innerHTML=Ms,re=n(),J(Jl.$$.fragment),ce=n(),il=M("p"),il.textContent=os,Ie=n(),J(wl.$$.fragment),me=n(),J(pl.$$.fragment),de=n(),yl=M("p"),yl.innerHTML=Ts,Ue=n(),jl=M("p"),jl.innerHTML=Js,ue=n(),rl=M("p"),rl.innerHTML=is,he=n(),J(cl.$$.fragment),be=n(),Il=M("p"),Il.innerHTML=ws,Ce=n(),J(ml.$$.fragment),fe=n(),J(dl.$$.fragment),Ae=n(),Ul=M("p"),Ul.innerHTML=ps,Ze=n(),ul=M("p"),ul.innerHTML=ys,Be=n(),hl=M("ul"),hl.innerHTML=js,ge=n(),bl=M("p"),bl.innerHTML=rs,Ge=n(),J(Cl.$$.fragment),Ne=n(),fl=M("p"),fl.innerHTML=cs,xe=n(),J(Al.$$.fragment),We=n(),Zl=M("p"),Zl.innerHTML=Is,Xe=n(),Bl=M("p"),Bl.innerHTML=ms,Ve=n(),gl=M("p"),gl.innerHTML=ds,_e=n(),J(Gl.$$.fragment),ke=n(),Nl=M("p"),Nl.innerHTML=Us,Re=n(),Wl=M("p"),this.h()},l(l){const e=Ns("svelte-u9bgzb",document.head);c=o(e,"META",{name:!0,content:!0}),e.forEach(s),h=a(l),I=o(l,"P",{}),bs(I).forEach(s),d=a(l),i(U.$$.fragment,l),u=a(l),i(b.$$.fragment,l),A=a(l),i(r.$$.fragment,l),C=a(l),g=o(l,"P",{"data-svelte-h":!0}),T(g)!=="svelte-1oa09xy"&&(g.textContent=Ee),Xl=a(l),i(G.$$.fragment,l),Vl=a(l),N=o(l,"P",{"data-svelte-h":!0}),T(N)!=="svelte-b35baa"&&(N.textContent=Qe),_l=a(l),i(x.$$.fragment,l),kl=a(l),i(W.$$.fragment,l),Rl=a(l),X=o(l,"P",{"data-svelte-h":!0}),T(X)!=="svelte-1cnwd0n"&&(X.innerHTML=Fe),vl=a(l),V=o(l,"P",{"data-svelte-h":!0}),T(V)!=="svelte-euckgi"&&(V.innerHTML=He),El=a(l),_=o(l,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1gw8h88"&&(_.textContent=ze),Ql=a(l),i(Z.$$.fragment,l),Fl=a(l),k=o(l,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1s6uhud"&&(k.textContent=Se),Hl=a(l),R=o(l,"P",{"data-svelte-h":!0}),T(R)!=="svelte-knw39o"&&(R.innerHTML=Ye),zl=a(l),i(v.$$.fragment,l),Sl=a(l),E=o(l,"P",{"data-svelte-h":!0}),T(E)!=="svelte-1you5wm"&&(E.textContent=$e),Yl=a(l),i(Q.$$.fragment,l),$l=a(l),F=o(l,"P",{"data-svelte-h":!0}),T(F)!=="svelte-1fl926d"&&(F.textContent=Le),Ll=a(l),i(H.$$.fragment,l),ql=a(l),z=o(l,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1kejiao"&&(z.textContent=qe),Ol=a(l),i(S.$$.fragment,l),Dl=a(l),Y=o(l,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-ihysar"&&(Y.textContent=Oe),Pl=a(l),i($.$$.fragment,l),Kl=a(l),L=o(l,"P",{"data-svelte-h":!0}),T(L)!=="svelte-109rm3j"&&(L.innerHTML=De),le=a(l),q=o(l,"P",{"data-svelte-h":!0}),T(q)!=="svelte-6f0nj1"&&(q.innerHTML=Pe),ee=a(l),i(O.$$.fragment,l),se=a(l),D=o(l,"P",{"data-svelte-h":!0}),T(D)!=="svelte-1bmxkbv"&&(D.innerHTML=Ke),te=a(l),P=o(l,"P",{"data-svelte-h":!0}),T(P)!=="svelte-1nck33v"&&(P.innerHTML=ls),ne=a(l),i(K.$$.fragment,l),ae=a(l),ll=o(l,"P",{"data-svelte-h":!0}),T(ll)!=="svelte-t36063"&&(ll.textContent=es),Me=a(l),i(el.$$.fragment,l),oe=a(l),sl=o(l,"P",{"data-svelte-h":!0}),T(sl)!=="svelte-rtz6xi"&&(sl.textContent=ss),Te=a(l),i(B.$$.fragment,l),Je=a(l),i(tl.$$.fragment,l),ie=a(l),nl=o(l,"P",{"data-svelte-h":!0}),T(nl)!=="svelte-158qyi8"&&(nl.innerHTML=ts),we=a(l),i(al.$$.fragment,l),pe=a(l),Ml=o(l,"P",{"data-svelte-h":!0}),T(Ml)!=="svelte-v3ph27"&&(Ml.innerHTML=ns),ye=a(l),ol=o(l,"P",{"data-svelte-h":!0}),T(ol)!=="svelte-p5wxrb"&&(ol.innerHTML=as),je=a(l),Tl=o(l,"P",{"data-svelte-h":!0}),T(Tl)!=="svelte-1oe2262"&&(Tl.innerHTML=Ms),re=a(l),i(Jl.$$.fragment,l),ce=a(l),il=o(l,"P",{"data-svelte-h":!0}),T(il)!=="svelte-1qlona5"&&(il.textContent=os),Ie=a(l),i(wl.$$.fragment,l),me=a(l),i(pl.$$.fragment,l),de=a(l),yl=o(l,"P",{"data-svelte-h":!0}),T(yl)!=="svelte-291hoy"&&(yl.innerHTML=Ts),Ue=a(l),jl=o(l,"P",{"data-svelte-h":!0}),T(jl)!=="svelte-189qp8m"&&(jl.innerHTML=Js),ue=a(l),rl=o(l,"P",{"data-svelte-h":!0}),T(rl)!=="svelte-1f3f6g4"&&(rl.innerHTML=is),he=a(l),i(cl.$$.fragment,l),be=a(l),Il=o(l,"P",{"data-svelte-h":!0}),T(Il)!=="svelte-1t0g6cf"&&(Il.innerHTML=ws),Ce=a(l),i(ml.$$.fragment,l),fe=a(l),i(dl.$$.fragment,l),Ae=a(l),Ul=o(l,"P",{"data-svelte-h":!0}),T(Ul)!=="svelte-1n2o16n"&&(Ul.innerHTML=ps),Ze=a(l),ul=o(l,"P",{"data-svelte-h":!0}),T(ul)!=="svelte-btd0km"&&(ul.innerHTML=ys),Be=a(l),hl=o(l,"UL",{"data-svelte-h":!0}),T(hl)!=="svelte-ah878r"&&(hl.innerHTML=js),ge=a(l),bl=o(l,"P",{"data-svelte-h":!0}),T(bl)!=="svelte-119hl5b"&&(bl.innerHTML=rs),Ge=a(l),i(Cl.$$.fragment,l),Ne=a(l),fl=o(l,"P",{"data-svelte-h":!0}),T(fl)!=="svelte-oirjjn"&&(fl.innerHTML=cs),xe=a(l),i(Al.$$.fragment,l),We=a(l),Zl=o(l,"P",{"data-svelte-h":!0}),T(Zl)!=="svelte-8am21n"&&(Zl.innerHTML=Is),Xe=a(l),Bl=o(l,"P",{"data-svelte-h":!0}),T(Bl)!=="svelte-1g9lv2i"&&(Bl.innerHTML=ms),Ve=a(l),gl=o(l,"P",{"data-svelte-h":!0}),T(gl)!=="svelte-yfb72j"&&(gl.innerHTML=ds),_e=a(l),i(Gl.$$.fragment,l),ke=a(l),Nl=o(l,"P",{"data-svelte-h":!0}),T(Nl)!=="svelte-y1tnao"&&(Nl.innerHTML=Us),Re=a(l),Wl=o(l,"P",{}),bs(Wl).forEach(s),this.h()},h(){Cs(c,"name","hf:doc:metadata"),Cs(c,"content",ks)},m(l,e){xs(document.head,c),t(l,h,e),t(l,I,e),t(l,d,e),w(U,l,e),t(l,u,e),w(b,l,e),t(l,A,e),w(r,l,e),t(l,C,e),t(l,g,e),t(l,Xl,e),w(G,l,e),t(l,Vl,e),t(l,N,e),t(l,_l,e),w(x,l,e),t(l,kl,e),w(W,l,e),t(l,Rl,e),t(l,X,e),t(l,vl,e),t(l,V,e),t(l,El,e),t(l,_,e),t(l,Ql,e),w(Z,l,e),t(l,Fl,e),t(l,k,e),t(l,Hl,e),t(l,R,e),t(l,zl,e),w(v,l,e),t(l,Sl,e),t(l,E,e),t(l,Yl,e),w(Q,l,e),t(l,$l,e),t(l,F,e),t(l,Ll,e),w(H,l,e),t(l,ql,e),t(l,z,e),t(l,Ol,e),w(S,l,e),t(l,Dl,e),t(l,Y,e),t(l,Pl,e),w($,l,e),t(l,Kl,e),t(l,L,e),t(l,le,e),t(l,q,e),t(l,ee,e),w(O,l,e),t(l,se,e),t(l,D,e),t(l,te,e),t(l,P,e),t(l,ne,e),w(K,l,e),t(l,ae,e),t(l,ll,e),t(l,Me,e),w(el,l,e),t(l,oe,e),t(l,sl,e),t(l,Te,e),w(B,l,e),t(l,Je,e),w(tl,l,e),t(l,ie,e),t(l,nl,e),t(l,we,e),w(al,l,e),t(l,pe,e),t(l,Ml,e),t(l,ye,e),t(l,ol,e),t(l,je,e),t(l,Tl,e),t(l,re,e),w(Jl,l,e),t(l,ce,e),t(l,il,e),t(l,Ie,e),w(wl,l,e),t(l,me,e),w(pl,l,e),t(l,de,e),t(l,yl,e),t(l,Ue,e),t(l,jl,e),t(l,ue,e),t(l,rl,e),t(l,he,e),w(cl,l,e),t(l,be,e),t(l,Il,e),t(l,Ce,e),w(ml,l,e),t(l,fe,e),w(dl,l,e),t(l,Ae,e),t(l,Ul,e),t(l,Ze,e),t(l,ul,e),t(l,Be,e),t(l,hl,e),t(l,ge,e),t(l,bl,e),t(l,Ge,e),w(Cl,l,e),t(l,Ne,e),t(l,fl,e),t(l,xe,e),w(Al,l,e),t(l,We,e),t(l,Zl,e),t(l,Xe,e),t(l,Bl,e),t(l,Ve,e),t(l,gl,e),t(l,_e,e),w(Gl,l,e),t(l,ke,e),t(l,Nl,e),t(l,Re,e),t(l,Wl,e),ve=!0},p(l,[e]){const us={};e&2&&(us.$$scope={dirty:e,ctx:l}),Z.$set(us);const hs={};e&2&&(hs.$$scope={dirty:e,ctx:l}),B.$set(hs)},i(l){ve||(p(U.$$.fragment,l),p(b.$$.fragment,l),p(r.$$.fragment,l),p(G.$$.fragment,l),p(x.$$.fragment,l),p(W.$$.fragment,l),p(Z.$$.fragment,l),p(v.$$.fragment,l),p(Q.$$.fragment,l),p(H.$$.fragment,l),p(S.$$.fragment,l),p($.$$.fragment,l),p(O.$$.fragment,l),p(K.$$.fragment,l),p(el.$$.fragment,l),p(B.$$.fragment,l),p(tl.$$.fragment,l),p(al.$$.fragment,l),p(Jl.$$.fragment,l),p(wl.$$.fragment,l),p(pl.$$.fragment,l),p(cl.$$.fragment,l),p(ml.$$.fragment,l),p(dl.$$.fragment,l),p(Cl.$$.fragment,l),p(Al.$$.fragment,l),p(Gl.$$.fragment,l),ve=!0)},o(l){y(U.$$.fragment,l),y(b.$$.fragment,l),y(r.$$.fragment,l),y(G.$$.fragment,l),y(x.$$.fragment,l),y(W.$$.fragment,l),y(Z.$$.fragment,l),y(v.$$.fragment,l),y(Q.$$.fragment,l),y(H.$$.fragment,l),y(S.$$.fragment,l),y($.$$.fragment,l),y(O.$$.fragment,l),y(K.$$.fragment,l),y(el.$$.fragment,l),y(B.$$.fragment,l),y(tl.$$.fragment,l),y(al.$$.fragment,l),y(Jl.$$.fragment,l),y(wl.$$.fragment,l),y(pl.$$.fragment,l),y(cl.$$.fragment,l),y(ml.$$.fragment,l),y(dl.$$.fragment,l),y(Cl.$$.fragment,l),y(Al.$$.fragment,l),y(Gl.$$.fragment,l),ve=!1},d(l){l&&(s(h),s(I),s(d),s(u),s(A),s(C),s(g),s(Xl),s(Vl),s(N),s(_l),s(kl),s(Rl),s(X),s(vl),s(V),s(El),s(_),s(Ql),s(Fl),s(k),s(Hl),s(R),s(zl),s(Sl),s(E),s(Yl),s($l),s(F),s(Ll),s(ql),s(z),s(Ol),s(Dl),s(Y),s(Pl),s(Kl),s(L),s(le),s(q),s(ee),s(se),s(D),s(te),s(P),s(ne),s(ae),s(ll),s(Me),s(oe),s(sl),s(Te),s(Je),s(ie),s(nl),s(we),s(pe),s(Ml),s(ye),s(ol),s(je),s(Tl),s(re),s(ce),s(il),s(Ie),s(me),s(de),s(yl),s(Ue),s(jl),s(ue),s(rl),s(he),s(be),s(Il),s(Ce),s(fe),s(Ae),s(Ul),s(Ze),s(ul),s(Be),s(hl),s(ge),s(bl),s(Ge),s(Ne),s(fl),s(xe),s(We),s(Zl),s(Xe),s(Bl),s(Ve),s(gl),s(_e),s(ke),s(Nl),s(Re),s(Wl)),s(c),j(U,l),j(b,l),j(r,l),j(G,l),j(x,l),j(W,l),j(Z,l),j(v,l),j(Q,l),j(H,l),j(S,l),j($,l),j(O,l),j(K,l),j(el,l),j(B,l),j(tl,l),j(al,l),j(Jl,l),j(wl,l),j(pl,l),j(cl,l),j(ml,l),j(dl,l),j(Cl,l),j(Al,l),j(Gl,l)}}}const ks='{"title":"Export a model to ONNX with optimum.exporters.onnx","local":"export-a-model-to-onnx-with-optimumexportersonnx","sections":[{"title":"Summary","local":"summary","sections":[],"depth":2},{"title":"Why use ONNX?","local":"why-use-onnx","sections":[],"depth":2},{"title":"Exporting a model to ONNX using the CLI","local":"exporting-a-model-to-onnx-using-the-cli","sections":[{"title":"Exporting a model to be used with Optimum’s ORTModel","local":"exporting-a-model-to-be-used-with-optimums-ortmodel","sections":[],"depth":3},{"title":"Exporting a model using past keys/values in the decoder","local":"exporting-a-model-using-past-keysvalues-in-the-decoder","sections":[],"depth":3}],"depth":2},{"title":"Selecting a task","local":"selecting-a-task","sections":[],"depth":2},{"title":"Custom export of Transformers models","local":"custom-export-of-transformers-models","sections":[{"title":"Customize the export of official Transformers models","local":"customize-the-export-of-official-transformers-models","sections":[],"depth":3},{"title":"Customize the export of Transformers models with custom modeling","local":"customize-the-export-of-transformers-models-with-custom-modeling","sections":[],"depth":3}],"depth":2}],"depth":1}';function Rs(xl){return Bs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zs extends gs{constructor(c){super(),Gs(this,c,Rs,_s,Zs,{})}}export{zs as component};
