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GFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTJCJTIwdG9tZXNkLmFwcGx5X3BhdGNoKHBpcGVsaW5lJTJDJTIwcmF0aW8lM0QwLjUpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMjJhJTIwcGhvdG8lMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwb24lMjBtYXJzJTIyKS5pbWFnZXMlNUIwJTVE",highlighted:`from diffusers import StableDiffusionPipeline
import tomesd

pipeline = StableDiffusionPipeline.from_pretrained(
      &quot;runwayml/stable-diffusion-v1-5&quot;, torch_dtype=torch.float16
).to(&quot;cuda&quot;)
<span class="hljs-addition">+ tomesd.apply_patch(pipeline, ratio=0.5)</span>

image = pipeline(&quot;a photo of an astronaut riding a horse on mars&quot;).images[0]`}}),De=new el({}),Me=new Uu({props:{code:"LSUyMCU2MGRpZmZ1c2VycyU2MCUyMHZlcnNpb24lM0ElMjAwLjE1LjElMEEtJTIwUHl0aG9uJTIwdmVyc2lvbiUzQSUyMDMuOC4xNiUwQS0lMjBQeVRvcmNoJTIwdmVyc2lvbiUyMChHUFUlM0YpJTNBJTIwMS4xMy4xJTJCY3UxMTYlMjAoVHJ1ZSklMEEtJTIwSHVnZ2luZ2ZhY2VfaHViJTIwdmVyc2lvbiUzQSUyMDAuMTMuMiUwQS0lMjBUcmFuc2Zvcm1lcnMlMjB2ZXJzaW9uJTNBJTIwNC4yNy4yJTBBLSUyMEFjY2VsZXJhdGUlMjB2ZXJzaW9uJTNBJTIwMC4xOC4wJTBBLSUyMHhGb3JtZXJzJTIwdmVyc2lvbiUzQSUyMDAuMC4xNiUwQS0lMjB0b21lc2QlMjB2ZXJzaW9uJTNBJTIwMC4xLjI=",highlighted:`- \`diffusers\` version: 0.15.1
- Python version: 3.8.16
- PyTorch version (GPU?): 1.13.1+cu116 (True)
- Huggingface_hub version: 0.13.2
- Transformers version: 4.27.2
- Accelerate version: 0.18.0
- xFormers version: 0.0.16
- tomesd version: 0.1.2`}}),we=new el({}),Oe=new el({}),ke=new el({}),{c(){Zt=l("meta"),na=a(),Ht=l("h1"),Wt=l("a"),ll=l("span"),oe(ie.$$.fragment),gs=a(),rl=l("span"),Os=s("Token Merging"),ia=a(),jt=l("p"),ys=s("Token Merging (introduced in "),he=l("a"),ks=s("Token Merging: Your ViT But Faster"),Ps=s(") works by merging the redundant tokens / patches progressively in the forward pass of a Transformer-based network. It can speed up the inference latency of the underlying network."),ha=a(),z=l("p"),As=s("After Token Merging (ToMe) was released, the authors released "),ce=l("a"),Ss=s("Token Merging for Fast Stable Diffusion"),$s=s(", which introduced a version of ToMe which is more compatible with Stable Diffusion. We can use ToMe to gracefully speed up the inference latency of a "),Je=l("a"),Js=s("DiffusionPipeline"),xs=s(". This doc discusses how to apply ToMe to the "),xe=l("a"),Bs=s("StableDiffusionPipeline"),Rs=s(", the expected speedups, and the qualitative aspects of using ToMe on the "),Be=l("a"),Us=s("StableDiffusionPipeline"),Is=s("."),ca=a(),Nt=l("h2"),qt=l("a"),ol=l("span"),oe(pe.$$.fragment),Zs=a(),al=l("span"),Hs=s("Using ToMe"),pa=a(),$t=l("p"),Ns=s("The authors of ToMe released a convenient Python library called "),Te=l("a"),dl=l("code"),Vs=s("tomesd"),Gs=s(" that lets us apply ToMe to a "),Re=l("a"),Cs=s("DiffusionPipeline"),Fs=s(" like so:"),Ta=a(),oe(Ee.$$.fragment),Ea=a(),Ue=l("p"),Ws=s("And that\u2019s it!"),ua=a(),v=l("p"),sl=l("code"),js=s("tomesd.apply_patch()"),qs=s(" exposes "),ue=l("a"),Ls=s("a number of arguments"),Ys=s(" to let us strike a balance between the pipeline inference speed and the quality of the generated tokens. Amongst those arguments, the most important one is "),fl=l("code"),Xs=s("ratio"),zs=s(". "),nl=l("code"),Qs=s("ratio"),Ks=s(" controls the number of tokens that will be merged during the forward pass. For more details on "),il=l("code"),tf=s("tomesd"),ef=s(", please refer to the original repository "),ve=l("a"),lf=s("https://github.com/dbolya/tomesd"),rf=s(" and "),_e=l("a"),of=s("the paper"),af=s("."),va=a(),Vt=l("h2"),Lt=l("a"),hl=l("span"),oe(De.$$.fragment),df=a(),Yt=l("span"),sf=s("Benchmarking "),cl=l("code"),ff=s("tomesd"),nf=s(" with "),pl=l("code"),hf=s("StableDiffusionPipeline"),_a=a(),St=l("p"),cf=s("We benchmarked the impact of using "),Tl=l("code"),pf=s("tomesd"),Tf=s(" on "),Ie=l("a"),Ef=s("StableDiffusionPipeline"),uf=s(" along with "),me=l("a"),vf=s("xformers"),_f=s(" across different image resolutions. We used A100 and V100 as our test GPU devices with the following development environment (with Python 3.8.5):"),Da=a(),oe(Me.$$.fragment),ma=a(),Xt=l("p"),Df=s("We used this script for benchmarking: "),be=l("a"),mf=s("https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),Mf=s(". Following are our findings:"),Ma=a(),Gt=l("h3"),zt=l("a"),El=l("span"),oe(we.$$.fragment),bf=a(),ul=l("span"),wf=s("A100"),ba=a(),Qt=l("table"),vl=l("thead"),_=l("tr"),_l=l("th"),gf=s("Resolution"),Of=a(),Dl=l("th"),yf=s("Batch size"),kf=a(),ml=l("th"),Pf=s("Vanilla"),Af=a(),Ml=l("th"),Sf=s("ToMe"),$f=a(),bl=l("th"),Jf=s("ToMe + xFormers"),xf=a(),wl=l("th"),Bf=s("ToMe speedup (%)"),Rf=a(),gl=l("th"),Uf=s("ToMe + xFormers speedup (%)"),If=a(),E=l("tbody"),D=l("tr"),Ol=l("td"),Zf=s("512"),Hf=a(),yl=l("td"),Nf=s("10"),Vf=a(),kl=l("td"),Gf=s("6.88"),Cf=a(),Pl=l("td"),Ff=s("5.26"),Wf=a(),Al=l("td"),jf=s("4.69"),qf=a(),Sl=l("td"),Lf=s("23.54651163"),Yf=a(),$l=l("td"),Xf=s("31.83139535"),zf=a(),m=l("tr"),wa=l("td"),Qf=a(),ga=l("td"),Kf=a(),Oa=l("td"),tn=a(),ya=l("td"),en=a(),ka=l("td"),ln=a(),Pa=l("td"),rn=a(),Aa=l("td"),on=a(),M=l("tr"),Jl=l("td"),an=s("768"),dn=a(),xl=l("td"),sn=s("10"),fn=a(),Bl=l("td"),nn=s("OOM"),hn=a(),Rl=l("td"),cn=s("14.71"),pn=a(),Ul=l("td"),Tn=s("11"),En=a(),Sa=l("td"),un=a(),$a=l("td"),vn=a(),b=l("tr"),Ja=l("td"),_n=a(),Il=l("td"),Dn=s("8"),mn=a(),Zl=l("td"),Mn=s("OOM"),bn=a(),Hl=l("td"),wn=s("11.56"),gn=a(),Nl=l("td"),On=s("8.84"),yn=a(),xa=l("td"),kn=a(),Ba=l("td"),Pn=a(),w=l("tr"),Ra=l("td"),An=a(),Vl=l("td"),Sn=s("4"),$n=a(),Gl=l("td"),Jn=s("OOM"),xn=a(),Cl=l("td"),Bn=s("5.98"),Rn=a(),Fl=l("td"),Un=s("4.66"),In=a(),Ua=l("td"),Zn=a(),Ia=l("td"),Hn=a(),g=l("tr"),Za=l("td"),Nn=a(),Wl=l("td"),Vn=s("2"),Gn=a(),jl=l("td"),Cn=s("4.99"),Fn=a(),ql=l("td"),Wn=s("3.24"),jn=a(),Ll=l("td"),qn=s("3.1"),Ln=a(),Yl=l("td"),Yn=s("35.07014028"),Xn=a(),Xl=l("td"),zn=s("37.8757515"),Qn=a(),O=l("tr"),Ha=l("td"),Kn=a(),zl=l("td"),ti=s("1"),ei=a(),Ql=l("td"),li=s("3.29"),ri=a(),Kl=l("td"),oi=s("2.24"),ai=a(),tr=l("td"),di=s("2.03"),si=a(),er=l("td"),fi=s("31.91489362"),ni=a(),lr=l("td"),ii=s("38.29787234"),hi=a(),y=l("tr"),Na=l("td"),ci=a(),Va=l("td"),pi=a(),Ga=l("td"),Ti=a(),Ca=l("td"),Ei=a(),Fa=l("td"),ui=a(),Wa=l("td"),vi=a(),ja=l("td"),_i=a(),k=l("tr"),rr=l("td"),Di=s("1024"),mi=a(),or=l("td"),Mi=s("10"),bi=a(),ar=l("td"),wi=s("OOM"),gi=a(),dr=l("td"),Oi=s("OOM"),yi=a(),sr=l("td"),ki=s("OOM"),Pi=a(),qa=l("td"),Ai=a(),La=l("td"),Si=a(),P=l("tr"),Ya=l("td"),$i=a(),fr=l("td"),Ji=s("8"),xi=a(),nr=l("td"),Bi=s("OOM"),Ri=a(),ir=l("td"),Ui=s("OOM"),Ii=a(),hr=l("td"),Zi=s("OOM"),Hi=a(),Xa=l("td"),Ni=a(),za=l("td"),Vi=a(),A=l("tr"),Qa=l("td"),Gi=a(),cr=l("td"),Ci=s("4"),Fi=a(),pr=l("td"),Wi=s("OOM"),ji=a(),Tr=l("td"),qi=s("12.51"),Li=a(),Er=l("td"),Yi=s("9.09"),Xi=a(),Ka=l("td"),zi=a(),td=l("td"),Qi=a(),S=l("tr"),ed=l("td"),Ki=a(),ur=l("td"),t1=s("2"),e1=a(),vr=l("td"),l1=s("OOM"),r1=a(),_r=l("td"),o1=s("6.52"),a1=a(),Dr=l("td"),d1=s("4.96"),s1=a(),ld=l("td"),f1=a(),rd=l("td"),n1=a(),$=l("tr"),od=l("td"),i1=a(),mr=l("td"),h1=s("1"),c1=a(),Mr=l("td"),p1=s("6.4"),T1=a(),br=l("td"),E1=s("3.61"),u1=a(),wr=l("td"),v1=s("2.81"),_1=a(),gr=l("td"),D1=s("43.59375"),m1=a(),Or=l("td"),M1=s("56.09375"),ad=a(),Ze=l("p"),yr=l("strong"),ge=l("em"),b1=s("The timings reported here are in seconds. Speedups are calculated over the "),kr=l("code"),w1=s("Vanilla"),g1=s(" timings."),dd=a(),Ct=l("h3"),Kt=l("a"),Pr=l("span"),oe(Oe.$$.fragment),O1=a(),Ar=l("span"),y1=s("V100"),sd=a(),te=l("table"),Sr=l("thead"),J=l("tr"),$r=l("th"),k1=s("Resolution"),P1=a(),Jr=l("th"),A1=s("Batch size"),S1=a(),xr=l("th"),$1=s("Vanilla"),J1=a(),Br=l("th"),x1=s("ToMe"),B1=a(),Rr=l("th"),R1=s("ToMe + xFormers"),U1=a(),Ur=l("th"),I1=s("ToMe speedup (%)"),Z1=a(),Ir=l("th"),H1=s("ToMe + xFormers speedup (%)"),N1=a(),p=l("tbody"),x=l("tr"),Zr=l("td"),V1=s("512"),G1=a(),Hr=l("td"),C1=s("10"),F1=a(),Nr=l("td"),W1=s("OOM"),j1=a(),Vr=l("td"),q1=s("10.03"),L1=a(),Gr=l("td"),Y1=s("9.29"),X1=a(),fd=l("td"),z1=a(),nd=l("td"),Q1=a(),B=l("tr"),id=l("td"),K1=a(),Cr=l("td"),th=s("8"),eh=a(),Fr=l("td"),lh=s("OOM"),rh=a(),Wr=l("td"),oh=s("8.05"),ah=a(),jr=l("td"),dh=s("7.47"),sh=a(),hd=l("td"),fh=a(),cd=l("td"),nh=a(),R=l("tr"),pd=l("td"),ih=a(),qr=l("td"),hh=s("4"),ch=a(),Lr=l("td"),ph=s("5.7"),Th=a(),Yr=l("td"),Eh=s("4.3"),uh=a(),Xr=l("td"),vh=s("3.98"),_h=a(),zr=l("td"),Dh=s("24.56140351"),mh=a(),Qr=l("td"),Mh=s("30.1754386"),bh=a(),U=l("tr"),Td=l("td"),wh=a(),Kr=l("td"),gh=s("2"),Oh=a(),to=l("td"),yh=s("3.14"),kh=a(),eo=l("td"),Ph=s("2.43"),Ah=a(),lo=l("td"),Sh=s("2.27"),$h=a(),ro=l("td"),Jh=s("22.61146497"),xh=a(),oo=l("td"),Bh=s("27.70700637"),Rh=a(),I=l("tr"),Ed=l("td"),Uh=a(),ao=l("td"),Ih=s("1"),Zh=a(),so=l("td"),Hh=s("1.88"),Nh=a(),fo=l("td"),Vh=s("1.57"),Gh=a(),no=l("td"),Ch=s("1.57"),Fh=a(),io=l("td"),Wh=s("16.4893617"),jh=a(),ho=l("td"),qh=s("16.4893617"),Lh=a(),Z=l("tr"),ud=l("td"),Yh=a(),vd=l("td"),Xh=a(),_d=l("td"),zh=a(),Dd=l("td"),Qh=a(),md=l("td"),Kh=a(),Md=l("td"),tc=a(),bd=l("td"),ec=a(),H=l("tr"),co=l("td"),lc=s("768"),rc=a(),po=l("td"),oc=s("10"),ac=a(),To=l("td"),dc=s("OOM"),sc=a(),Eo=l("td"),fc=s("OOM"),nc=a(),uo=l("td"),ic=s("23.67"),hc=a(),wd=l("td"),cc=a(),gd=l("td"),pc=a(),N=l("tr"),Od=l("td"),Tc=a(),vo=l("td"),Ec=s("8"),uc=a(),_o=l("td"),vc=s("OOM"),_c=a(),Do=l("td"),Dc=s("OOM"),mc=a(),mo=l("td"),Mc=s("18.81"),bc=a(),yd=l("td"),wc=a(),kd=l("td"),gc=a(),V=l("tr"),Pd=l("td"),Oc=a(),Mo=l("td"),yc=s("4"),kc=a(),bo=l("td"),Pc=s("OOM"),Ac=a(),wo=l("td"),Sc=s("11.81"),$c=a(),go=l("td"),Jc=s("9.7"),xc=a(),Ad=l("td"),Bc=a(),Sd=l("td"),Rc=a(),G=l("tr"),$d=l("td"),Uc=a(),Oo=l("td"),Ic=s("2"),Zc=a(),yo=l("td"),Hc=s("OOM"),Nc=a(),ko=l("td"),Vc=s("6.27"),Gc=a(),Po=l("td"),Cc=s("5.2"),Fc=a(),Jd=l("td"),Wc=a(),xd=l("td"),jc=a(),C=l("tr"),Bd=l("td"),qc=a(),Ao=l("td"),Lc=s("1"),Yc=a(),So=l("td"),Xc=s("5.43"),zc=a(),$o=l("td"),Qc=s("3.38"),Kc=a(),Jo=l("td"),t2=s("2.82"),e2=a(),xo=l("td"),l2=s("37.75322284"),r2=a(),Bo=l("td"),o2=s("48.06629834"),a2=a(),F=l("tr"),Rd=l("td"),d2=a(),Ud=l("td"),s2=a(),Id=l("td"),f2=a(),Zd=l("td"),n2=a(),Hd=l("td"),i2=a(),Nd=l("td"),h2=a(),Vd=l("td"),c2=a(),W=l("tr"),Ro=l("td"),p2=s("1024"),T2=a(),Uo=l("td"),E2=s("10"),u2=a(),Io=l("td"),v2=s("OOM"),_2=a(),Zo=l("td"),D2=s("OOM"),m2=a(),Ho=l("td"),M2=s("OOM"),b2=a(),Gd=l("td"),w2=a(),Cd=l("td"),g2=a(),j=l("tr"),Fd=l("td"),O2=a(),No=l("td"),y2=s("8"),k2=a(),Vo=l("td"),P2=s("OOM"),A2=a(),Go=l("td"),S2=s("OOM"),$2=a(),Co=l("td"),J2=s("OOM"),x2=a(),Wd=l("td"),B2=a(),jd=l("td"),R2=a(),q=l("tr"),qd=l("td"),U2=a(),Fo=l("td"),I2=s("4"),Z2=a(),Wo=l("td"),H2=s("OOM"),N2=a(),jo=l("td"),V2=s("OOM"),G2=a(),qo=l("td"),C2=s("19.35"),F2=a(),Ld=l("td"),W2=a(),Yd=l("td"),j2=a(),L=l("tr"),Xd=l("td"),q2=a(),Lo=l("td"),L2=s("2"),Y2=a(),Yo=l("td"),X2=s("OOM"),z2=a(),Xo=l("td"),Q2=s("13"),K2=a(),zo=l("td"),tp=s("10.78"),ep=a(),zd=l("td"),lp=a(),Qd=l("td"),rp=a(),Y=l("tr"),Kd=l("td"),op=a(),Qo=l("td"),ap=s("1"),dp=a(),Ko=l("td"),sp=s("OOM"),fp=a(),ta=l("td"),np=s("6.66"),ip=a(),ea=l("td"),hp=s("5.54"),cp=a(),ts=l("td"),pp=a(),es=l("td"),ls=a(),Jt=l("p"),Tp=s("As seen in the tables above, the speedup with "),la=l("code"),Ep=s("tomesd"),up=s(" becomes more pronounced for larger image resolutions. It is also interesting to note that with "),ra=l("code"),vp=s("tomesd"),_p=s(", it becomes possible to run the pipeline on a higher resolution, like 1024x1024."),rs=a(),ee=l("p"),Dp=s("It might be possible to speed up inference even further with "),ye=l("a"),oa=l("code"),mp=s("torch.compile()"),Mp=s("."),os=a(),Ft=l("h2"),le=l("a"),aa=l("span"),oe(ke.$$.fragment),bp=a(),da=l("span"),wp=s("Quality"),as=a(),xt=l("p"),gp=s("As reported in "),Pe=l("a"),Op=s("the paper"),yp=s(", ToMe can preserve the quality of the generated images to a great extent while speeding up inference. By increasing the "),sa=l("code"),kp=s("ratio"),Pp=s(", it is possible to further speed up inference, but that might come at the cost of a deterioration in the image quality."),ds=a(),Bt=l("p"),Ap=s("To test the quality of the generated samples using our setup, we sampled a few prompts from the \u201CParti Prompts\u201D (introduced in "),Ae=l("a"),Sp=s("Parti"),$p=s(") and performed inference with the "),He=l("a"),Jp=s("StableDiffusionPipeline"),xp=s(" in the following settings:"),ss=a(),Rt=l("ul"),Ne=l("li"),Bp=s("Vanilla "),Ve=l("a"),Rp=s("StableDiffusionPipeline"),Up=a(),Ge=l("li"),Ce=l("a"),Ip=s("StableDiffusionPipeline"),Zp=s(" + ToMe"),Hp=a(),Fe=l("li"),We=l("a"),Np=s("StableDiffusionPipeline"),Vp=s(" + ToMe + xformers"),fs=a(),je=l("p"),Gp=s("We didn\u2019t notice any significant decrease in the quality of the generated samples. Here are samples:"),ns=a(),qe=l("p"),Le=l("img"),is=a(),Ut=l("p"),Cp=s("You can check out the generated samples "),Se=l("a"),Fp=s("here"),Wp=s(". We used "),$e=l("a"),jp=s("this script"),qp=s(" for conducting this experiment."),this.h()},l(n){const h=Nu('[data-svelte="svelte-1phssyn"]',document.head);Zt=r(h,"META",{name:!0,content:!0}),h.forEach(e),na=d(n),Ht=r(n,"H1",{class:!0});var cs=o(Ht);Wt=r(cs,"A",{id:!0,class:!0,href:!0});var Kp=o(Wt);ll=r(Kp,"SPAN",{});var t3=o(ll);ae(ie.$$.fragment,t3),t3.forEach(e),Kp.forEach(e),gs=d(cs),rl=r(cs,"SPAN",{});var e3=o(rl);Os=f(e3,"Token Merging"),e3.forEach(e),cs.forEach(e),ia=d(n),jt=r(n,"P",{});var ps=o(jt);ys=f(ps,"Token Merging (introduced in "),he=r(ps,"A",{href:!0,rel:!0});var l3=o(he);ks=f(l3,"Token Merging: Your ViT But Faster"),l3.forEach(e),Ps=f(ps,") works by merging the redundant tokens / patches progressively in the forward pass of a Transformer-based network. It can speed up the inference latency of the underlying network."),ps.forEach(e),ha=d(n),z=r(n,"P",{});var It=o(z);As=f(It,"After Token Merging (ToMe) was released, the authors released "),ce=r(It,"A",{href:!0,rel:!0});var r3=o(ce);Ss=f(r3,"Token Merging for Fast Stable Diffusion"),r3.forEach(e),$s=f(It,", which introduced a version of ToMe which is more compatible with Stable Diffusion. We can use ToMe to gracefully speed up the inference latency of a "),Je=r(It,"A",{href:!0});var o3=o(Je);Js=f(o3,"DiffusionPipeline"),o3.forEach(e),xs=f(It,". This doc discusses how to apply ToMe to the "),xe=r(It,"A",{href:!0});var a3=o(xe);Bs=f(a3,"StableDiffusionPipeline"),a3.forEach(e),Rs=f(It,", the expected speedups, and the qualitative aspects of using ToMe on the "),Be=r(It,"A",{href:!0});var d3=o(Be);Us=f(d3,"StableDiffusionPipeline"),d3.forEach(e),Is=f(It,"."),It.forEach(e),ca=d(n),Nt=r(n,"H2",{class:!0});var Ts=o(Nt);qt=r(Ts,"A",{id:!0,class:!0,href:!0});var s3=o(qt);ol=r(s3,"SPAN",{});var f3=o(ol);ae(pe.$$.fragment,f3),f3.forEach(e),s3.forEach(e),Zs=d(Ts),al=r(Ts,"SPAN",{});var n3=o(al);Hs=f(n3,"Using ToMe"),n3.forEach(e),Ts.forEach(e),pa=d(n),$t=r(n,"P",{});var Ye=o($t);Ns=f(Ye,"The authors of ToMe released a convenient Python library called "),Te=r(Ye,"A",{href:!0,rel:!0});var i3=o(Te);dl=r(i3,"CODE",{});var h3=o(dl);Vs=f(h3,"tomesd"),h3.forEach(e),i3.forEach(e),Gs=f(Ye," that lets us apply ToMe to a "),Re=r(Ye,"A",{href:!0});var c3=o(Re);Cs=f(c3,"DiffusionPipeline"),c3.forEach(e),Fs=f(Ye," like so:"),Ye.forEach(e),Ta=d(n),ae(Ee.$$.fragment,n),Ea=d(n),Ue=r(n,"P",{});var p3=o(Ue);Ws=f(p3,"And that\u2019s it!"),p3.forEach(e),ua=d(n),v=r(n,"P",{});var X=o(v);sl=r(X,"CODE",{});var T3=o(sl);js=f(T3,"tomesd.apply_patch()"),T3.forEach(e),qs=f(X," exposes "),ue=r(X,"A",{href:!0,rel:!0});var E3=o(ue);Ls=f(E3,"a number of arguments"),E3.forEach(e),Ys=f(X," to let us strike a balance between the pipeline inference speed and the quality of the generated tokens. Amongst those arguments, the most important one is "),fl=r(X,"CODE",{});var u3=o(fl);Xs=f(u3,"ratio"),u3.forEach(e),zs=f(X,". "),nl=r(X,"CODE",{});var v3=o(nl);Qs=f(v3,"ratio"),v3.forEach(e),Ks=f(X," controls the number of tokens that will be merged during the forward pass. For more details on "),il=r(X,"CODE",{});var _3=o(il);tf=f(_3,"tomesd"),_3.forEach(e),ef=f(X,", please refer to the original repository "),ve=r(X,"A",{href:!0,rel:!0});var D3=o(ve);lf=f(D3,"https://github.com/dbolya/tomesd"),D3.forEach(e),rf=f(X," and "),_e=r(X,"A",{href:!0,rel:!0});var m3=o(_e);of=f(m3,"the paper"),m3.forEach(e),af=f(X,"."),X.forEach(e),va=d(n),Vt=r(n,"H2",{class:!0});var Es=o(Vt);Lt=r(Es,"A",{id:!0,class:!0,href:!0});var M3=o(Lt);hl=r(M3,"SPAN",{});var b3=o(hl);ae(De.$$.fragment,b3),b3.forEach(e),M3.forEach(e),df=d(Es),Yt=r(Es,"SPAN",{});var fa=o(Yt);sf=f(fa,"Benchmarking "),cl=r(fa,"CODE",{});var w3=o(cl);ff=f(w3,"tomesd"),w3.forEach(e),nf=f(fa," with "),pl=r(fa,"CODE",{});var g3=o(pl);hf=f(g3,"StableDiffusionPipeline"),g3.forEach(e),fa.forEach(e),Es.forEach(e),_a=d(n),St=r(n,"P",{});var re=o(St);cf=f(re,"We benchmarked the impact of using "),Tl=r(re,"CODE",{});var O3=o(Tl);pf=f(O3,"tomesd"),O3.forEach(e),Tf=f(re," on "),Ie=r(re,"A",{href:!0});var y3=o(Ie);Ef=f(y3,"StableDiffusionPipeline"),y3.forEach(e),uf=f(re," along with "),me=r(re,"A",{href:!0,rel:!0});var k3=o(me);vf=f(k3,"xformers"),k3.forEach(e),_f=f(re," across different image resolutions. We used A100 and V100 as our test GPU devices with the following development environment (with Python 3.8.5):"),re.forEach(e),Da=d(n),ae(Me.$$.fragment,n),ma=d(n),Xt=r(n,"P",{});var us=o(Xt);Df=f(us,"We used this script for benchmarking: "),be=r(us,"A",{href:!0,rel:!0});var P3=o(be);mf=f(P3,"https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),P3.forEach(e),Mf=f(us,". Following are our findings:"),us.forEach(e),Ma=d(n),Gt=r(n,"H3",{class:!0});var vs=o(Gt);zt=r(vs,"A",{id:!0,class:!0,href:!0});var A3=o(zt);El=r(A3,"SPAN",{});var S3=o(El);ae(we.$$.fragment,S3),S3.forEach(e),A3.forEach(e),bf=d(vs),ul=r(vs,"SPAN",{});var $3=o(ul);wf=f($3,"A100"),$3.forEach(e),vs.forEach(e),ba=d(n),Qt=r(n,"TABLE",{});var _s=o(Qt);vl=r(_s,"THEAD",{});var J3=o(vl);_=r(J3,"TR",{});var Q=o(_);_l=r(Q,"TH",{});var x3=o(_l);gf=f(x3,"Resolution"),x3.forEach(e),Of=d(Q),Dl=r(Q,"TH",{});var B3=o(Dl);yf=f(B3,"Batch size"),B3.forEach(e),kf=d(Q),ml=r(Q,"TH",{});var R3=o(ml);Pf=f(R3,"Vanilla"),R3.forEach(e),Af=d(Q),Ml=r(Q,"TH",{});var U3=o(Ml);Sf=f(U3,"ToMe"),U3.forEach(e),$f=d(Q),bl=r(Q,"TH",{});var I3=o(bl);Jf=f(I3,"ToMe + xFormers"),I3.forEach(e),xf=d(Q),wl=r(Q,"TH",{});var Z3=o(wl);Bf=f(Z3,"ToMe speedup (%)"),Z3.forEach(e),Rf=d(Q),gl=r(Q,"TH",{});var H3=o(gl);Uf=f(H3,"ToMe + xFormers speedup (%)"),H3.forEach(e),Q.forEach(e),J3.forEach(e),If=d(_s),E=r(_s,"TBODY",{});var u=o(E);D=r(u,"TR",{});var K=o(D);Ol=r(K,"TD",{});var N3=o(Ol);Zf=f(N3,"512"),N3.forEach(e),Hf=d(K),yl=r(K,"TD",{});var V3=o(yl);Nf=f(V3,"10"),V3.forEach(e),Vf=d(K),kl=r(K,"TD",{});var G3=o(kl);Gf=f(G3,"6.88"),G3.forEach(e),Cf=d(K),Pl=r(K,"TD",{});var C3=o(Pl);Ff=f(C3,"5.26"),C3.forEach(e),Wf=d(K),Al=r(K,"TD",{});var F3=o(Al);jf=f(F3,"4.69"),F3.forEach(e),qf=d(K),Sl=r(K,"TD",{});var W3=o(Sl);Lf=f(W3,"23.54651163"),W3.forEach(e),Yf=d(K),$l=r(K,"TD",{});var j3=o($l);Xf=f(j3,"31.83139535"),j3.forEach(e),K.forEach(e),zf=d(u),m=r(u,"TR",{});var tt=o(m);wa=r(tt,"TD",{}),o(wa).forEach(e),Qf=d(tt),ga=r(tt,"TD",{}),o(ga).forEach(e),Kf=d(tt),Oa=r(tt,"TD",{}),o(Oa).forEach(e),tn=d(tt),ya=r(tt,"TD",{}),o(ya).forEach(e),en=d(tt),ka=r(tt,"TD",{}),o(ka).forEach(e),ln=d(tt),Pa=r(tt,"TD",{}),o(Pa).forEach(e),rn=d(tt),Aa=r(tt,"TD",{}),o(Aa).forEach(e),tt.forEach(e),on=d(u),M=r(u,"TR",{});var et=o(M);Jl=r(et,"TD",{});var q3=o(Jl);an=f(q3,"768"),q3.forEach(e),dn=d(et),xl=r(et,"TD",{});var L3=o(xl);sn=f(L3,"10"),L3.forEach(e),fn=d(et),Bl=r(et,"TD",{});var Y3=o(Bl);nn=f(Y3,"OOM"),Y3.forEach(e),hn=d(et),Rl=r(et,"TD",{});var X3=o(Rl);cn=f(X3,"14.71"),X3.forEach(e),pn=d(et),Ul=r(et,"TD",{});var z3=o(Ul);Tn=f(z3,"11"),z3.forEach(e),En=d(et),Sa=r(et,"TD",{}),o(Sa).forEach(e),un=d(et),$a=r(et,"TD",{}),o($a).forEach(e),et.forEach(e),vn=d(u),b=r(u,"TR",{});var lt=o(b);Ja=r(lt,"TD",{}),o(Ja).forEach(e),_n=d(lt),Il=r(lt,"TD",{});var Q3=o(Il);Dn=f(Q3,"8"),Q3.forEach(e),mn=d(lt),Zl=r(lt,"TD",{});var K3=o(Zl);Mn=f(K3,"OOM"),K3.forEach(e),bn=d(lt),Hl=r(lt,"TD",{});var tT=o(Hl);wn=f(tT,"11.56"),tT.forEach(e),gn=d(lt),Nl=r(lt,"TD",{});var eT=o(Nl);On=f(eT,"8.84"),eT.forEach(e),yn=d(lt),xa=r(lt,"TD",{}),o(xa).forEach(e),kn=d(lt),Ba=r(lt,"TD",{}),o(Ba).forEach(e),lt.forEach(e),Pn=d(u),w=r(u,"TR",{});var rt=o(w);Ra=r(rt,"TD",{}),o(Ra).forEach(e),An=d(rt),Vl=r(rt,"TD",{});var lT=o(Vl);Sn=f(lT,"4"),lT.forEach(e),$n=d(rt),Gl=r(rt,"TD",{});var rT=o(Gl);Jn=f(rT,"OOM"),rT.forEach(e),xn=d(rt),Cl=r(rt,"TD",{});var oT=o(Cl);Bn=f(oT,"5.98"),oT.forEach(e),Rn=d(rt),Fl=r(rt,"TD",{});var aT=o(Fl);Un=f(aT,"4.66"),aT.forEach(e),In=d(rt),Ua=r(rt,"TD",{}),o(Ua).forEach(e),Zn=d(rt),Ia=r(rt,"TD",{}),o(Ia).forEach(e),rt.forEach(e),Hn=d(u),g=r(u,"TR",{});var ot=o(g);Za=r(ot,"TD",{}),o(Za).forEach(e),Nn=d(ot),Wl=r(ot,"TD",{});var dT=o(Wl);Vn=f(dT,"2"),dT.forEach(e),Gn=d(ot),jl=r(ot,"TD",{});var sT=o(jl);Cn=f(sT,"4.99"),sT.forEach(e),Fn=d(ot),ql=r(ot,"TD",{});var fT=o(ql);Wn=f(fT,"3.24"),fT.forEach(e),jn=d(ot),Ll=r(ot,"TD",{});var nT=o(Ll);qn=f(nT,"3.1"),nT.forEach(e),Ln=d(ot),Yl=r(ot,"TD",{});var iT=o(Yl);Yn=f(iT,"35.07014028"),iT.forEach(e),Xn=d(ot),Xl=r(ot,"TD",{});var hT=o(Xl);zn=f(hT,"37.8757515"),hT.forEach(e),ot.forEach(e),Qn=d(u),O=r(u,"TR",{});var at=o(O);Ha=r(at,"TD",{}),o(Ha).forEach(e),Kn=d(at),zl=r(at,"TD",{});var cT=o(zl);ti=f(cT,"1"),cT.forEach(e),ei=d(at),Ql=r(at,"TD",{});var pT=o(Ql);li=f(pT,"3.29"),pT.forEach(e),ri=d(at),Kl=r(at,"TD",{});var TT=o(Kl);oi=f(TT,"2.24"),TT.forEach(e),ai=d(at),tr=r(at,"TD",{});var ET=o(tr);di=f(ET,"2.03"),ET.forEach(e),si=d(at),er=r(at,"TD",{});var uT=o(er);fi=f(uT,"31.91489362"),uT.forEach(e),ni=d(at),lr=r(at,"TD",{});var vT=o(lr);ii=f(vT,"38.29787234"),vT.forEach(e),at.forEach(e),hi=d(u),y=r(u,"TR",{});var dt=o(y);Na=r(dt,"TD",{}),o(Na).forEach(e),ci=d(dt),Va=r(dt,"TD",{}),o(Va).forEach(e),pi=d(dt),Ga=r(dt,"TD",{}),o(Ga).forEach(e),Ti=d(dt),Ca=r(dt,"TD",{}),o(Ca).forEach(e),Ei=d(dt),Fa=r(dt,"TD",{}),o(Fa).forEach(e),ui=d(dt),Wa=r(dt,"TD",{}),o(Wa).forEach(e),vi=d(dt),ja=r(dt,"TD",{}),o(ja).forEach(e),dt.forEach(e),_i=d(u),k=r(u,"TR",{});var st=o(k);rr=r(st,"TD",{});var _T=o(rr);Di=f(_T,"1024"),_T.forEach(e),mi=d(st),or=r(st,"TD",{});var DT=o(or);Mi=f(DT,"10"),DT.forEach(e),bi=d(st),ar=r(st,"TD",{});var mT=o(ar);wi=f(mT,"OOM"),mT.forEach(e),gi=d(st),dr=r(st,"TD",{});var MT=o(dr);Oi=f(MT,"OOM"),MT.forEach(e),yi=d(st),sr=r(st,"TD",{});var bT=o(sr);ki=f(bT,"OOM"),bT.forEach(e),Pi=d(st),qa=r(st,"TD",{}),o(qa).forEach(e),Ai=d(st),La=r(st,"TD",{}),o(La).forEach(e),st.forEach(e),Si=d(u),P=r(u,"TR",{});var ft=o(P);Ya=r(ft,"TD",{}),o(Ya).forEach(e),$i=d(ft),fr=r(ft,"TD",{});var wT=o(fr);Ji=f(wT,"8"),wT.forEach(e),xi=d(ft),nr=r(ft,"TD",{});var gT=o(nr);Bi=f(gT,"OOM"),gT.forEach(e),Ri=d(ft),ir=r(ft,"TD",{});var OT=o(ir);Ui=f(OT,"OOM"),OT.forEach(e),Ii=d(ft),hr=r(ft,"TD",{});var yT=o(hr);Zi=f(yT,"OOM"),yT.forEach(e),Hi=d(ft),Xa=r(ft,"TD",{}),o(Xa).forEach(e),Ni=d(ft),za=r(ft,"TD",{}),o(za).forEach(e),ft.forEach(e),Vi=d(u),A=r(u,"TR",{});var nt=o(A);Qa=r(nt,"TD",{}),o(Qa).forEach(e),Gi=d(nt),cr=r(nt,"TD",{});var kT=o(cr);Ci=f(kT,"4"),kT.forEach(e),Fi=d(nt),pr=r(nt,"TD",{});var PT=o(pr);Wi=f(PT,"OOM"),PT.forEach(e),ji=d(nt),Tr=r(nt,"TD",{});var AT=o(Tr);qi=f(AT,"12.51"),AT.forEach(e),Li=d(nt),Er=r(nt,"TD",{});var ST=o(Er);Yi=f(ST,"9.09"),ST.forEach(e),Xi=d(nt),Ka=r(nt,"TD",{}),o(Ka).forEach(e),zi=d(nt),td=r(nt,"TD",{}),o(td).forEach(e),nt.forEach(e),Qi=d(u),S=r(u,"TR",{});var it=o(S);ed=r(it,"TD",{}),o(ed).forEach(e),Ki=d(it),ur=r(it,"TD",{});var $T=o(ur);t1=f($T,"2"),$T.forEach(e),e1=d(it),vr=r(it,"TD",{});var JT=o(vr);l1=f(JT,"OOM"),JT.forEach(e),r1=d(it),_r=r(it,"TD",{});var xT=o(_r);o1=f(xT,"6.52"),xT.forEach(e),a1=d(it),Dr=r(it,"TD",{});var BT=o(Dr);d1=f(BT,"4.96"),BT.forEach(e),s1=d(it),ld=r(it,"TD",{}),o(ld).forEach(e),f1=d(it),rd=r(it,"TD",{}),o(rd).forEach(e),it.forEach(e),n1=d(u),$=r(u,"TR",{});var ht=o($);od=r(ht,"TD",{}),o(od).forEach(e),i1=d(ht),mr=r(ht,"TD",{});var RT=o(mr);h1=f(RT,"1"),RT.forEach(e),c1=d(ht),Mr=r(ht,"TD",{});var UT=o(Mr);p1=f(UT,"6.4"),UT.forEach(e),T1=d(ht),br=r(ht,"TD",{});var IT=o(br);E1=f(IT,"3.61"),IT.forEach(e),u1=d(ht),wr=r(ht,"TD",{});var ZT=o(wr);v1=f(ZT,"2.81"),ZT.forEach(e),_1=d(ht),gr=r(ht,"TD",{});var HT=o(gr);D1=f(HT,"43.59375"),HT.forEach(e),m1=d(ht),Or=r(ht,"TD",{});var NT=o(Or);M1=f(NT,"56.09375"),NT.forEach(e),ht.forEach(e),u.forEach(e),_s.forEach(e),ad=d(n),Ze=r(n,"P",{});var VT=o(Ze);yr=r(VT,"STRONG",{});var GT=o(yr);ge=r(GT,"EM",{});var Ds=o(ge);b1=f(Ds,"The timings reported here are in seconds. Speedups are calculated over the "),kr=r(Ds,"CODE",{});var CT=o(kr);w1=f(CT,"Vanilla"),CT.forEach(e),g1=f(Ds," timings."),Ds.forEach(e),GT.forEach(e),VT.forEach(e),dd=d(n),Ct=r(n,"H3",{class:!0});var ms=o(Ct);Kt=r(ms,"A",{id:!0,class:!0,href:!0});var FT=o(Kt);Pr=r(FT,"SPAN",{});var WT=o(Pr);ae(Oe.$$.fragment,WT),WT.forEach(e),FT.forEach(e),O1=d(ms),Ar=r(ms,"SPAN",{});var jT=o(Ar);y1=f(jT,"V100"),jT.forEach(e),ms.forEach(e),sd=d(n),te=r(n,"TABLE",{});var Ms=o(te);Sr=r(Ms,"THEAD",{});var qT=o(Sr);J=r(qT,"TR",{});var ct=o(J);$r=r(ct,"TH",{});var LT=o($r);k1=f(LT,"Resolution"),LT.forEach(e),P1=d(ct),Jr=r(ct,"TH",{});var YT=o(Jr);A1=f(YT,"Batch size"),YT.forEach(e),S1=d(ct),xr=r(ct,"TH",{});var XT=o(xr);$1=f(XT,"Vanilla"),XT.forEach(e),J1=d(ct),Br=r(ct,"TH",{});var zT=o(Br);x1=f(zT,"ToMe"),zT.forEach(e),B1=d(ct),Rr=r(ct,"TH",{});var QT=o(Rr);R1=f(QT,"ToMe + xFormers"),QT.forEach(e),U1=d(ct),Ur=r(ct,"TH",{});var KT=o(Ur);I1=f(KT,"ToMe speedup (%)"),KT.forEach(e),Z1=d(ct),Ir=r(ct,"TH",{});var tE=o(Ir);H1=f(tE,"ToMe + xFormers speedup (%)"),tE.forEach(e),ct.forEach(e),qT.forEach(e),N1=d(Ms),p=r(Ms,"TBODY",{});var T=o(p);x=r(T,"TR",{});var pt=o(x);Zr=r(pt,"TD",{});var eE=o(Zr);V1=f(eE,"512"),eE.forEach(e),G1=d(pt),Hr=r(pt,"TD",{});var lE=o(Hr);C1=f(lE,"10"),lE.forEach(e),F1=d(pt),Nr=r(pt,"TD",{});var rE=o(Nr);W1=f(rE,"OOM"),rE.forEach(e),j1=d(pt),Vr=r(pt,"TD",{});var oE=o(Vr);q1=f(oE,"10.03"),oE.forEach(e),L1=d(pt),Gr=r(pt,"TD",{});var aE=o(Gr);Y1=f(aE,"9.29"),aE.forEach(e),X1=d(pt),fd=r(pt,"TD",{}),o(fd).forEach(e),z1=d(pt),nd=r(pt,"TD",{}),o(nd).forEach(e),pt.forEach(e),Q1=d(T),B=r(T,"TR",{});var Tt=o(B);id=r(Tt,"TD",{}),o(id).forEach(e),K1=d(Tt),Cr=r(Tt,"TD",{});var dE=o(Cr);th=f(dE,"8"),dE.forEach(e),eh=d(Tt),Fr=r(Tt,"TD",{});var sE=o(Fr);lh=f(sE,"OOM"),sE.forEach(e),rh=d(Tt),Wr=r(Tt,"TD",{});var fE=o(Wr);oh=f(fE,"8.05"),fE.forEach(e),ah=d(Tt),jr=r(Tt,"TD",{});var nE=o(jr);dh=f(nE,"7.47"),nE.forEach(e),sh=d(Tt),hd=r(Tt,"TD",{}),o(hd).forEach(e),fh=d(Tt),cd=r(Tt,"TD",{}),o(cd).forEach(e),Tt.forEach(e),nh=d(T),R=r(T,"TR",{});var Et=o(R);pd=r(Et,"TD",{}),o(pd).forEach(e),ih=d(Et),qr=r(Et,"TD",{});var iE=o(qr);hh=f(iE,"4"),iE.forEach(e),ch=d(Et),Lr=r(Et,"TD",{});var hE=o(Lr);ph=f(hE,"5.7"),hE.forEach(e),Th=d(Et),Yr=r(Et,"TD",{});var cE=o(Yr);Eh=f(cE,"4.3"),cE.forEach(e),uh=d(Et),Xr=r(Et,"TD",{});var pE=o(Xr);vh=f(pE,"3.98"),pE.forEach(e),_h=d(Et),zr=r(Et,"TD",{});var TE=o(zr);Dh=f(TE,"24.56140351"),TE.forEach(e),mh=d(Et),Qr=r(Et,"TD",{});var EE=o(Qr);Mh=f(EE,"30.1754386"),EE.forEach(e),Et.forEach(e),bh=d(T),U=r(T,"TR",{});var ut=o(U);Td=r(ut,"TD",{}),o(Td).forEach(e),wh=d(ut),Kr=r(ut,"TD",{});var uE=o(Kr);gh=f(uE,"2"),uE.forEach(e),Oh=d(ut),to=r(ut,"TD",{});var vE=o(to);yh=f(vE,"3.14"),vE.forEach(e),kh=d(ut),eo=r(ut,"TD",{});var _E=o(eo);Ph=f(_E,"2.43"),_E.forEach(e),Ah=d(ut),lo=r(ut,"TD",{});var DE=o(lo);Sh=f(DE,"2.27"),DE.forEach(e),$h=d(ut),ro=r(ut,"TD",{});var mE=o(ro);Jh=f(mE,"22.61146497"),mE.forEach(e),xh=d(ut),oo=r(ut,"TD",{});var ME=o(oo);Bh=f(ME,"27.70700637"),ME.forEach(e),ut.forEach(e),Rh=d(T),I=r(T,"TR",{});var vt=o(I);Ed=r(vt,"TD",{}),o(Ed).forEach(e),Uh=d(vt),ao=r(vt,"TD",{});var bE=o(ao);Ih=f(bE,"1"),bE.forEach(e),Zh=d(vt),so=r(vt,"TD",{});var wE=o(so);Hh=f(wE,"1.88"),wE.forEach(e),Nh=d(vt),fo=r(vt,"TD",{});var gE=o(fo);Vh=f(gE,"1.57"),gE.forEach(e),Gh=d(vt),no=r(vt,"TD",{});var OE=o(no);Ch=f(OE,"1.57"),OE.forEach(e),Fh=d(vt),io=r(vt,"TD",{});var yE=o(io);Wh=f(yE,"16.4893617"),yE.forEach(e),jh=d(vt),ho=r(vt,"TD",{});var kE=o(ho);qh=f(kE,"16.4893617"),kE.forEach(e),vt.forEach(e),Lh=d(T),Z=r(T,"TR",{});var _t=o(Z);ud=r(_t,"TD",{}),o(ud).forEach(e),Yh=d(_t),vd=r(_t,"TD",{}),o(vd).forEach(e),Xh=d(_t),_d=r(_t,"TD",{}),o(_d).forEach(e),zh=d(_t),Dd=r(_t,"TD",{}),o(Dd).forEach(e),Qh=d(_t),md=r(_t,"TD",{}),o(md).forEach(e),Kh=d(_t),Md=r(_t,"TD",{}),o(Md).forEach(e),tc=d(_t),bd=r(_t,"TD",{}),o(bd).forEach(e),_t.forEach(e),ec=d(T),H=r(T,"TR",{});var Dt=o(H);co=r(Dt,"TD",{});var PE=o(co);lc=f(PE,"768"),PE.forEach(e),rc=d(Dt),po=r(Dt,"TD",{});var AE=o(po);oc=f(AE,"10"),AE.forEach(e),ac=d(Dt),To=r(Dt,"TD",{});var SE=o(To);dc=f(SE,"OOM"),SE.forEach(e),sc=d(Dt),Eo=r(Dt,"TD",{});var $E=o(Eo);fc=f($E,"OOM"),$E.forEach(e),nc=d(Dt),uo=r(Dt,"TD",{});var JE=o(uo);ic=f(JE,"23.67"),JE.forEach(e),hc=d(Dt),wd=r(Dt,"TD",{}),o(wd).forEach(e),cc=d(Dt),gd=r(Dt,"TD",{}),o(gd).forEach(e),Dt.forEach(e),pc=d(T),N=r(T,"TR",{});var mt=o(N);Od=r(mt,"TD",{}),o(Od).forEach(e),Tc=d(mt),vo=r(mt,"TD",{});var xE=o(vo);Ec=f(xE,"8"),xE.forEach(e),uc=d(mt),_o=r(mt,"TD",{});var BE=o(_o);vc=f(BE,"OOM"),BE.forEach(e),_c=d(mt),Do=r(mt,"TD",{});var RE=o(Do);Dc=f(RE,"OOM"),RE.forEach(e),mc=d(mt),mo=r(mt,"TD",{});var UE=o(mo);Mc=f(UE,"18.81"),UE.forEach(e),bc=d(mt),yd=r(mt,"TD",{}),o(yd).forEach(e),wc=d(mt),kd=r(mt,"TD",{}),o(kd).forEach(e),mt.forEach(e),gc=d(T),V=r(T,"TR",{});var Mt=o(V);Pd=r(Mt,"TD",{}),o(Pd).forEach(e),Oc=d(Mt),Mo=r(Mt,"TD",{});var IE=o(Mo);yc=f(IE,"4"),IE.forEach(e),kc=d(Mt),bo=r(Mt,"TD",{});var ZE=o(bo);Pc=f(ZE,"OOM"),ZE.forEach(e),Ac=d(Mt),wo=r(Mt,"TD",{});var HE=o(wo);Sc=f(HE,"11.81"),HE.forEach(e),$c=d(Mt),go=r(Mt,"TD",{});var NE=o(go);Jc=f(NE,"9.7"),NE.forEach(e),xc=d(Mt),Ad=r(Mt,"TD",{}),o(Ad).forEach(e),Bc=d(Mt),Sd=r(Mt,"TD",{}),o(Sd).forEach(e),Mt.forEach(e),Rc=d(T),G=r(T,"TR",{});var bt=o(G);$d=r(bt,"TD",{}),o($d).forEach(e),Uc=d(bt),Oo=r(bt,"TD",{});var VE=o(Oo);Ic=f(VE,"2"),VE.forEach(e),Zc=d(bt),yo=r(bt,"TD",{});var GE=o(yo);Hc=f(GE,"OOM"),GE.forEach(e),Nc=d(bt),ko=r(bt,"TD",{});var CE=o(ko);Vc=f(CE,"6.27"),CE.forEach(e),Gc=d(bt),Po=r(bt,"TD",{});var FE=o(Po);Cc=f(FE,"5.2"),FE.forEach(e),Fc=d(bt),Jd=r(bt,"TD",{}),o(Jd).forEach(e),Wc=d(bt),xd=r(bt,"TD",{}),o(xd).forEach(e),bt.forEach(e),jc=d(T),C=r(T,"TR",{});var wt=o(C);Bd=r(wt,"TD",{}),o(Bd).forEach(e),qc=d(wt),Ao=r(wt,"TD",{});var WE=o(Ao);Lc=f(WE,"1"),WE.forEach(e),Yc=d(wt),So=r(wt,"TD",{});var jE=o(So);Xc=f(jE,"5.43"),jE.forEach(e),zc=d(wt),$o=r(wt,"TD",{});var qE=o($o);Qc=f(qE,"3.38"),qE.forEach(e),Kc=d(wt),Jo=r(wt,"TD",{});var LE=o(Jo);t2=f(LE,"2.82"),LE.forEach(e),e2=d(wt),xo=r(wt,"TD",{});var YE=o(xo);l2=f(YE,"37.75322284"),YE.forEach(e),r2=d(wt),Bo=r(wt,"TD",{});var XE=o(Bo);o2=f(XE,"48.06629834"),XE.forEach(e),wt.forEach(e),a2=d(T),F=r(T,"TR",{});var gt=o(F);Rd=r(gt,"TD",{}),o(Rd).forEach(e),d2=d(gt),Ud=r(gt,"TD",{}),o(Ud).forEach(e),s2=d(gt),Id=r(gt,"TD",{}),o(Id).forEach(e),f2=d(gt),Zd=r(gt,"TD",{}),o(Zd).forEach(e),n2=d(gt),Hd=r(gt,"TD",{}),o(Hd).forEach(e),i2=d(gt),Nd=r(gt,"TD",{}),o(Nd).forEach(e),h2=d(gt),Vd=r(gt,"TD",{}),o(Vd).forEach(e),gt.forEach(e),c2=d(T),W=r(T,"TR",{});var Ot=o(W);Ro=r(Ot,"TD",{});var zE=o(Ro);p2=f(zE,"1024"),zE.forEach(e),T2=d(Ot),Uo=r(Ot,"TD",{});var QE=o(Uo);E2=f(QE,"10"),QE.forEach(e),u2=d(Ot),Io=r(Ot,"TD",{});var KE=o(Io);v2=f(KE,"OOM"),KE.forEach(e),_2=d(Ot),Zo=r(Ot,"TD",{});var tu=o(Zo);D2=f(tu,"OOM"),tu.forEach(e),m2=d(Ot),Ho=r(Ot,"TD",{});var eu=o(Ho);M2=f(eu,"OOM"),eu.forEach(e),b2=d(Ot),Gd=r(Ot,"TD",{}),o(Gd).forEach(e),w2=d(Ot),Cd=r(Ot,"TD",{}),o(Cd).forEach(e),Ot.forEach(e),g2=d(T),j=r(T,"TR",{});var yt=o(j);Fd=r(yt,"TD",{}),o(Fd).forEach(e),O2=d(yt),No=r(yt,"TD",{});var lu=o(No);y2=f(lu,"8"),lu.forEach(e),k2=d(yt),Vo=r(yt,"TD",{});var ru=o(Vo);P2=f(ru,"OOM"),ru.forEach(e),A2=d(yt),Go=r(yt,"TD",{});var ou=o(Go);S2=f(ou,"OOM"),ou.forEach(e),$2=d(yt),Co=r(yt,"TD",{});var au=o(Co);J2=f(au,"OOM"),au.forEach(e),x2=d(yt),Wd=r(yt,"TD",{}),o(Wd).forEach(e),B2=d(yt),jd=r(yt,"TD",{}),o(jd).forEach(e),yt.forEach(e),R2=d(T),q=r(T,"TR",{});var kt=o(q);qd=r(kt,"TD",{}),o(qd).forEach(e),U2=d(kt),Fo=r(kt,"TD",{});var du=o(Fo);I2=f(du,"4"),du.forEach(e),Z2=d(kt),Wo=r(kt,"TD",{});var su=o(Wo);H2=f(su,"OOM"),su.forEach(e),N2=d(kt),jo=r(kt,"TD",{});var fu=o(jo);V2=f(fu,"OOM"),fu.forEach(e),G2=d(kt),qo=r(kt,"TD",{});var nu=o(qo);C2=f(nu,"19.35"),nu.forEach(e),F2=d(kt),Ld=r(kt,"TD",{}),o(Ld).forEach(e),W2=d(kt),Yd=r(kt,"TD",{}),o(Yd).forEach(e),kt.forEach(e),j2=d(T),L=r(T,"TR",{});var Pt=o(L);Xd=r(Pt,"TD",{}),o(Xd).forEach(e),q2=d(Pt),Lo=r(Pt,"TD",{});var iu=o(Lo);L2=f(iu,"2"),iu.forEach(e),Y2=d(Pt),Yo=r(Pt,"TD",{});var hu=o(Yo);X2=f(hu,"OOM"),hu.forEach(e),z2=d(Pt),Xo=r(Pt,"TD",{});var cu=o(Xo);Q2=f(cu,"13"),cu.forEach(e),K2=d(Pt),zo=r(Pt,"TD",{});var pu=o(zo);tp=f(pu,"10.78"),pu.forEach(e),ep=d(Pt),zd=r(Pt,"TD",{}),o(zd).forEach(e),lp=d(Pt),Qd=r(Pt,"TD",{}),o(Qd).forEach(e),Pt.forEach(e),rp=d(T),Y=r(T,"TR",{});var At=o(Y);Kd=r(At,"TD",{}),o(Kd).forEach(e),op=d(At),Qo=r(At,"TD",{});var Tu=o(Qo);ap=f(Tu,"1"),Tu.forEach(e),dp=d(At),Ko=r(At,"TD",{});var Eu=o(Ko);sp=f(Eu,"OOM"),Eu.forEach(e),fp=d(At),ta=r(At,"TD",{});var uu=o(ta);np=f(uu,"6.66"),uu.forEach(e),ip=d(At),ea=r(At,"TD",{});var vu=o(ea);hp=f(vu,"5.54"),vu.forEach(e),cp=d(At),ts=r(At,"TD",{}),o(ts).forEach(e),pp=d(At),es=r(At,"TD",{}),o(es).forEach(e),At.forEach(e),T.forEach(e),Ms.forEach(e),ls=d(n),Jt=r(n,"P",{});var Xe=o(Jt);Tp=f(Xe,"As seen in the tables above, the speedup with "),la=r(Xe,"CODE",{});var _u=o(la);Ep=f(_u,"tomesd"),_u.forEach(e),up=f(Xe," becomes more pronounced for larger image resolutions. It is also interesting to note that with "),ra=r(Xe,"CODE",{});var Du=o(ra);vp=f(Du,"tomesd"),Du.forEach(e),_p=f(Xe,", it becomes possible to run the pipeline on a higher resolution, like 1024x1024."),Xe.forEach(e),rs=d(n),ee=r(n,"P",{});var bs=o(ee);Dp=f(bs,"It might be possible to speed up inference even further with "),ye=r(bs,"A",{href:!0,rel:!0});var mu=o(ye);oa=r(mu,"CODE",{});var Mu=o(oa);mp=f(Mu,"torch.compile()"),Mu.forEach(e),mu.forEach(e),Mp=f(bs,"."),bs.forEach(e),os=d(n),Ft=r(n,"H2",{class:!0});var ws=o(Ft);le=r(ws,"A",{id:!0,class:!0,href:!0});var bu=o(le);aa=r(bu,"SPAN",{});var wu=o(aa);ae(ke.$$.fragment,wu),wu.forEach(e),bu.forEach(e),bp=d(ws),da=r(ws,"SPAN",{});var gu=o(da);wp=f(gu,"Quality"),gu.forEach(e),ws.forEach(e),as=d(n),xt=r(n,"P",{});var ze=o(xt);gp=f(ze,"As reported in "),Pe=r(ze,"A",{href:!0,rel:!0});var Ou=o(Pe);Op=f(Ou,"the paper"),Ou.forEach(e),yp=f(ze,", ToMe can preserve the quality of the generated images to a great extent while speeding up inference. By increasing the "),sa=r(ze,"CODE",{});var yu=o(sa);kp=f(yu,"ratio"),yu.forEach(e),Pp=f(ze,", it is possible to further speed up inference, but that might come at the cost of a deterioration in the image quality."),ze.forEach(e),ds=d(n),Bt=r(n,"P",{});var Qe=o(Bt);Ap=f(Qe,"To test the quality of the generated samples using our setup, we sampled a few prompts from the \u201CParti Prompts\u201D (introduced in "),Ae=r(Qe,"A",{href:!0,rel:!0});var ku=o(Ae);Sp=f(ku,"Parti"),ku.forEach(e),$p=f(Qe,") and performed inference with the "),He=r(Qe,"A",{href:!0});var Pu=o(He);Jp=f(Pu,"StableDiffusionPipeline"),Pu.forEach(e),xp=f(Qe," in the following settings:"),Qe.forEach(e),ss=d(n),Rt=r(n,"UL",{});var Ke=o(Rt);Ne=r(Ke,"LI",{});var Lp=o(Ne);Bp=f(Lp,"Vanilla "),Ve=r(Lp,"A",{href:!0});var Au=o(Ve);Rp=f(Au,"StableDiffusionPipeline"),Au.forEach(e),Lp.forEach(e),Up=d(Ke),Ge=r(Ke,"LI",{});var Yp=o(Ge);Ce=r(Yp,"A",{href:!0});var Su=o(Ce);Ip=f(Su,"StableDiffusionPipeline"),Su.forEach(e),Zp=f(Yp," + ToMe"),Yp.forEach(e),Hp=d(Ke),Fe=r(Ke,"LI",{});var Xp=o(Fe);We=r(Xp,"A",{href:!0});var $u=o(We);Np=f($u,"StableDiffusionPipeline"),$u.forEach(e),Vp=f(Xp," + ToMe + xformers"),Xp.forEach(e),Ke.forEach(e),fs=d(n),je=r(n,"P",{});var Ju=o(je);Gp=f(Ju,"We didn\u2019t notice any significant decrease in the quality of the generated samples. Here are samples:"),Ju.forEach(e),ns=d(n),qe=r(n,"P",{});var xu=o(qe);Le=r(xu,"IMG",{src:!0,alt:!0}),xu.forEach(e),is=d(n),Ut=r(n,"P",{});var tl=o(Ut);Cp=f(tl,"You can check out the generated samples "),Se=r(tl,"A",{href:!0,rel:!0});var Bu=o(Se);Fp=f(Bu,"here"),Bu.forEach(e),Wp=f(tl,". We used "),$e=r(tl,"A",{href:!0,rel:!0});var Ru=o($e);jp=f(Ru,"this script"),Ru.forEach(e),qp=f(tl," for conducting this experiment."),tl.forEach(e),this.h()},h(){i(Zt,"name","hf:doc:metadata"),i(Zt,"content",JSON.stringify(Wu)),i(Wt,"id","token-merging"),i(Wt,"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"),i(Wt,"href","#token-merging"),i(Ht,"class","relative group"),i(he,"href","https://arxiv.org/abs/2210.09461"),i(he,"rel","nofollow"),i(ce,"href","https://arxiv.org/abs/2303.17604"),i(ce,"rel","nofollow"),i(Je,"href","/docs/diffusers/v0.18.2/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),i(xe,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Be,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(qt,"id","using-tome"),i(qt,"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"),i(qt,"href","#using-tome"),i(Nt,"class","relative group"),i(Te,"href","https://github.com/dbolya/tomesd"),i(Te,"rel","nofollow"),i(Re,"href","/docs/diffusers/v0.18.2/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),i(ue,"href","https://github.com/dbolya/tomesd#usage"),i(ue,"rel","nofollow"),i(ve,"href","https://github.com/dbolya/tomesd"),i(ve,"rel","nofollow"),i(_e,"href","https://arxiv.org/abs/2303.17604"),i(_e,"rel","nofollow"),i(Lt,"id","benchmarking-tomesd-with-stablediffusionpipeline"),i(Lt,"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"),i(Lt,"href","#benchmarking-tomesd-with-stablediffusionpipeline"),i(Vt,"class","relative group"),i(Ie,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(me,"href","https://huggingface.co/docs/diffusers/optimization/xformers"),i(me,"rel","nofollow"),i(be,"href","https://gist.github.com/sayakpaul/27aec6bca7eb7b0e0aa4112205850335"),i(be,"rel","nofollow"),i(zt,"id","a100"),i(zt,"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"),i(zt,"href","#a100"),i(Gt,"class","relative group"),i(Kt,"id","v100"),i(Kt,"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"),i(Kt,"href","#v100"),i(Ct,"class","relative group"),i(ye,"href","https://huggingface.co/docs/diffusers/optimization/torch2.0"),i(ye,"rel","nofollow"),i(le,"id","quality"),i(le,"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"),i(le,"href","#quality"),i(Ft,"class","relative group"),i(Pe,"href","https://arxiv.org/abs/2303.17604"),i(Pe,"rel","nofollow"),i(Ae,"href","https://parti.research.google/"),i(Ae,"rel","nofollow"),i(He,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Ve,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(Ce,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),i(We,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),Vu(Le.src,Qp="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/tome/tome_samples.png")||i(Le,"src",Qp),i(Le,"alt","tome-samples"),i(Se,"href","https://wandb.ai/sayakpaul/tomesd-results/runs/23j4bj3i?workspace="),i(Se,"rel","nofollow"),i($e,"href","https://gist.github.com/sayakpaul/8cac98d7f22399085a060992f411ecbd"),i($e,"rel","nofollow")},m(n,h){t(document.head,Zt),c(n,na,h),c(n,Ht,h),t(Ht,Wt),t(Wt,ll),de(ie,ll,null),t(Ht,gs),t(Ht,rl),t(rl,Os),c(n,ia,h),c(n,jt,h),t(jt,ys),t(jt,he),t(he,ks),t(jt,Ps),c(n,ha,h),c(n,z,h),t(z,As),t(z,ce),t(ce,Ss),t(z,$s),t(z,Je),t(Je,Js),t(z,xs),t(z,xe),t(xe,Bs),t(z,Rs),t(z,Be),t(Be,Us),t(z,Is),c(n,ca,h),c(n,Nt,h),t(Nt,qt),t(qt,ol),de(pe,ol,null),t(Nt,Zs),t(Nt,al),t(al,Hs),c(n,pa,h),c(n,$t,h),t($t,Ns),t($t,Te),t(Te,dl),t(dl,Vs),t($t,Gs),t($t,Re),t(Re,Cs),t($t,Fs),c(n,Ta,h),de(Ee,n,h),c(n,Ea,h),c(n,Ue,h),t(Ue,Ws),c(n,ua,h),c(n,v,h),t(v,sl),t(sl,js),t(v,qs),t(v,ue),t(ue,Ls),t(v,Ys),t(v,fl),t(fl,Xs),t(v,zs),t(v,nl),t(nl,Qs),t(v,Ks),t(v,il),t(il,tf),t(v,ef),t(v,ve),t(ve,lf),t(v,rf),t(v,_e),t(_e,of),t(v,af),c(n,va,h),c(n,Vt,h),t(Vt,Lt),t(Lt,hl),de(De,hl,null),t(V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i),t(A,Li),t(A,Er),t(Er,Yi),t(A,Xi),t(A,Ka),t(A,zi),t(A,td),t(E,Qi),t(E,S),t(S,ed),t(S,Ki),t(S,ur),t(ur,t1),t(S,e1),t(S,vr),t(vr,l1),t(S,r1),t(S,_r),t(_r,o1),t(S,a1),t(S,Dr),t(Dr,d1),t(S,s1),t(S,ld),t(S,f1),t(S,rd),t(E,n1),t(E,$),t($,od),t($,i1),t($,mr),t(mr,h1),t($,c1),t($,Mr),t(Mr,p1),t($,T1),t($,br),t(br,E1),t($,u1),t($,wr),t(wr,v1),t($,_1),t($,gr),t(gr,D1),t($,m1),t($,Or),t(Or,M1),c(n,ad,h),c(n,Ze,h),t(Ze,yr),t(yr,ge),t(ge,b1),t(ge,kr),t(kr,w1),t(ge,g1),c(n,dd,h),c(n,Ct,h),t(Ct,Kt),t(Kt,Pr),de(Oe,Pr,null),t(Ct,O1),t(Ct,Ar),t(Ar,y1),c(n,sd,h),c(n,te,h),t(te,Sr),t(Sr,J),t(J,$r),t($r,k1),t(J,P1),t(J,Jr),t(Jr,A1),t(J,S1),t(J,xr),t(xr,$1),t(J,J1),t(J,Br),t(Br,x1),t(J,B1),t(J,Rr),t(Rr,R1),t(J,U1),t(J,Ur),t(Ur,I1),t(J,Z1),t(J,Ir),t(Ir,H1),t(te,N1),t(te,p),t(p,x),t(x,Zr),t(Zr,V1),t(x,G1),t(x,Hr),t(Hr,C1),t(x,F1),t(x,Nr),t(Nr,W1),t(x,j1),t(x,Vr),t(Vr,q1),t(x,L1),t(x,Gr),t(Gr,Y1),t(x,X1),t(x,fd),t(x,z1),t(x,nd),t(p,Q1),t(p,B),t(B,id),t(B,K1),t(B,Cr),t(Cr,th),t(B,eh),t(B,Fr),t(Fr,lh),t(B,rh),t(B,Wr),t(Wr,oh),t(B,ah),t(B,jr),t(jr,dh),t(B,sh),t(B,hd),t(B,fh),t(B,cd),t(p,nh),t(p,R),t(R,pd),t(R,ih),t(R,qr),t(qr,hh),t(R,ch),t(R,L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t(Y,fp),t(Y,ta),t(ta,np),t(Y,ip),t(Y,ea),t(ea,hp),t(Y,cp),t(Y,ts),t(Y,pp),t(Y,es),c(n,ls,h),c(n,Jt,h),t(Jt,Tp),t(Jt,la),t(la,Ep),t(Jt,up),t(Jt,ra),t(ra,vp),t(Jt,_p),c(n,rs,h),c(n,ee,h),t(ee,Dp),t(ee,ye),t(ye,oa),t(oa,mp),t(ee,Mp),c(n,os,h),c(n,Ft,h),t(Ft,le),t(le,aa),de(ke,aa,null),t(Ft,bp),t(Ft,da),t(da,wp),c(n,as,h),c(n,xt,h),t(xt,gp),t(xt,Pe),t(Pe,Op),t(xt,yp),t(xt,sa),t(sa,kp),t(xt,Pp),c(n,ds,h),c(n,Bt,h),t(Bt,Ap),t(Bt,Ae),t(Ae,Sp),t(Bt,$p),t(Bt,He),t(He,Jp),t(Bt,xp),c(n,ss,h),c(n,Rt,h),t(Rt,Ne),t(Ne,Bp),t(Ne,Ve),t(Ve,Rp),t(Rt,Up),t(Rt,Ge),t(Ge,Ce),t(Ce,Ip),t(Ge,Zp),t(Rt,Hp),t(Rt,Fe),t(Fe,We),t(We,Np),t(Fe,Vp),c(n,fs,h),c(n,je,h),t(je,Gp),c(n,ns,h),c(n,qe,h),t(qe,Le),c(n,is,h),c(n,Ut,h),t(Ut,Cp),t(Ut,Se),t(Se,Fp),t(Ut,Wp),t(Ut,$e),t($e,jp),t(Ut,qp),hs=!0},p:Gu,i(n){hs||(se(ie.$$.fragment,n),se(pe.$$.fragment,n),se(Ee.$$.fragment,n),se(De.$$.fragment,n),se(Me.$$.fragment,n),se(we.$$.fragment,n),se(Oe.$$.fragment,n),se(ke.$$.fragment,n),hs=!0)},o(n){fe(ie.$$.fragment,n),fe(pe.$$.fragment,n),fe(Ee.$$.fragment,n),fe(De.$$.fragment,n),fe(Me.$$.fragment,n),fe(we.$$.fragment,n),fe(Oe.$$.fragment,n),fe(ke.$$.fragment,n),hs=!1},d(n){e(Zt),n&&e(na),n&&e(Ht),ne(ie),n&&e(ia),n&&e(jt),n&&e(ha),n&&e(z),n&&e(ca),n&&e(Nt),ne(pe),n&&e(pa),n&&e($t),n&&e(Ta),ne(Ee,n),n&&e(Ea),n&&e(Ue),n&&e(ua),n&&e(v),n&&e(va),n&&e(Vt),ne(De),n&&e(_a),n&&e(St),n&&e(Da),ne(Me,n),n&&e(ma),n&&e(Xt),n&&e(Ma),n&&e(Gt),ne(we),n&&e(ba),n&&e(Qt),n&&e(ad),n&&e(Ze),n&&e(dd),n&&e(Ct),ne(Oe),n&&e(sd),n&&e(te),n&&e(ls),n&&e(Jt),n&&e(rs),n&&e(ee),n&&e(os),n&&e(Ft),ne(ke),n&&e(as),n&&e(xt),n&&e(ds),n&&e(Bt),n&&e(ss),n&&e(Rt),n&&e(fs),n&&e(je),n&&e(ns),n&&e(qe),n&&e(is),n&&e(Ut)}}}const Wu={local:"token-merging",sections:[{local:"using-tome",title:"Using ToMe"},{local:"benchmarking-tomesd-with-stablediffusionpipeline",sections:[{local:"a100",title:"A100"},{local:"v100",title:"V100"}],title:"Benchmarking `tomesd` with `StableDiffusionPipeline`"},{local:"quality",title:"Quality"}],title:"Token Merging"};function ju(zp){return Cu(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xu extends Iu{constructor(Zt){super();Zu(this,Zt,ju,Fu,Hu,{})}}export{Xu as default,Wu as metadata};
