import{s as ve,n as Oe,o as be}from"../chunks/scheduler.5f3e6389.js";import{S as Te,i as Pe,e as m,s as i,c as l,h as Le,a as p,d as o,b as r,f as b,g as c,j as V,k as T,l as t,m as f,n as u,t as h,o as _,p as g}from"../chunks/index.373ab25c.js";import{C as Re,H as $e}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.972976e0.js";import{D as X}from"../chunks/Docstring.3603b29b.js";function ye(fe){let d,A,j,F,P,W,L,B,R,G,n,y,ne,M,ue="Handles the ONNX Runtime optimization process for models shared on huggingface.co/models.",oe,x,C,ie,E,he="Initializes the <code>ORTOptimizer</code> from a local directory or an <code>ORTModel</code>.",re,z,w,ae,I,_e="Computes the dictionary mapping the name of the fused operators to their number of apparition in the model.",me,$,k,pe,U,ge="Compute the difference in the number of nodes between the original and the optimized model.",se,v,D,de,H,xe=`Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between
the original and the optimized model.`,le,O,N,ce,q,ze="Optimizes a model given the optimization specifications defined in <code>optimization_config</code>.",J,S,K;return P=new Re({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),L=new $e({props:{title:"Optimization",local:"optimization",headingTag:"h1"}}),R=new $e({props:{title:"ORTOptimizer",local:"optimum.onnxruntime.ORTOptimizer",headingTag:"h2"}}),y=new X({props:{name:"class optimum.onnxruntime.ORTOptimizer",anchor:"optimum.onnxruntime.ORTOptimizer",parameters:[{name:"onnx_model_path",val:": list[os.PathLike]"},{name:"config",val:": PretrainedConfig"},{name:"from_ortmodel",val:": bool = False"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L49"}}),C=new X({props:{name:"from_pretrained",anchor:"optimum.onnxruntime.ORTOptimizer.from_pretrained",parameters:[{name:"model_or_path",val:": str | os.PathLike | ORTModel"},{name:"file_names",val:": list[str] | None = None"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.from_pretrained.model_or_path",description:`<strong>model_or_path</strong> (<code>Union[str, os.PathLike, ORTModel]</code>) &#x2014;
The path to a local directory hosting the model to optimize or an instance of an <code>ORTModel</code> to quantize.
Can be either:<ul>
<li>A path to a local <em>directory</em> containing the model to optimize.</li>
<li>An instance of <a href="/docs/optimum/pr_68/en/onnxruntime/package_reference/modeling_ort#optimum.onnxruntime.ORTModel">ORTModel</a>.</li>
</ul>`,name:"model_or_path"},{anchor:"optimum.onnxruntime.ORTOptimizer.from_pretrained.file_names(Optional[List[str]],",description:`<strong>file_names(<code>Optional[List[str]]</code>,</strong> defaults to <code>None</code>) &#x2014;
The list of file names of the models to optimize.`,name:"file_names(Optional[List[str]],"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L80"}}),w=new X({props:{name:"get_fused_operators",anchor:"optimum.onnxruntime.ORTOptimizer.get_fused_operators",parameters:[{name:"onnx_model_path",val:": str | os.PathLike"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.get_fused_operators.onnx_model_path",description:`<strong>onnx_model_path</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
Path of the ONNX model.`,name:"onnx_model_path"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L247",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The dictionary mapping the name of the fused operators to their number of apparition in the model.</p>
`}}),k=new X({props:{name:"get_nodes_number_difference",anchor:"optimum.onnxruntime.ORTOptimizer.get_nodes_number_difference",parameters:[{name:"onnx_model_path",val:": str | os.PathLike"},{name:"onnx_optimized_model_path",val:": str | os.PathLike"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.get_nodes_number_difference.onnx_model_path",description:`<strong>onnx_model_path</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
Path of the ONNX model.`,name:"onnx_model_path"},{anchor:"optimum.onnxruntime.ORTOptimizer.get_nodes_number_difference.onnx_optimized_model_path",description:`<strong>onnx_optimized_model_path</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
Path of the optimized ONNX model.`,name:"onnx_optimized_model_path"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L265",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The difference in the number of nodes between the original and the optimized model.</p>
`}}),D=new X({props:{name:"get_operators_difference",anchor:"optimum.onnxruntime.ORTOptimizer.get_operators_difference",parameters:[{name:"onnx_model_path",val:": str | os.PathLike"},{name:"onnx_optimized_model_path",val:": str | os.PathLike"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.get_operators_difference.onnx_model_path",description:`<strong>onnx_model_path</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
Path of the ONNX model.`,name:"onnx_model_path"},{anchor:"optimum.onnxruntime.ORTOptimizer.get_operators_difference.onnx_optimized_model_path",description:`<strong>onnx_optimized_model_path</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
Path of the optimized ONNX model.`,name:"onnx_optimized_model_path"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L293",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The dictionary mapping the operators name to the difference in the number of corresponding nodes between the
original and the optimized model.</p>
`}}),N=new X({props:{name:"optimize",anchor:"optimum.onnxruntime.ORTOptimizer.optimize",parameters:[{name:"optimization_config",val:": OptimizationConfig"},{name:"save_dir",val:": str | os.PathLike"},{name:"file_suffix",val:": str | None = 'optimized'"},{name:"one_external_file",val:": bool = True"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.optimize.optimization_config",description:`<strong>optimization_config</strong> (<a href="/docs/optimum/pr_68/en/onnxruntime/package_reference/configuration#optimum.onnxruntime.OptimizationConfig">OptimizationConfig</a>) &#x2014;
The configuration containing the parameters related to optimization.`,name:"optimization_config"},{anchor:"optimum.onnxruntime.ORTOptimizer.optimize.save_dir",description:`<strong>save_dir</strong> (<code>Union[str, os.PathLike]</code>) &#x2014;
The path used to save the optimized model.`,name:"save_dir"},{anchor:"optimum.onnxruntime.ORTOptimizer.optimize.file_suffix",description:`<strong>file_suffix</strong> (<code>str</code>, defaults to <code>&quot;optimized&quot;</code>) &#x2014;
The file suffix used to save the optimized model.`,name:"file_suffix"},{anchor:"optimum.onnxruntime.ORTOptimizer.optimize.one_external_file",description:`<strong>one_external_file</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
When <code>use_external_data_format=True</code>, whether to save all tensors to one external file.
If False, save each tensor to a file named with the tensor name.`,name:"one_external_file"}],source:"https://github.com/huggingface/optimum-onnx/blob/vr_68/optimum/onnxruntime/optimization.py#L128"}}),{c(){d=m("meta"),A=i(),j=m("p"),F=i(),l(P.$$.fragment),W=i(),l(L.$$.fragment),B=i(),l(R.$$.fragment),G=i(),n=m("div"),l(y.$$.fragment),ne=i(),M=m("p"),M.textContent=ue,oe=i(),x=m("div"),l(C.$$.fragment),ie=i(),E=m("p"),E.innerHTML=he,re=i(),z=m("div"),l(w.$$.fragment),ae=i(),I=m("p"),I.textContent=_e,me=i(),$=m("div"),l(k.$$.fragment),pe=i(),U=m("p"),U.textContent=ge,se=i(),v=m("div"),l(D.$$.fragment),de=i(),H=m("p"),H.textContent=xe,le=i(),O=m("div"),l(N.$$.fragment),ce=i(),q=m("p"),q.innerHTML=ze,J=i(),S=m("p"),this.h()},l(e){const a=Le("svelte-u9bgzb",document.head);d=p(a,"META",{name:!0,content:!0}),a.forEach(o),A=r(e),j=p(e,"P",{}),b(j).forEach(o),F=r(e),c(P.$$.fragment,e),W=r(e),c(L.$$.fragment,e),B=r(e),c(R.$$.fragment,e),G=r(e),n=p(e,"DIV",{class:!0});var s=b(n);c(y.$$.fragment,s),ne=r(s),M=p(s,"P",{"data-svelte-h":!0}),V(M)!=="svelte-grwr9f"&&(M.textContent=ue),oe=r(s),x=p(s,"DIV",{class:!0});var Q=b(x);c(C.$$.fragment,Q),ie=r(Q),E=p(Q,"P",{"data-svelte-h":!0}),V(E)!=="svelte-1gci8wb"&&(E.innerHTML=he),Q.forEach(o),re=r(s),z=p(s,"DIV",{class:!0});var Y=b(z);c(w.$$.fragment,Y),ae=r(Y),I=p(Y,"P",{"data-svelte-h":!0}),V(I)!=="svelte-yjxy0i"&&(I.textContent=_e),Y.forEach(o),me=r(s),$=p(s,"DIV",{class:!0});var Z=b($);c(k.$$.fragment,Z),pe=r(Z),U=p(Z,"P",{"data-svelte-h":!0}),V(U)!=="svelte-nuojg2"&&(U.textContent=ge),Z.forEach(o),se=r(s),v=p(s,"DIV",{class:!0});var ee=b(v);c(D.$$.fragment,ee),de=r(ee),H=p(ee,"P",{"data-svelte-h":!0}),V(H)!=="svelte-1qznsek"&&(H.textContent=xe),ee.forEach(o),le=r(s),O=p(s,"DIV",{class:!0});var te=b(O);c(N.$$.fragment,te),ce=r(te),q=p(te,"P",{"data-svelte-h":!0}),V(q)!=="svelte-akjqps"&&(q.innerHTML=ze),te.forEach(o),s.forEach(o),J=r(e),S=p(e,"P",{}),b(S).forEach(o),this.h()},h(){T(d,"name","hf:doc:metadata"),T(d,"content",Ce),T(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(n,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,a){t(document.head,d),f(e,A,a),f(e,j,a),f(e,F,a),u(P,e,a),f(e,W,a),u(L,e,a),f(e,B,a),u(R,e,a),f(e,G,a),f(e,n,a),u(y,n,null),t(n,ne),t(n,M),t(n,oe),t(n,x),u(C,x,null),t(x,ie),t(x,E),t(n,re),t(n,z),u(w,z,null),t(z,ae),t(z,I),t(n,me),t(n,$),u(k,$,null),t($,pe),t($,U),t(n,se),t(n,v),u(D,v,null),t(v,de),t(v,H),t(n,le),t(n,O),u(N,O,null),t(O,ce),t(O,q),f(e,J,a),f(e,S,a),K=!0},p:Oe,i(e){K||(h(P.$$.fragment,e),h(L.$$.fragment,e),h(R.$$.fragment,e),h(y.$$.fragment,e),h(C.$$.fragment,e),h(w.$$.fragment,e),h(k.$$.fragment,e),h(D.$$.fragment,e),h(N.$$.fragment,e),K=!0)},o(e){_(P.$$.fragment,e),_(L.$$.fragment,e),_(R.$$.fragment,e),_(y.$$.fragment,e),_(C.$$.fragment,e),_(w.$$.fragment,e),_(k.$$.fragment,e),_(D.$$.fragment,e),_(N.$$.fragment,e),K=!1},d(e){e&&(o(A),o(j),o(F),o(W),o(B),o(G),o(n),o(J),o(S)),o(d),g(P,e),g(L,e),g(R,e),g(y),g(C),g(w),g(k),g(D),g(N)}}}const Ce='{"title":"Optimization","local":"optimization","sections":[{"title":"ORTOptimizer","local":"optimum.onnxruntime.ORTOptimizer","sections":[],"depth":2}],"depth":1}';function we(fe){return be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends Te{constructor(d){super(),Pe(this,d,we,ye,ve,{})}}export{Ee as component};
