import{s as ct,o as Tt,n as tt}from"../chunks/scheduler.8c3d61f6.js";import{S as wt,i as ft,g as f,s as c,r as u,A as mt,h as m,f as s,c as T,j as dt,u as h,x as J,k as rt,y as Jt,a as M,v as y,d as U,t as j,w as b}from"../chunks/index.589a98e8.js";import{C as x}from"../chunks/CodeBlock.36627b28.js";import{H as ot,E as ut}from"../chunks/EditOnGithub.e5a8d9cb.js";import{H as ht,a as O}from"../chunks/HfOption.9804ab8b.js";function yt(I){let l,w="Accelerate <code>PixArtAlphaPipeline</code> with T-GATE:",d,a,i;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwUGl4QXJ0QWxwaGFQaXBlbGluZSUwQWZyb20lMjB0Z2F0ZSUyMGltcG9ydCUyMFRnYXRlUGl4QXJ0TG9hZGVyJTBBJTBBcGlwZSUyMCUzRCUyMFBpeEFydEFscGhhUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMlBpeEFydC1hbHBoYSUyRlBpeEFydC1YTC0yLTEwMjQtTVMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBZ2F0ZV9zdGVwJTIwJTNEJTIwOCUwQWluZmVyZW5jZV9zdGVwJTIwJTNEJTIwMjUlMEFwaXBlJTIwJTNEJTIwVGdhdGVQaXhBcnRMb2FkZXIoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwcGlwZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUyQyUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUudGdhdGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyQW4lMjBhbHBhY2ElMjBtYWRlJTIwb2YlMjBjb2xvcmZ1bCUyMGJ1aWxkaW5nJTIwYmxvY2tzJTJDJTIwY3liZXJwdW5rLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> PixArtAlphaPipeline
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgatePixArtLoader

pipe = PixArtAlphaPipeline.from_pretrained(<span class="hljs-string">&quot;PixArt-alpha/PixArt-XL-2-1024-MS&quot;</span>, torch_dtype=torch.float16)

gate_step = <span class="hljs-number">8</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgatePixArtLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;An alpaca made of colorful building blocks, cyberpunk.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=f("p"),l.innerHTML=w,d=c(),u(a.$$.fragment)},l(e){l=m(e,"P",{"data-svelte-h":!0}),J(l)!=="svelte-10eb54u"&&(l.innerHTML=w),d=T(e),h(a.$$.fragment,e)},m(e,r){M(e,l,r),M(e,d,r),y(a,e,r),i=!0},p:tt,i(e){i||(U(a.$$.fragment,e),i=!0)},o(e){j(a.$$.fragment,e),i=!1},d(e){e&&(s(l),s(d)),b(a,e)}}}function Ut(I){let l,w="Accelerate <code>StableDiffusionXLPipeline</code> with T-GATE:",d,a,i;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9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BudW1faW5mZXJlbmNlX3N0ZXBzJTNEaW5mZXJlbmNlX3N0ZXAlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlLnRnYXRlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGsuJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwZ2F0ZV9zdGVwJTNEZ2F0ZV9zdGVwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRGluZmVyZW5jZV9zdGVwJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLLoader

pipe = StableDiffusionXLPipeline.from_pretrained(
            <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
            torch_dtype=torch.float16,
            variant=<span class="hljs-string">&quot;fp16&quot;</span>,
            use_safetensors=<span class="hljs-literal">True</span>,
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">10</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgateSDXLLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=f("p"),l.innerHTML=w,d=c(),u(a.$$.fragment)},l(e){l=m(e,"P",{"data-svelte-h":!0}),J(l)!=="svelte-iys01i"&&(l.innerHTML=w),d=T(e),h(a.$$.fragment,e)},m(e,r){M(e,l,r),M(e,d,r),y(a,e,r),i=!0},p:tt,i(e){i||(U(a.$$.fragment,e),i=!0)},o(e){j(a.$$.fragment,e),i=!1},d(e){e&&(s(l),s(d)),b(a,e)}}}function jt(I){let l,w='Accelerate <code>StableDiffusionXLPipeline</code> with <a href="https://github.com/horseee/DeepCache" rel="nofollow">DeepCache</a> and T-GATE:',d,a,i;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEFmcm9tJTIwdGdhdGUlMjBpbXBvcnQlMjBUZ2F0ZVNEWExEZWVwQ2FjaGVMb2FkZXIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTJDJTBBKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyklMEElMEFnYXRlX3N0ZXAlMjAlM0QlMjAxMCUwQWluZmVyZW5jZV9zdGVwJTIwJTNEJTIwMjUlMEFwaXBlJTIwJTNEJTIwVGdhdGVTRFhMRGVlcENhY2hlTG9hZGVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMHBpcGUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBjYWNoZV9pbnRlcnZhbCUzRDMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBjYWNoZV9icmFuY2hfaWQlM0QwJTJDJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLDeepCacheLoader

pipe = StableDiffusionXLPipeline.from_pretrained(
            <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
            torch_dtype=torch.float16,
            variant=<span class="hljs-string">&quot;fp16&quot;</span>,
            use_safetensors=<span class="hljs-literal">True</span>,
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">10</span>
inference_step = <span class="hljs-number">25</span>
pipe = TgateSDXLDeepCacheLoader(
       pipe,
       cache_interval=<span class="hljs-number">3</span>,
       cache_branch_id=<span class="hljs-number">0</span>,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=f("p"),l.innerHTML=w,d=c(),u(a.$$.fragment)},l(e){l=m(e,"P",{"data-svelte-h":!0}),J(l)!=="svelte-tcx4pu"&&(l.innerHTML=w),d=T(e),h(a.$$.fragment,e)},m(e,r){M(e,l,r),M(e,d,r),y(a,e,r),i=!0},p:tt,i(e){i||(U(a.$$.fragment,e),i=!0)},o(e){j(a.$$.fragment,e),i=!1},d(e){e&&(s(l),s(d)),b(a,e)}}}function bt(I){let l,w="Accelerate <code>latent-consistency/lcm-sdxl</code> with T-GATE:",d,a,i;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBVTmV0MkRDb25kaXRpb25Nb2RlbCUyQyUyMExDTVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEFmcm9tJTIwdGdhdGUlMjBpbXBvcn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lMjBsY20lM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLPipeline
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> UNet2DConditionModel, LCMScheduler
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler
<span class="hljs-keyword">from</span> tgate <span class="hljs-keyword">import</span> TgateSDXLLoader

unet = UNet2DConditionModel.from_pretrained(
    <span class="hljs-string">&quot;latent-consistency/lcm-sdxl&quot;</span>,
    torch_dtype=torch.float16,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipe = StableDiffusionXLPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    unet=unet,
    torch_dtype=torch.float16,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)

gate_step = <span class="hljs-number">1</span>
inference_step = <span class="hljs-number">4</span>
pipe = TgateSDXLLoader(
       pipe,
       gate_step=gate_step,
       num_inference_steps=inference_step,
       lcm=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe.tgate(
       <span class="hljs-string">&quot;Astronaut in a jungle, cold color palette, muted colors, detailed, 8k.&quot;</span>,
       gate_step=gate_step,
       num_inference_steps=inference_step
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){l=f("p"),l.innerHTML=w,d=c(),u(a.$$.fragment)},l(e){l=m(e,"P",{"data-svelte-h":!0}),J(l)!=="svelte-13iqzli"&&(l.innerHTML=w),d=T(e),h(a.$$.fragment,e)},m(e,r){M(e,l,r),M(e,d,r),y(a,e,r),i=!0},p:tt,i(e){i||(U(a.$$.fragment,e),i=!0)},o(e){j(a.$$.fragment,e),i=!1},d(e){e&&(s(l),s(d)),b(a,e)}}}function It(I){let l,w,d,a,i,e,r,G;return l=new O({props:{id:"pipelines",option:"PixArt",$$slots:{default:[yt]},$$scope:{ctx:I}}}),d=new O({props:{id:"pipelines",option:"Stable Diffusion XL",$$slots:{default:[Ut]},$$scope:{ctx:I}}}),i=new O({props:{id:"pipelines",option:"StableDiffusionXL with DeepCache",$$slots:{default:[jt]},$$scope:{ctx:I}}}),r=new O({props:{id:"pipelines",option:"Latent Consistency Model",$$slots:{default:[bt]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment),w=c(),u(d.$$.fragment),a=c(),u(i.$$.fragment),e=c(),u(r.$$.fragment)},l(n){h(l.$$.fragment,n),w=T(n),h(d.$$.fragment,n),a=T(n),h(i.$$.fragment,n),e=T(n),h(r.$$.fragment,n)},m(n,o){y(l,n,o),M(n,w,o),y(d,n,o),M(n,a,o),y(i,n,o),M(n,e,o),y(r,n,o),G=!0},p(n,o){const k={};o&2&&(k.$$scope={dirty:o,ctx:n}),l.$set(k);const B={};o&2&&(B.$$scope={dirty:o,ctx:n}),d.$set(B);const C={};o&2&&(C.$$scope={dirty:o,ctx:n}),i.$set(C);const A={};o&2&&(A.$$scope={dirty:o,ctx:n}),r.$set(A)},i(n){G||(U(l.$$.fragment,n),U(d.$$.fragment,n),U(i.$$.fragment,n),U(r.$$.fragment,n),G=!0)},o(n){j(l.$$.fragment,n),j(d.$$.fragment,n),j(i.$$.fragment,n),j(r.$$.fragment,n),G=!1},d(n){n&&(s(w),s(a),s(e)),b(l,n),b(d,n),b(i,n),b(r,n)}}}function Ct(I){let l,w,d,a,i,e,r,G='<a href="https://github.com/HaozheLiu-ST/T-GATE/tree/main" rel="nofollow">T-GATE</a> accelerates inference for <a href="../api/pipelines/stable_diffusion/overview">Stable Diffusion</a>, <a href="../api/pipelines/pixart">PixArt</a>, and <a href="../api/pipelines/latent_consistency_models.md">Latency Consistency Model</a> pipelines by skipping the cross-attention calculation once it converges. This method doesn’t require any additional training and it can speed up inference from 10-50%. T-GATE is also compatible with other optimization methods like <a href="./deepcache">DeepCache</a>.',n,o,k="Before you begin, make sure you install T-GATE.",B,C,A,V,et="To use T-GATE with a pipeline, you need to use its corresponding loader.",D,E,lt="<thead><tr><th>Pipeline</th> <th>T-GATE Loader</th></tr></thead> <tbody><tr><td>PixArt</td> <td>TgatePixArtLoader</td></tr> <tr><td>Stable Diffusion XL</td> <td>TgateSDXLLoader</td></tr> <tr><td>Stable Diffusion XL + DeepCache</td> <td>TgateSDXLDeepCacheLoader</td></tr> <tr><td>Stable Diffusion</td> <td>TgateSDLoader</td></tr> <tr><td>Stable Diffusion + DeepCache</td> <td>TgateSDDeepCacheLoader</td></tr></tbody>",Q,X,st="Next, create a <code>TgateLoader</code> with a pipeline, the gate step (the time step to stop calculating the cross attention), and the number of inference steps. Then call the <code>tgate</code> method on the pipeline with a prompt, gate step, and the number of inference steps.",Y,$,at="Let’s see how to enable this for several different pipelines.",N,Z,F,g,nt='T-GATE also supports <a href="/docs/diffusers/pr_8483/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> and <a href="https://hf.co/PixArt-alpha/PixArt-LCM-XL-2-1024-MS" rel="nofollow">PixArt-alpha/PixArt-LCM-XL-2-1024-MS</a>.',v,R,z,S,pt="<thead><tr><th>Model</th> <th>MACs</th> <th>Param</th> <th>Latency</th> <th>Zero-shot 10K-FID on MS-COCO</th></tr></thead> <tbody><tr><td>SD-1.5</td> <td>16.938T</td> <td>859.520M</td> <td>7.032s</td> <td>23.927</td></tr> <tr><td>SD-1.5 w/ T-GATE</td> <td>9.875T</td> <td>815.557M</td> <td>4.313s</td> <td>20.789</td></tr> <tr><td>SD-2.1</td> <td>38.041T</td> <td>865.785M</td> <td>16.121s</td> <td>22.609</td></tr> <tr><td>SD-2.1 w/ T-GATE</td> <td>22.208T</td> <td>815.433 M</td> <td>9.878s</td> <td>19.940</td></tr> <tr><td>SD-XL</td> <td>149.438T</td> <td>2.570B</td> <td>53.187s</td> <td>24.628</td></tr> <tr><td>SD-XL w/ T-GATE</td> <td>84.438T</td> <td>2.024B</td> <td>27.932s</td> <td>22.738</td></tr> <tr><td>Pixart-Alpha</td> <td>107.031T</td> <td>611.350M</td> <td>61.502s</td> <td>38.669</td></tr> <tr><td>Pixart-Alpha w/ T-GATE</td> <td>65.318T</td> <td>462.585M</td> <td>37.867s</td> <td>35.825</td></tr> <tr><td>DeepCache (SD-XL)</td> <td>57.888T</td> <td>-</td> <td>19.931s</td> <td>23.755</td></tr> <tr><td>DeepCache w/ T-GATE</td> <td>43.868T</td> <td>-</td> <td>14.666s</td> <td>23.999</td></tr> <tr><td>LCM (SD-XL)</td> <td>11.955T</td> <td>2.570B</td> <td>3.805s</td> <td>25.044</td></tr> <tr><td>LCM w/ T-GATE</td> <td>11.171T</td> <td>2.024B</td> <td>3.533s</td> <td>25.028</td></tr> <tr><td>LCM (Pixart-Alpha)</td> <td>8.563T</td> <td>611.350M</td> <td>4.733s</td> <td>36.086</td></tr> <tr><td>LCM w/ T-GATE</td> <td>7.623T</td> <td>462.585M</td> <td>4.543s</td> <td>37.048</td></tr></tbody>",P,W,Mt='The latency is tested on an NVIDIA 1080TI, MACs and Params are calculated with <a href="https://github.com/MrYxJ/calculate-flops.pytorch" rel="nofollow">calflops</a>, and the FID is calculated with <a href="https://github.com/mseitzer/pytorch-fid" rel="nofollow">PytorchFID</a>.',H,_,q,L,K;return i=new ot({props:{title:"T-GATE",local:"t-gate",headingTag:"h1"}}),C=new x({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRnYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC1VJTIwdG9yY2glMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBhY2NlbGVyYXRlJTIwRGVlcENhY2hl",highlighted:`pip install tgate
pip install -U torch diffusers transformers accelerate DeepCache`,wrap:!1}}),Z=new ht({props:{id:"pipelines",options:["PixArt","Stable Diffusion XL","StableDiffusionXL with DeepCache","Latent Consistency Model"],$$slots:{default:[It]},$$scope:{ctx:I}}}),R=new ot({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h2"}}),_=new ut({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/tgate.md"}}),{c(){l=f("meta"),w=c(),d=f("p"),a=c(),u(i.$$.fragment),e=c(),r=f("p"),r.innerHTML=G,n=c(),o=f("p"),o.textContent=k,B=c(),u(C.$$.fragment),A=c(),V=f("p"),V.textContent=et,D=c(),E=f("table"),E.innerHTML=lt,Q=c(),X=f("p"),X.innerHTML=st,Y=c(),$=f("p"),$.textContent=at,N=c(),u(Z.$$.fragment),F=c(),g=f("p"),g.innerHTML=nt,v=c(),u(R.$$.fragment),z=c(),S=f("table"),S.innerHTML=pt,P=c(),W=f("p"),W.innerHTML=Mt,H=c(),u(_.$$.fragment),q=c(),L=f("p"),this.h()},l(t){const p=mt("svelte-u9bgzb",document.head);l=m(p,"META",{name:!0,content:!0}),p.forEach(s),w=T(t),d=m(t,"P",{}),dt(d).forEach(s),a=T(t),h(i.$$.fragment,t),e=T(t),r=m(t,"P",{"data-svelte-h":!0}),J(r)!=="svelte-1qox7gi"&&(r.innerHTML=G),n=T(t),o=m(t,"P",{"data-svelte-h":!0}),J(o)!=="svelte-rx8j02"&&(o.textContent=k),B=T(t),h(C.$$.fragment,t),A=T(t),V=m(t,"P",{"data-svelte-h":!0}),J(V)!=="svelte-113mmog"&&(V.textContent=et),D=T(t),E=m(t,"TABLE",{"data-svelte-h":!0}),J(E)!=="svelte-17jk9ut"&&(E.innerHTML=lt),Q=T(t),X=m(t,"P",{"data-svelte-h":!0}),J(X)!=="svelte-1uere4x"&&(X.innerHTML=st),Y=T(t),$=m(t,"P",{"data-svelte-h":!0}),J($)!=="svelte-1tyd5nl"&&($.textContent=at),N=T(t),h(Z.$$.fragment,t),F=T(t),g=m(t,"P",{"data-svelte-h":!0}),J(g)!=="svelte-i681rl"&&(g.innerHTML=nt),v=T(t),h(R.$$.fragment,t),z=T(t),S=m(t,"TABLE",{"data-svelte-h":!0}),J(S)!=="svelte-7mhhwa"&&(S.innerHTML=pt),P=T(t),W=m(t,"P",{"data-svelte-h":!0}),J(W)!=="svelte-17hd8in"&&(W.innerHTML=Mt),H=T(t),h(_.$$.fragment,t),q=T(t),L=m(t,"P",{}),dt(L).forEach(s),this.h()},h(){rt(l,"name","hf:doc:metadata"),rt(l,"content",Zt)},m(t,p){Jt(document.head,l),M(t,w,p),M(t,d,p),M(t,a,p),y(i,t,p),M(t,e,p),M(t,r,p),M(t,n,p),M(t,o,p),M(t,B,p),y(C,t,p),M(t,A,p),M(t,V,p),M(t,D,p),M(t,E,p),M(t,Q,p),M(t,X,p),M(t,Y,p),M(t,$,p),M(t,N,p),y(Z,t,p),M(t,F,p),M(t,g,p),M(t,v,p),y(R,t,p),M(t,z,p),M(t,S,p),M(t,P,p),M(t,W,p),M(t,H,p),y(_,t,p),M(t,q,p),M(t,L,p),K=!0},p(t,[p]){const it={};p&2&&(it.$$scope={dirty:p,ctx:t}),Z.$set(it)},i(t){K||(U(i.$$.fragment,t),U(C.$$.fragment,t),U(Z.$$.fragment,t),U(R.$$.fragment,t),U(_.$$.fragment,t),K=!0)},o(t){j(i.$$.fragment,t),j(C.$$.fragment,t),j(Z.$$.fragment,t),j(R.$$.fragment,t),j(_.$$.fragment,t),K=!1},d(t){t&&(s(w),s(d),s(a),s(e),s(r),s(n),s(o),s(B),s(A),s(V),s(D),s(E),s(Q),s(X),s(Y),s($),s(N),s(F),s(g),s(v),s(z),s(S),s(P),s(W),s(H),s(q),s(L)),s(l),b(i,t),b(C,t),b(Z,t),b(R,t),b(_,t)}}}const Zt='{"title":"T-GATE","local":"t-gate","sections":[{"title":"Benchmarks","local":"benchmarks","sections":[],"depth":2}],"depth":1}';function Gt(I){return Tt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $t extends wt{constructor(l){super(),ft(this,l,Gt,Ct,ct,{})}}export{$t as component};
