import{S as Ke,i as Qe,s as Ye,e as n,k as m,w as _,t as l,M as Ze,c as i,d as o,m as s,a as r,x as z,h as c,b as p,G as e,g as q,y as v,L as et,q as x,o as b,B as O,v as tt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as M}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as je}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function ot(Ue){let h,Z,u,$,H,N,le,F,ce,ee,f,y,G,E,he,B,ue,te,a,k,fe,J,ge,_e,V,D,ze,T,C,ve,W,xe,be,P,U,Oe,j,$e,ye,R,X,Te,K,Pe,Re,w,A,we,I,Le,Q,Ne,Ee,ke,L,S,De,Y,Ce,oe;return N=new je({}),E=new je({}),k=new M({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_412/optimum/onnxruntime/optimization.py#L39"}}),D=new M({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_412/optimum/onnxruntime/optimization.py#L56"}}),C=new M({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_412/optimum/onnxruntime/optimization.py#L157",returnDescription:`
<p>The dictionary mapping the name of the fused operators to their number of apparition in the model.</p>
`}}),U=new M({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_412/optimum/onnxruntime/optimization.py#L176",returnDescription:`
<p>The difference in the number of nodes between the original and the optimized model.</p>
`}}),X=new M({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_412/optimum/onnxruntime/optimization.py#L205",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 M({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_412/optimum/onnxruntime/optimization.py#L94"}}),S=new M({props:{name:"parse_fusion_options",anchor:"optimum.onnxruntime.ORTOptimizer.parse_fusion_options",parameters:[{name:"optimization_config",val:": OptimizationConfig"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTOptimizer.parse_fusion_options.optimization_config",description:"<strong>optimization_config</strong> (<code>OptimizationConfig</code>) &#x2014; optimization configuration.",name:"optimization_config"}],source:"https://github.com/huggingface/optimum/blob/vr_412/optimum/onnxruntime/optimization.py#L240",returnDescription:`
<p>fusion options in the ONNX Runtime format.</p>
`,returnType:`
<p>FusionOptions</p>
`}}),{c(){h=n("meta"),Z=m(),u=n("h1"),$=n("a"),H=n("span"),_(N.$$.fragment),le=m(),F=n("span"),ce=l("Optimization"),ee=m(),f=n("h2"),y=n("a"),G=n("span"),_(E.$$.fragment),he=m(),B=n("span"),ue=l("ORTOptimizer"),te=m(),a=n("div"),_(k.$$.fragment),fe=m(),J=n("p"),ge=l("Handles the ONNX Runtime optimization process for models shared on huggingface.co/models."),_e=m(),V=n("div"),_(D.$$.fragment),ze=m(),T=n("div"),_(C.$$.fragment),ve=m(),W=n("p"),xe=l("Compute the dictionary mapping the name of the fused operators to their number of apparition in the model."),be=m(),P=n("div"),_(U.$$.fragment),Oe=m(),j=n("p"),$e=l("Compute the difference in the number of nodes between the original and the optimized model."),ye=m(),R=n("div"),_(X.$$.fragment),Te=m(),K=n("p"),Pe=l(`Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between
the original and the optimized model.`),Re=m(),w=n("div"),_(A.$$.fragment),we=m(),I=n("p"),Le=l("Optimize a model given the optimization specifications defined in "),Q=n("code"),Ne=l("optimization_config"),Ee=l("."),ke=m(),L=n("div"),_(S.$$.fragment),De=m(),Y=n("p"),Ce=l(`Parses fusion options in the optimization configuration.
This is needed because we do not use the same option names as
ONNX Runtime because they can be misleading.`),this.h()},l(t){const g=Ze('[data-svelte="svelte-1phssyn"]',document.head);h=i(g,"META",{name:!0,content:!0}),g.forEach(o),Z=s(t),u=i(t,"H1",{class:!0});var ne=r(u);$=i(ne,"A",{id:!0,class:!0,href:!0});var Xe=r($);H=i(Xe,"SPAN",{});var Ae=r(H);z(N.$$.fragment,Ae),Ae.forEach(o),Xe.forEach(o),le=s(ne),F=i(ne,"SPAN",{});var Ie=r(F);ce=c(Ie,"Optimization"),Ie.forEach(o),ne.forEach(o),ee=s(t),f=i(t,"H2",{class:!0});var ie=r(f);y=i(ie,"A",{id:!0,class:!0,href:!0});var Se=r(y);G=i(Se,"SPAN",{});var Me=r(G);z(E.$$.fragment,Me),Me.forEach(o),Se.forEach(o),he=s(ie),B=i(ie,"SPAN",{});var Ve=r(B);ue=c(Ve,"ORTOptimizer"),Ve.forEach(o),ie.forEach(o),te=s(t),a=i(t,"DIV",{class:!0});var d=r(a);z(k.$$.fragment,d),fe=s(d),J=i(d,"P",{});var qe=r(J);ge=c(qe,"Handles the ONNX Runtime optimization process for models shared on huggingface.co/models."),qe.forEach(o),_e=s(d),V=i(d,"DIV",{class:!0});var He=r(V);z(D.$$.fragment,He),He.forEach(o),ze=s(d),T=i(d,"DIV",{class:!0});var re=r(T);z(C.$$.fragment,re),ve=s(re),W=i(re,"P",{});var Fe=r(W);xe=c(Fe,"Compute the dictionary mapping the name of the fused operators to their number of apparition in the model."),Fe.forEach(o),re.forEach(o),be=s(d),P=i(d,"DIV",{class:!0});var ae=r(P);z(U.$$.fragment,ae),Oe=s(ae),j=i(ae,"P",{});var Ge=r(j);$e=c(Ge,"Compute the difference in the number of nodes between the original and the optimized model."),Ge.forEach(o),ae.forEach(o),ye=s(d),R=i(d,"DIV",{class:!0});var me=r(R);z(X.$$.fragment,me),Te=s(me),K=i(me,"P",{});var Be=r(K);Pe=c(Be,`Compute the dictionary mapping the operators name to the difference in the number of corresponding nodes between
the original and the optimized model.`),Be.forEach(o),me.forEach(o),Re=s(d),w=i(d,"DIV",{class:!0});var se=r(w);z(A.$$.fragment,se),we=s(se),I=i(se,"P",{});var pe=r(I);Le=c(pe,"Optimize a model given the optimization specifications defined in "),Q=i(pe,"CODE",{});var Je=r(Q);Ne=c(Je,"optimization_config"),Je.forEach(o),Ee=c(pe,"."),pe.forEach(o),se.forEach(o),ke=s(d),L=i(d,"DIV",{class:!0});var de=r(L);z(S.$$.fragment,de),De=s(de),Y=i(de,"P",{});var We=r(Y);Ce=c(We,`Parses fusion options in the optimization configuration.
This is needed because we do not use the same option names as
ONNX Runtime because they can be misleading.`),We.forEach(o),de.forEach(o),d.forEach(o),this.h()},h(){p(h,"name","hf:doc:metadata"),p(h,"content",JSON.stringify(nt)),p($,"id","optimization"),p($,"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"),p($,"href","#optimization"),p(u,"class","relative group"),p(y,"id","optimum.onnxruntime.ORTOptimizer"),p(y,"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"),p(y,"href","#optimum.onnxruntime.ORTOptimizer"),p(f,"class","relative group"),p(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(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,g){e(document.head,h),q(t,Z,g),q(t,u,g),e(u,$),e($,H),v(N,H,null),e(u,le),e(u,F),e(F,ce),q(t,ee,g),q(t,f,g),e(f,y),e(y,G),v(E,G,null),e(f,he),e(f,B),e(B,ue),q(t,te,g),q(t,a,g),v(k,a,null),e(a,fe),e(a,J),e(J,ge),e(a,_e),e(a,V),v(D,V,null),e(a,ze),e(a,T),v(C,T,null),e(T,ve),e(T,W),e(W,xe),e(a,be),e(a,P),v(U,P,null),e(P,Oe),e(P,j),e(j,$e),e(a,ye),e(a,R),v(X,R,null),e(R,Te),e(R,K),e(K,Pe),e(a,Re),e(a,w),v(A,w,null),e(w,we),e(w,I),e(I,Le),e(I,Q),e(Q,Ne),e(I,Ee),e(a,ke),e(a,L),v(S,L,null),e(L,De),e(L,Y),e(Y,Ce),oe=!0},p:et,i(t){oe||(x(N.$$.fragment,t),x(E.$$.fragment,t),x(k.$$.fragment,t),x(D.$$.fragment,t),x(C.$$.fragment,t),x(U.$$.fragment,t),x(X.$$.fragment,t),x(A.$$.fragment,t),x(S.$$.fragment,t),oe=!0)},o(t){b(N.$$.fragment,t),b(E.$$.fragment,t),b(k.$$.fragment,t),b(D.$$.fragment,t),b(C.$$.fragment,t),b(U.$$.fragment,t),b(X.$$.fragment,t),b(A.$$.fragment,t),b(S.$$.fragment,t),oe=!1},d(t){o(h),t&&o(Z),t&&o(u),O(N),t&&o(ee),t&&o(f),O(E),t&&o(te),t&&o(a),O(k),O(D),O(C),O(U),O(X),O(A),O(S)}}}const nt={local:"optimization",sections:[{local:"optimum.onnxruntime.ORTOptimizer",title:"ORTOptimizer"}],title:"Optimization"};function it(Ue){return tt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class st extends Ke{constructor(h){super();Qe(this,h,it,ot,Ye,{})}}export{st as default,nt as metadata};
