import{S as Ve,i as He,s as Fe,e as n,k as p,w as $,t as u,M as Ge,c as i,d as o,m as s,a as r,x as y,h as _,b as m,G as e,g as M,y as T,L as Be,q as P,o as R,B as w,v as Je}from"../../../chunks/vendor-hf-doc-builder.js";import{D as X}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as qe}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function We(we){let l,K,h,g,q,L,me,V,pe,Q,c,v,H,k,se,F,de,Y,a,E,le,G,he,ce,S,N,fe,x,D,ue,B,_e,ge,z,U,ve,J,xe,ze,O,C,Oe,W,be,$e,b,A,ye,I,Te,j,Pe,Re,Z;return L=new qe({}),k=new qe({}),E=new X({props:{name:"class optimum.onnxruntime.ORTOptimizer",anchor:"optimum.onnxruntime.ORTOptimizer",parameters:[{name:"onnx_model_path",val:": typing.List[os.PathLike]"},{name:"config",val:": PretrainedConfig"}],source:"https://github.com/huggingface/optimum/blob/vr_450/optimum/onnxruntime/optimization.py#L37"}}),N=new X({props:{name:"from_pretrained",anchor:"optimum.onnxruntime.ORTOptimizer.from_pretrained",parameters:[{name:"model_or_path",val:": typing.Union[str, os.PathLike, optimum.onnxruntime.modeling_ort.ORTModel]"},{name:"file_names",val:": typing.Optional[typing.List[str]] = 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 ORTModel.</li>
</ul>`,name:"model_or_path"},{anchor:"optimum.onnxruntime.ORTOptimizer.from_pretrained.file_names(List[str],",description:`<strong>file_names(<code>List[str]</code>,</strong> <em>optional</em>) &#x2014;
The list of file names of the models to optimize.`,name:"file_names(List[str],"}],source:"https://github.com/huggingface/optimum/blob/vr_450/optimum/onnxruntime/optimization.py#L54"}}),D=new X({props:{name:"get_fused_operators",anchor:"optimum.onnxruntime.ORTOptimizer.get_fused_operators",parameters:[{name:"onnx_model_path",val:": typing.Union[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/blob/vr_450/optimum/onnxruntime/optimization.py#L155",returnDescription:`
<p>The dictionary mapping the name of the fused operators to their number of apparition in the model.</p>
`}}),U=new X({props:{name:"get_nodes_number_difference",anchor:"optimum.onnxruntime.ORTOptimizer.get_nodes_number_difference",parameters:[{name:"onnx_model_path",val:": typing.Union[str, os.PathLike]"},{name:"onnx_optimized_model_path",val:": typing.Union[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/blob/vr_450/optimum/onnxruntime/optimization.py#L174",returnDescription:`
<p>The difference in the number of nodes between the original and the optimized model.</p>
`}}),C=new X({props:{name:"get_operators_difference",anchor:"optimum.onnxruntime.ORTOptimizer.get_operators_difference",parameters:[{name:"onnx_model_path",val:": typing.Union[str, os.PathLike]"},{name:"onnx_optimized_model_path",val:": typing.Union[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/blob/vr_450/optimum/onnxruntime/optimization.py#L203",returnDescription:`
<p>The dictionary mapping the operators name to the difference in the number of corresponding nodes between the
original and the optimized model.</p>
`}}),A=new X({props:{name:"optimize",anchor:"optimum.onnxruntime.ORTOptimizer.optimize",parameters:[{name:"optimization_config",val:": OptimizationConfig"},{name:"save_dir",val:": typing.Union[str, os.PathLike]"},{name:"file_suffix",val:": typing.Optional[str] = 'optimized'"},{name:"use_external_data_format",val:": bool = False"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.optimize.optimization_config",description:`<strong>optimization_config</strong> (<code>OptimizationConfig</code>) &#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>, <em>optional</em>, 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.use_external_data_format",description:`<strong>use_external_data_format</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use external data format to store model of size &gt;= 2Gb.`,name:"use_external_data_format"}],source:"https://github.com/huggingface/optimum/blob/vr_450/optimum/onnxruntime/optimization.py#L92"}}),{c(){l=n("meta"),K=p(),h=n("h1"),g=n("a"),q=n("span"),$(L.$$.fragment),me=p(),V=n("span"),pe=u("Optimization"),Q=p(),c=n("h2"),v=n("a"),H=n("span"),$(k.$$.fragment),se=p(),F=n("span"),de=u("ORTOptimizer"),Y=p(),a=n("div"),$(E.$$.fragment),le=p(),G=n("p"),he=u("Handles the ONNX Runtime optimization process for models shared on huggingface.co/models."),ce=p(),S=n("div"),$(N.$$.fragment),fe=p(),x=n("div"),$(D.$$.fragment),ue=p(),B=n("p"),_e=u("Compute the dictionary mapping the name of the fused operators to their number of apparition in the model."),ge=p(),z=n("div"),$(U.$$.fragment),ve=p(),J=n("p"),xe=u("Compute the difference in the number of nodes between the original and the optimized model."),ze=p(),O=n("div"),$(C.$$.fragment),Oe=p(),W=n("p"),be=u(`Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between
the original and the optimized model.`),$e=p(),b=n("div"),$(A.$$.fragment),ye=p(),I=n("p"),Te=u("Optimize a model given the optimization specifications defined in "),j=n("code"),Pe=u("optimization_config"),Re=u("."),this.h()},l(t){const f=Ge('[data-svelte="svelte-1phssyn"]',document.head);l=i(f,"META",{name:!0,content:!0}),f.forEach(o),K=s(t),h=i(t,"H1",{class:!0});var ee=r(h);g=i(ee,"A",{id:!0,class:!0,href:!0});var Le=r(g);q=i(Le,"SPAN",{});var ke=r(q);y(L.$$.fragment,ke),ke.forEach(o),Le.forEach(o),me=s(ee),V=i(ee,"SPAN",{});var Ee=r(V);pe=_(Ee,"Optimization"),Ee.forEach(o),ee.forEach(o),Q=s(t),c=i(t,"H2",{class:!0});var te=r(c);v=i(te,"A",{id:!0,class:!0,href:!0});var Ne=r(v);H=i(Ne,"SPAN",{});var De=r(H);y(k.$$.fragment,De),De.forEach(o),Ne.forEach(o),se=s(te),F=i(te,"SPAN",{});var Ue=r(F);de=_(Ue,"ORTOptimizer"),Ue.forEach(o),te.forEach(o),Y=s(t),a=i(t,"DIV",{class:!0});var d=r(a);y(E.$$.fragment,d),le=s(d),G=i(d,"P",{});var Ce=r(G);he=_(Ce,"Handles the ONNX Runtime optimization process for models shared on huggingface.co/models."),Ce.forEach(o),ce=s(d),S=i(d,"DIV",{class:!0});var Ae=r(S);y(N.$$.fragment,Ae),Ae.forEach(o),fe=s(d),x=i(d,"DIV",{class:!0});var oe=r(x);y(D.$$.fragment,oe),ue=s(oe),B=i(oe,"P",{});var Ie=r(B);_e=_(Ie,"Compute the dictionary mapping the name of the fused operators to their number of apparition in the model."),Ie.forEach(o),oe.forEach(o),ge=s(d),z=i(d,"DIV",{class:!0});var ne=r(z);y(U.$$.fragment,ne),ve=s(ne),J=i(ne,"P",{});var Se=r(J);xe=_(Se,"Compute the difference in the number of nodes between the original and the optimized model."),Se.forEach(o),ne.forEach(o),ze=s(d),O=i(d,"DIV",{class:!0});var ie=r(O);y(C.$$.fragment,ie),Oe=s(ie),W=i(ie,"P",{});var Me=r(W);be=_(Me,`Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between
the original and the optimized model.`),Me.forEach(o),ie.forEach(o),$e=s(d),b=i(d,"DIV",{class:!0});var re=r(b);y(A.$$.fragment,re),ye=s(re),I=i(re,"P",{});var ae=r(I);Te=_(ae,"Optimize a model given the optimization specifications defined in "),j=i(ae,"CODE",{});var Xe=r(j);Pe=_(Xe,"optimization_config"),Xe.forEach(o),Re=_(ae,"."),ae.forEach(o),re.forEach(o),d.forEach(o),this.h()},h(){m(l,"name","hf:doc:metadata"),m(l,"content",JSON.stringify(je)),m(g,"id","optimization"),m(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(g,"href","#optimization"),m(h,"class","relative group"),m(v,"id","optimum.onnxruntime.ORTOptimizer"),m(v,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(v,"href","#optimum.onnxruntime.ORTOptimizer"),m(c,"class","relative group"),m(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,l),M(t,K,f),M(t,h,f),e(h,g),e(g,q),T(L,q,null),e(h,me),e(h,V),e(V,pe),M(t,Q,f),M(t,c,f),e(c,v),e(v,H),T(k,H,null),e(c,se),e(c,F),e(F,de),M(t,Y,f),M(t,a,f),T(E,a,null),e(a,le),e(a,G),e(G,he),e(a,ce),e(a,S),T(N,S,null),e(a,fe),e(a,x),T(D,x,null),e(x,ue),e(x,B),e(B,_e),e(a,ge),e(a,z),T(U,z,null),e(z,ve),e(z,J),e(J,xe),e(a,ze),e(a,O),T(C,O,null),e(O,Oe),e(O,W),e(W,be),e(a,$e),e(a,b),T(A,b,null),e(b,ye),e(b,I),e(I,Te),e(I,j),e(j,Pe),e(I,Re),Z=!0},p:Be,i(t){Z||(P(L.$$.fragment,t),P(k.$$.fragment,t),P(E.$$.fragment,t),P(N.$$.fragment,t),P(D.$$.fragment,t),P(U.$$.fragment,t),P(C.$$.fragment,t),P(A.$$.fragment,t),Z=!0)},o(t){R(L.$$.fragment,t),R(k.$$.fragment,t),R(E.$$.fragment,t),R(N.$$.fragment,t),R(D.$$.fragment,t),R(U.$$.fragment,t),R(C.$$.fragment,t),R(A.$$.fragment,t),Z=!1},d(t){o(l),t&&o(K),t&&o(h),w(L),t&&o(Q),t&&o(c),w(k),t&&o(Y),t&&o(a),w(E),w(N),w(D),w(U),w(C),w(A)}}}const je={local:"optimization",sections:[{local:"optimum.onnxruntime.ORTOptimizer",title:"ORTOptimizer"}],title:"Optimization"};function Ke(we){return Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class et extends Ve{constructor(l){super();He(this,l,Ke,We,Fe,{})}}export{et as default,je as metadata};
