import{s as wt,o as Jt,n as lt}from"../chunks/scheduler.e4ff9b64.js";import{S as ft,i as mt,e as J,s as T,c as m,h as yt,a as f,d as a,b as o,f as Tt,g as y,j as I,k as ot,l as ut,m as M,n as u,t as U,o as h,p as j}from"../chunks/index.09f1bca0.js";import{C as Ut,H as ct,E as ht}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.f48f387f.js";import{C as D}from"../chunks/CodeBlock.fad5d282.js";import{H as jt,a as et}from"../chunks/HfOption.44827c7f.js";function It(b){let l,c="使用 T-GATE 加速 <code>PixArtAlphaPipeline</code>：",i,n,d;return n=new D({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=c,i=T(),m(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),I(l)!=="svelte-4mgysz"&&(l.innerHTML=c),i=o(e),y(n.$$.fragment,e)},m(e,r){M(e,l,r),M(e,i,r),u(n,e,r),d=!0},p:lt,i(e){d||(U(n.$$.fragment,e),d=!0)},o(e){h(n.$$.fragment,e),d=!1},d(e){e&&(a(l),a(i)),j(n,e)}}}function bt(b){let l,c="使用 T-GATE 加速 <code>StableDiffusionXLPipeline</code>：",i,n,d;return n=new D({props:{code:"aW1wb3J0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MjAlMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEaW5mZXJlbmNlX3N0ZXAlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlLnRnYXRlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkFzdHJvbmF1dCUyMGluJTIwYSUyMGp1bmdsZSUyQyUyMGNvbGQlMjBjb2xvciUyMHBhbGV0dGUlMkMlMjBtdXRlZCUyMGNvbG9ycyUyQyUyMGRldGFpbGVkJTJDJTIwOGsuJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwZ2F0ZV9zdGVwJTNEZ2F0ZV9zdGVwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRGluZmVyZW5jZV9zdGVwJTBBKS5pbWFnZXMlNUIwJTVE",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=c,i=T(),m(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),I(l)!=="svelte-1r8lruj"&&(l.innerHTML=c),i=o(e),y(n.$$.fragment,e)},m(e,r){M(e,l,r),M(e,i,r),u(n,e,r),d=!0},p:lt,i(e){d||(U(n.$$.fragment,e),d=!0)},o(e){h(n.$$.fragment,e),d=!1},d(e){e&&(a(l),a(i)),j(n,e)}}}function Ct(b){let l,c=`使用 [DeepCache](<a href="https://github.co" rel="nofollow">https://github.co</a> 加速 <code>StableDiffusionXLPipeline</code>
m/horseee/DeepCache) 和 T-GATE：`,i,n,d;return n=new D({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=c,i=T(),m(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),I(l)!=="svelte-h6fosh"&&(l.innerHTML=c),i=o(e),y(n.$$.fragment,e)},m(e,r){M(e,l,r),M(e,i,r),u(n,e,r),d=!0},p:lt,i(e){d||(U(n.$$.fragment,e),d=!0)},o(e){h(n.$$.fragment,e),d=!1},d(e){e&&(a(l),a(i)),j(n,e)}}}function Zt(b){let l,c="使用 T-GATE 加速 <code>latent-consistency/lcm-sdxl</code>：",i,n,d;return n=new D({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBVTmV0MkRDb25kaXRpb25Nb2RlbCUyQyUyMExDTVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZ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N0ZXAlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjBsY20lM0RUcnVlJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZS50Z2F0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjBpbiUyMGElMjBqdW5nbGUlMkMlMjBjb2xkJTIwY29sb3IlMjBwYWxldHRlJTJDJTIwbXV0ZWQlMjBjb2xvcnMlMkMlMjBkZXRhaWxlZCUyQyUyMDhrLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMGdhdGVfc3RlcCUzRGdhdGVfc3RlcCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0RpbmZlcmVuY2Vfc3RlcCUwQSkuaW1hZ2VzJTVCMCU1RA==",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=c,i=T(),m(n.$$.fragment)},l(e){l=f(e,"P",{"data-svelte-h":!0}),I(l)!=="svelte-1gx1bcj"&&(l.innerHTML=c),i=o(e),y(n.$$.fragment,e)},m(e,r){M(e,l,r),M(e,i,r),u(n,e,r),d=!0},p:lt,i(e){d||(U(n.$$.fragment,e),d=!0)},o(e){h(n.$$.fragment,e),d=!1},d(e){e&&(a(l),a(i)),j(n,e)}}}function Gt(b){let l,c,i,n,d,e,r,Z;return l=new et({props:{id:"pipelines",option:"PixArt",$$slots:{default:[It]},$$scope:{ctx:b}}}),i=new et({props:{id:"pipelines",option:"Stable Diffusion XL",$$slots:{default:[bt]},$$scope:{ctx:b}}}),d=new et({props:{id:"pipelines",option:"StableDiffusionXL with DeepCache",$$slots:{default:[Ct]},$$scope:{ctx:b}}}),r=new et({props:{id:"pipelines",option:"Latent Consistency Model",$$slots:{default:[Zt]},$$scope:{ctx:b}}}),{c(){m(l.$$.fragment),c=T(),m(i.$$.fragment),n=T(),m(d.$$.fragment),e=T(),m(r.$$.fragment)},l(s){y(l.$$.fragment,s),c=o(s),y(i.$$.fragment,s),n=o(s),y(d.$$.fragment,s),e=o(s),y(r.$$.fragment,s)},m(s,w){u(l,s,w),M(s,c,w),u(i,s,w),M(s,n,w),u(d,s,w),M(s,e,w),u(r,s,w),Z=!0},p(s,w){const B={};w&2&&(B.$$scope={dirty:w,ctx:s}),l.$set(B);const C={};w&2&&(C.$$scope={dirty:w,ctx:s}),i.$set(C);const k={};w&2&&(k.$$scope={dirty:w,ctx:s}),d.$set(k);const $={};w&2&&($.$$scope={dirty:w,ctx:s}),r.$set($)},i(s){Z||(U(l.$$.fragment,s),U(i.$$.fragment,s),U(d.$$.fragment,s),U(r.$$.fragment,s),Z=!0)},o(s){h(l.$$.fragment,s),h(i.$$.fragment,s),h(d.$$.fragment,s),h(r.$$.fragment,s),Z=!1},d(s){s&&(a(c),a(n),a(e)),j(l,s),j(i,s),j(d,s),j(r,s)}}}function Bt(b){let l,c,i,n,d,e,r,Z,s,w='<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> 等其他优化方法兼容。',B,C,k="开始之前，请确保安装 T-GATE。",$,A,Q,V,st="要使用 T-GATE 与管道，您需要使用其对应的加载器。",Y,E,at="<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>",N,X,nt="接下来，创建一个 <code>TgateLoader</code>，包含管道、门限步骤（停止计算交叉注意力的时间步）和推理步骤数。然后在管道上调用 <code>tgate</code> 方法，提供提示、门限步骤和推理步骤数。",F,g,pt="让我们看看如何为几个不同的管道启用此功能。",v,G,z,R,Mt='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>。',H,S,P,W,dt="<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>",q,_,it='延迟测试基于 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> 计算。',K,L,O,x,tt;return d=new Ut({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),r=new ct({props:{title:"T-GATE",local:"t-gate",headingTag:"h1"}}),A=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRnYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC1VJTIwdG9yY2glMjBkaWZmdXNlcnMlMjB0cmFuc2Zvcm1lcnMlMjBhY2NlbGVyYXRlJTIwRGVlcENhY2hl",highlighted:`pip install tgate
pip install -U torch diffusers transformers accelerate DeepCache`,wrap:!1}}),G=new jt({props:{id:"pipelines",options:["PixArt","Stable Diffusion XL","StableDiffusionXL with DeepCache","Latent Consistency Model"],$$slots:{default:[Gt]},$$scope:{ctx:b}}}),S=new ct({props:{title:"基准测试",local:"基准测试",headingTag:"h2"}}),L=new ht({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/optimization/tgate.md"}}),{c(){l=J("meta"),c=T(),i=J("p"),n=T(),m(d.$$.fragment),e=T(),m(r.$$.fragment),Z=T(),s=J("p"),s.innerHTML=w,B=T(),C=J("p"),C.textContent=k,$=T(),m(A.$$.fragment),Q=T(),V=J("p"),V.textContent=st,Y=T(),E=J("table"),E.innerHTML=at,N=T(),X=J("p"),X.innerHTML=nt,F=T(),g=J("p"),g.textContent=pt,v=T(),m(G.$$.fragment),z=T(),R=J("p"),R.innerHTML=Mt,H=T(),m(S.$$.fragment),P=T(),W=J("table"),W.innerHTML=dt,q=T(),_=J("p"),_.innerHTML=it,K=T(),m(L.$$.fragment),O=T(),x=J("p"),this.h()},l(t){const p=yt("svelte-u9bgzb",document.head);l=f(p,"META",{name:!0,content:!0}),p.forEach(a),c=o(t),i=f(t,"P",{}),Tt(i).forEach(a),n=o(t),y(d.$$.fragment,t),e=o(t),y(r.$$.fragment,t),Z=o(t),s=f(t,"P",{"data-svelte-h":!0}),I(s)!=="svelte-stt6jb"&&(s.innerHTML=w),B=o(t),C=f(t,"P",{"data-svelte-h":!0}),I(C)!=="svelte-dy0t0v"&&(C.textContent=k),$=o(t),y(A.$$.fragment,t),Q=o(t),V=f(t,"P",{"data-svelte-h":!0}),I(V)!=="svelte-wrf6f2"&&(V.textContent=st),Y=o(t),E=f(t,"TABLE",{"data-svelte-h":!0}),I(E)!=="svelte-mjnwbx"&&(E.innerHTML=at),N=o(t),X=f(t,"P",{"data-svelte-h":!0}),I(X)!=="svelte-a22hn6"&&(X.innerHTML=nt),F=o(t),g=f(t,"P",{"data-svelte-h":!0}),I(g)!=="svelte-4logtv"&&(g.textContent=pt),v=o(t),y(G.$$.fragment,t),z=o(t),R=f(t,"P",{"data-svelte-h":!0}),I(R)!=="svelte-1yo3bdu"&&(R.innerHTML=Mt),H=o(t),y(S.$$.fragment,t),P=o(t),W=f(t,"TABLE",{"data-svelte-h":!0}),I(W)!=="svelte-1rxtbsl"&&(W.innerHTML=dt),q=o(t),_=f(t,"P",{"data-svelte-h":!0}),I(_)!=="svelte-16r9eh7"&&(_.innerHTML=it),K=o(t),y(L.$$.fragment,t),O=o(t),x=f(t,"P",{}),Tt(x).forEach(a),this.h()},h(){ot(l,"name","hf:doc:metadata"),ot(l,"content",$t)},m(t,p){ut(document.head,l),M(t,c,p),M(t,i,p),M(t,n,p),u(d,t,p),M(t,e,p),u(r,t,p),M(t,Z,p),M(t,s,p),M(t,B,p),M(t,C,p),M(t,$,p),u(A,t,p),M(t,Q,p),M(t,V,p),M(t,Y,p),M(t,E,p),M(t,N,p),M(t,X,p),M(t,F,p),M(t,g,p),M(t,v,p),u(G,t,p),M(t,z,p),M(t,R,p),M(t,H,p),u(S,t,p),M(t,P,p),M(t,W,p),M(t,q,p),M(t,_,p),M(t,K,p),u(L,t,p),M(t,O,p),M(t,x,p),tt=!0},p(t,[p]){const rt={};p&2&&(rt.$$scope={dirty:p,ctx:t}),G.$set(rt)},i(t){tt||(U(d.$$.fragment,t),U(r.$$.fragment,t),U(A.$$.fragment,t),U(G.$$.fragment,t),U(S.$$.fragment,t),U(L.$$.fragment,t),tt=!0)},o(t){h(d.$$.fragment,t),h(r.$$.fragment,t),h(A.$$.fragment,t),h(G.$$.fragment,t),h(S.$$.fragment,t),h(L.$$.fragment,t),tt=!1},d(t){t&&(a(c),a(i),a(n),a(e),a(Z),a(s),a(B),a(C),a($),a(Q),a(V),a(Y),a(E),a(N),a(X),a(F),a(g),a(v),a(z),a(R),a(H),a(P),a(W),a(q),a(_),a(K),a(O),a(x)),a(l),j(d,t),j(r,t),j(A,t),j(G,t),j(S,t),j(L,t)}}}const $t='{"title":"T-GATE","local":"t-gate","sections":[{"title":"基准测试","local":"基准测试","sections":[],"depth":2}],"depth":1}';function At(b){return Jt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class St extends ft{constructor(l){super(),mt(this,l,At,Bt,wt,{})}}export{St as component};
