import{s as ct,o as ot,n as tt}from"../chunks/scheduler.5c93273d.js";import{S as wt,i as Jt,g as J,s as c,r as y,A as ft,h as f,f as s,c as o,j as it,u,x as m,k as rt,y as mt,a as p,v as h,d as U,t as j,w as I}from"../chunks/index.e43dd92b.js";import{C as x}from"../chunks/CodeBlock.6896320e.js";import{H as Tt,E as yt}from"../chunks/getInferenceSnippets.bd93e167.js";import{H as ut,a as O}from"../chunks/HfOption.d50154c3.js";function ht(b){let l,w="使用 T-GATE 加速 <code>PixArtAlphaPipeline</code>：",i,a,d;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=J("p"),l.innerHTML=w,i=c(),y(a.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),m(l)!=="svelte-4mgysz"&&(l.innerHTML=w),i=o(e),u(a.$$.fragment,e)},m(e,r){p(e,l,r),p(e,i,r),h(a,e,r),d=!0},p:tt,i(e){d||(U(a.$$.fragment,e),d=!0)},o(e){j(a.$$.fragment,e),d=!1},d(e){e&&(s(l),s(i)),I(a,e)}}}function Ut(b){let l,w="使用 T-GATE 加速 <code>StableDiffusionXLPipeline</code>：",i,a,d;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTI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faW5mZXJlbmNlX3N0ZXBzJTNEaW5mZXJlbmNlX3N0ZXAlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlLnRnYXRlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGsuJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwZ2F0ZV9zdGVwJTNEZ2F0ZV9zdGVwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRGluZmVyZW5jZV9zdGVwJTBBKS5pbWFnZXMlNUIwJTVE",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=J("p"),l.innerHTML=w,i=c(),y(a.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),m(l)!=="svelte-1r8lruj"&&(l.innerHTML=w),i=o(e),u(a.$$.fragment,e)},m(e,r){p(e,l,r),p(e,i,r),h(a,e,r),d=!0},p:tt,i(e){d||(U(a.$$.fragment,e),d=!0)},o(e){j(a.$$.fragment,e),d=!1},d(e){e&&(s(l),s(i)),I(a,e)}}}function jt(b){let l,w=`使用 [DeepCache](<a href="https://github.co" rel="nofollow">https://github.co</a> 加速 <code>StableDiffusionXLPipeline</code>
m/horseee/DeepCache) 和 T-GATE：`,i,a,d;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=J("p"),l.innerHTML=w,i=c(),y(a.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),m(l)!=="svelte-h6fosh"&&(l.innerHTML=w),i=o(e),u(a.$$.fragment,e)},m(e,r){p(e,l,r),p(e,i,r),h(a,e,r),d=!0},p:tt,i(e){d||(U(a.$$.fragment,e),d=!0)},o(e){j(a.$$.fragment,e),d=!1},d(e){e&&(s(l),s(i)),I(a,e)}}}function It(b){let l,w="使用 T-GATE 加速 <code>latent-consistency/lcm-sdxl</code>：",i,a,d;return a=new x({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBVTmV0MkRDb25kaXRpb25Nb2RlbCUyQyUyMExDTVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEFmcm9tJTIwdGdhdG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lMjAlMjAlMjAlMjBsY20lM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",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=J("p"),l.innerHTML=w,i=c(),y(a.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),m(l)!=="svelte-1gx1bcj"&&(l.innerHTML=w),i=o(e),u(a.$$.fragment,e)},m(e,r){p(e,l,r),p(e,i,r),h(a,e,r),d=!0},p:tt,i(e){d||(U(a.$$.fragment,e),d=!0)},o(e){j(a.$$.fragment,e),d=!1},d(e){e&&(s(l),s(i)),I(a,e)}}}function bt(b){let l,w,i,a,d,e,r,G;return l=new O({props:{id:"pipelines",option:"PixArt",$$slots:{default:[ht]},$$scope:{ctx:b}}}),i=new O({props:{id:"pipelines",option:"Stable Diffusion XL",$$slots:{default:[Ut]},$$scope:{ctx:b}}}),d=new O({props:{id:"pipelines",option:"StableDiffusionXL with DeepCache",$$slots:{default:[jt]},$$scope:{ctx:b}}}),r=new O({props:{id:"pipelines",option:"Latent Consistency Model",$$slots:{default:[It]},$$scope:{ctx:b}}}),{c(){y(l.$$.fragment),w=c(),y(i.$$.fragment),a=c(),y(d.$$.fragment),e=c(),y(r.$$.fragment)},l(n){u(l.$$.fragment,n),w=o(n),u(i.$$.fragment,n),a=o(n),u(d.$$.fragment,n),e=o(n),u(r.$$.fragment,n)},m(n,T){h(l,n,T),p(n,w,T),h(i,n,T),p(n,a,T),h(d,n,T),p(n,e,T),h(r,n,T),G=!0},p(n,T){const L={};T&2&&(L.$$scope={dirty:T,ctx:n}),l.$set(L);const B={};T&2&&(B.$$scope={dirty:T,ctx:n}),i.$set(B);const C={};T&2&&(C.$$scope={dirty:T,ctx:n}),d.$set(C);const A={};T&2&&(A.$$scope={dirty:T,ctx:n}),r.$set(A)},i(n){G||(U(l.$$.fragment,n),U(i.$$.fragment,n),U(d.$$.fragment,n),U(r.$$.fragment,n),G=!0)},o(n){j(l.$$.fragment,n),j(i.$$.fragment,n),j(d.$$.fragment,n),j(r.$$.fragment,n),G=!1},d(n){n&&(s(w),s(a),s(e)),I(l,n),I(i,n),I(d,n),I(r,n)}}}function Ct(b){let l,w,i,a,d,e,r,G='<a href="https://github.com/HaozheLiu-ST/T-GATE/tree/main" rel="nofollow">T-GATE</a> 通过跳过交叉注意力计算一旦收敛，加速了 <a href="../api/pipelines/stable_diffusion/overview">Stable Diffusion</a>、<a href="../api/pipelines/pixart">PixArt</a> 和 <a href="../api/pipelines/latent_consistency_models.md">Latency Consistency Model</a> 管道的推理。此方法不需要任何额外训练，可以将推理速度提高 10-50%。T-GATE 还与 <a href="./deepcache">DeepCache</a> 等其他优化方法兼容。',n,T,L="开始之前，请确保安装 T-GATE。",B,C,A,V,et="要使用 T-GATE 与管道，您需要使用其对应的加载器。",D,E,lt="<thead><tr><th>管道</th> <th>T-GATE 加载器</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="接下来，创建一个 <code>TgateLoader</code>，包含管道、门限步骤（停止计算交叉注意力的时间步）和推理步骤数。然后在管道上调用 <code>tgate</code> 方法，提供提示、门限步骤和推理步骤数。",Y,$,at="让我们看看如何为几个不同的管道启用此功能。",N,Z,F,g,nt='T-GATE 还支持 <code>StableDiffusionPipeline</code> 和 <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,W,Mt="<thead><tr><th>模型</th> <th>MACs</th> <th>参数</th> <th>延迟</th> <th>零样本 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 配合 T-GATE</td> <td>43.868T</td> <td>-</td> <td>14.666秒</td> <td>23.999</td></tr> <tr><td>LCM (SD-XL)</td> <td>11.955T</td> <td>2.570B</td> <td>3.805秒</td> <td>25.044</td></tr> <tr><td>LCM 配合 T-GATE</td> <td>11.171T</td> <td>2.024B</td> <td>3.533秒</td> <td>25.028</td></tr> <tr><td>LCM (Pixart-Alpha)</td> <td>8.563T</td> <td>611.350M</td> <td>4.733秒</td> <td>36.086</td></tr> <tr><td>LCM 配合 T-GATE</td> <td>7.623T</td> <td>462.585M</td> <td>4.543秒</td> <td>37.048</td></tr></tbody>",H,S,pt='延迟测试基于 NVIDIA 1080TI，MACs 和 Params 使用 <a href="https://github.com/MrYxJ/calculate-flops.pytorch" rel="nofollow">calflops</a> 计算，FID 使用 <a href="https://github.com/mseitzer/pytorch-fid" rel="nofollow">PytorchFID</a> 计算。',P,_,q,k,K;return d=new Tt({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 ut({props:{id:"pipelines",options:["PixArt","Stable Diffusion XL","StableDiffusionXL with DeepCache","Latent Consistency Model"],$$slots:{default:[bt]},$$scope:{ctx:b}}}),R=new Tt({props:{title:"基准测试",local:"基准测试",headingTag:"h2"}}),_=new yt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/optimization/tgate.md"}}),{c(){l=J("meta"),w=c(),i=J("p"),a=c(),y(d.$$.fragment),e=c(),r=J("p"),r.innerHTML=G,n=c(),T=J("p"),T.textContent=L,B=c(),y(C.$$.fragment),A=c(),V=J("p"),V.textContent=et,D=c(),E=J("table"),E.innerHTML=lt,Q=c(),X=J("p"),X.innerHTML=st,Y=c(),$=J("p"),$.textContent=at,N=c(),y(Z.$$.fragment),F=c(),g=J("p"),g.innerHTML=nt,v=c(),y(R.$$.fragment),z=c(),W=J("table"),W.innerHTML=Mt,H=c(),S=J("p"),S.innerHTML=pt,P=c(),y(_.$$.fragment),q=c(),k=J("p"),this.h()},l(t){const M=ft("svelte-u9bgzb",document.head);l=f(M,"META",{name:!0,content:!0}),M.forEach(s),w=o(t),i=f(t,"P",{}),it(i).forEach(s),a=o(t),u(d.$$.fragment,t),e=o(t),r=f(t,"P",{"data-svelte-h":!0}),m(r)!=="svelte-stt6jb"&&(r.innerHTML=G),n=o(t),T=f(t,"P",{"data-svelte-h":!0}),m(T)!=="svelte-dy0t0v"&&(T.textContent=L),B=o(t),u(C.$$.fragment,t),A=o(t),V=f(t,"P",{"data-svelte-h":!0}),m(V)!=="svelte-wrf6f2"&&(V.textContent=et),D=o(t),E=f(t,"TABLE",{"data-svelte-h":!0}),m(E)!=="svelte-mjnwbx"&&(E.innerHTML=lt),Q=o(t),X=f(t,"P",{"data-svelte-h":!0}),m(X)!=="svelte-a22hn6"&&(X.innerHTML=st),Y=o(t),$=f(t,"P",{"data-svelte-h":!0}),m($)!=="svelte-4logtv"&&($.textContent=at),N=o(t),u(Z.$$.fragment,t),F=o(t),g=f(t,"P",{"data-svelte-h":!0}),m(g)!=="svelte-1yo3bdu"&&(g.innerHTML=nt),v=o(t),u(R.$$.fragment,t),z=o(t),W=f(t,"TABLE",{"data-svelte-h":!0}),m(W)!=="svelte-1rxtbsl"&&(W.innerHTML=Mt),H=o(t),S=f(t,"P",{"data-svelte-h":!0}),m(S)!=="svelte-16r9eh7"&&(S.innerHTML=pt),P=o(t),u(_.$$.fragment,t),q=o(t),k=f(t,"P",{}),it(k).forEach(s),this.h()},h(){rt(l,"name","hf:doc:metadata"),rt(l,"content",Zt)},m(t,M){mt(document.head,l),p(t,w,M),p(t,i,M),p(t,a,M),h(d,t,M),p(t,e,M),p(t,r,M),p(t,n,M),p(t,T,M),p(t,B,M),h(C,t,M),p(t,A,M),p(t,V,M),p(t,D,M),p(t,E,M),p(t,Q,M),p(t,X,M),p(t,Y,M),p(t,$,M),p(t,N,M),h(Z,t,M),p(t,F,M),p(t,g,M),p(t,v,M),h(R,t,M),p(t,z,M),p(t,W,M),p(t,H,M),p(t,S,M),p(t,P,M),h(_,t,M),p(t,q,M),p(t,k,M),K=!0},p(t,[M]){const dt={};M&2&&(dt.$$scope={dirty:M,ctx:t}),Z.$set(dt)},i(t){K||(U(d.$$.fragment,t),U(C.$$.fragment,t),U(Z.$$.fragment,t),U(R.$$.fragment,t),U(_.$$.fragment,t),K=!0)},o(t){j(d.$$.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(i),s(a),s(e),s(r),s(n),s(T),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(W),s(H),s(S),s(P),s(q),s(k)),s(l),I(d,t),I(C,t),I(Z,t),I(R,t),I(_,t)}}}const Zt='{"title":"T-GATE","local":"t-gate","sections":[{"title":"基准测试","local":"基准测试","sections":[],"depth":2}],"depth":1}';function Gt(b){return ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $t extends wt{constructor(l){super(),Jt(this,l,Gt,Ct,ct,{})}}export{$t as component};
