import{s as Oe,n as be,o as ve}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 s,d as o,b as r,f as v,g as c,j as V,k as T,l as t,m as f,n as u,t as h,o as g,p as _}from"../chunks/index.373ab25c.js";import{C as Re,H as $e}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.775b85bf.js";import{D as X}from"../chunks/Docstring.814857d8.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,ge="Computes the dictionary mapping the name of the fused operators to their number of apparition in the model.",me,$,k,se,U,_e="Compute the difference in the number of nodes between the original and the optimized model.",pe,O,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,b,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/main/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/main/en/onnxruntime/package_reference/modeling#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/main/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/main/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/main/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/main/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/main/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/main/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=ge,me=i(),$=m("div"),l(k.$$.fragment),se=i(),U=m("p"),U.textContent=_e,pe=i(),O=m("div"),l(D.$$.fragment),de=i(),H=m("p"),H.textContent=xe,le=i(),b=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=s(a,"META",{name:!0,content:!0}),a.forEach(o),A=r(e),j=s(e,"P",{}),v(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=s(e,"DIV",{class:!0});var p=v(n);c(y.$$.fragment,p),ne=r(p),M=s(p,"P",{"data-svelte-h":!0}),V(M)!=="svelte-grwr9f"&&(M.textContent=ue),oe=r(p),x=s(p,"DIV",{class:!0});var Q=v(x);c(C.$$.fragment,Q),ie=r(Q),E=s(Q,"P",{"data-svelte-h":!0}),V(E)!=="svelte-1gci8wb"&&(E.innerHTML=he),Q.forEach(o),re=r(p),z=s(p,"DIV",{class:!0});var Y=v(z);c(w.$$.fragment,Y),ae=r(Y),I=s(Y,"P",{"data-svelte-h":!0}),V(I)!=="svelte-yjxy0i"&&(I.textContent=ge),Y.forEach(o),me=r(p),$=s(p,"DIV",{class:!0});var Z=v($);c(k.$$.fragment,Z),se=r(Z),U=s(Z,"P",{"data-svelte-h":!0}),V(U)!=="svelte-nuojg2"&&(U.textContent=_e),Z.forEach(o),pe=r(p),O=s(p,"DIV",{class:!0});var ee=v(O);c(D.$$.fragment,ee),de=r(ee),H=s(ee,"P",{"data-svelte-h":!0}),V(H)!=="svelte-1qznsek"&&(H.textContent=xe),ee.forEach(o),le=r(p),b=s(p,"DIV",{class:!0});var te=v(b);c(N.$$.fragment,te),ce=r(te),q=s(te,"P",{"data-svelte-h":!0}),V(q)!=="svelte-akjqps"&&(q.innerHTML=ze),te.forEach(o),p.forEach(o),J=r(e),S=s(e,"P",{}),v(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(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(b,"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($,se),t($,U),t(n,pe),t(n,O),u(D,O,null),t(O,de),t(O,H),t(n,le),t(n,b),u(N,b,null),t(b,ce),t(b,q),f(e,J,a),f(e,S,a),K=!0},p:be,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){g(P.$$.fragment,e),g(L.$$.fragment,e),g(R.$$.fragment,e),g(y.$$.fragment,e),g(C.$$.fragment,e),g(w.$$.fragment,e),g(k.$$.fragment,e),g(D.$$.fragment,e),g(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),_(P,e),_(L,e),_(R,e),_(y),_(C),_(w),_(k),_(D),_(N)}}}const Ce='{"title":"Optimization","local":"optimization","sections":[{"title":"ORTOptimizer","local":"optimum.onnxruntime.ORTOptimizer","sections":[],"depth":2}],"depth":1}';function we(fe){return ve(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends Te{constructor(d){super(),Pe(this,d,we,ye,Oe,{})}}export{Ee as component};
