import{s as X,o as Z,n as W}from"../chunks/scheduler.5c93273d.js";import{S as K,i as N,g as $,s as i,r as T,A as Q,h as c,f as n,c as m,j as I,u as v,x as C,k as O,y as V,a as o,v as P,d as H,t as M,w as L}from"../chunks/index.e43dd92b.js";import{T as R}from"../chunks/Tip.1cbfe904.js";import{C as Y}from"../chunks/CodeBlock.6896320e.js";import{H as ee,E as te}from"../chunks/getInferenceSnippets.d410b42d.js";function se(w){let s,a='xFormers的<code>pip</code>安装包需要最新版本的PyTorch。如需使用旧版PyTorch，建议<a href="https://github.com/facebookresearch/xformers#installing-xformers" rel="nofollow">从源码安装xFormers</a>。';return{c(){s=$("p"),s.innerHTML=a},l(r){s=c(r,"P",{"data-svelte-h":!0}),C(s)!=="svelte-1889ig1"&&(s.innerHTML=a)},m(r,f){o(r,s,f)},p:W,d(r){r&&n(s)}}}function ne(w){let s,a='根据<a href="https://github.com/huggingface/diffusers/issues/2234#issuecomment-1416931212" rel="nofollow">此问题</a>反馈，xFormers <code>v0.0.16</code>版本在某些GPU上无法用于训练（微调或DreamBooth）。如遇此问题，请按照该issue评论区指引安装开发版本。';return{c(){s=$("p"),s.innerHTML=a},l(r){s=c(r,"P",{"data-svelte-h":!0}),C(s)!=="svelte-15e6nbw"&&(s.innerHTML=a)},m(r,f){o(r,s,f)},p:W,d(r){r&&n(s)}}}function re(w){let s,a,r,f,u,F,h,q='我们推荐在推理和训练过程中使用<a href="https://github.com/facebookresearch/xformers" rel="nofollow">xFormers</a>。在我们的测试中，其对注意力模块的优化能同时提升运行速度并降低内存消耗。',y,_,A="通过<code>pip</code>安装xFormers：",k,d,z,l,E,x,B='安装完成后，您可调用<code>enable_xformers_memory_efficient_attention()</code>来实现更快的推理速度和更低的内存占用，具体用法参见<a href="memory#memory-efficient-attention">此章节</a>。',G,p,J,g,S,b,U;return u=new ee({props:{title:"xFormers",local:"xformers",headingTag:"h1"}}),d=new Y({props:{code:"cGlwJTIwaW5zdGFsbCUyMHhmb3JtZXJz",highlighted:"pip install xformers",wrap:!1}}),l=new R({props:{$$slots:{default:[se]},$$scope:{ctx:w}}}),p=new R({props:{warning:!0,$$slots:{default:[ne]},$$scope:{ctx:w}}}),g=new te({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/optimization/xformers.md"}}),{c(){s=$("meta"),a=i(),r=$("p"),f=i(),T(u.$$.fragment),F=i(),h=$("p"),h.innerHTML=q,y=i(),_=$("p"),_.innerHTML=A,k=i(),T(d.$$.fragment),z=i(),T(l.$$.fragment),E=i(),x=$("p"),x.innerHTML=B,G=i(),T(p.$$.fragment),J=i(),T(g.$$.fragment),S=i(),b=$("p"),this.h()},l(e){const t=Q("svelte-u9bgzb",document.head);s=c(t,"META",{name:!0,content:!0}),t.forEach(n),a=m(e),r=c(e,"P",{}),I(r).forEach(n),f=m(e),v(u.$$.fragment,e),F=m(e),h=c(e,"P",{"data-svelte-h":!0}),C(h)!=="svelte-1k8d7zl"&&(h.innerHTML=q),y=m(e),_=c(e,"P",{"data-svelte-h":!0}),C(_)!=="svelte-oxf3ff"&&(_.innerHTML=A),k=m(e),v(d.$$.fragment,e),z=m(e),v(l.$$.fragment,e),E=m(e),x=c(e,"P",{"data-svelte-h":!0}),C(x)!=="svelte-1x5mssq"&&(x.innerHTML=B),G=m(e),v(p.$$.fragment,e),J=m(e),v(g.$$.fragment,e),S=m(e),b=c(e,"P",{}),I(b).forEach(n),this.h()},h(){O(s,"name","hf:doc:metadata"),O(s,"content",oe)},m(e,t){V(document.head,s),o(e,a,t),o(e,r,t),o(e,f,t),P(u,e,t),o(e,F,t),o(e,h,t),o(e,y,t),o(e,_,t),o(e,k,t),P(d,e,t),o(e,z,t),P(l,e,t),o(e,E,t),o(e,x,t),o(e,G,t),P(p,e,t),o(e,J,t),P(g,e,t),o(e,S,t),o(e,b,t),U=!0},p(e,[t]){const j={};t&2&&(j.$$scope={dirty:t,ctx:e}),l.$set(j);const D={};t&2&&(D.$$scope={dirty:t,ctx:e}),p.$set(D)},i(e){U||(H(u.$$.fragment,e),H(d.$$.fragment,e),H(l.$$.fragment,e),H(p.$$.fragment,e),H(g.$$.fragment,e),U=!0)},o(e){M(u.$$.fragment,e),M(d.$$.fragment,e),M(l.$$.fragment,e),M(p.$$.fragment,e),M(g.$$.fragment,e),U=!1},d(e){e&&(n(a),n(r),n(f),n(F),n(h),n(y),n(_),n(k),n(z),n(E),n(x),n(G),n(J),n(S),n(b)),n(s),L(u,e),L(d,e),L(l,e),L(p,e),L(g,e)}}}const oe='{"title":"xFormers","local":"xformers","sections":[],"depth":1}';function ae(w){return Z(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $e extends K{constructor(s){super(),N(this,s,ae,re,X,{})}}export{$e as component};
