import{s as he,n as we,o as ke}from"../chunks/scheduler.e4ff9b64.js";import{S as ye,i as xe,e as i,s as n,c as o,h as ge,a as p,d as l,b as a,f as Ue,g as M,j as c,k as Se,l as ve,m as s,n as d,t as f,o as r,p as T}from"../chunks/index.09f1bca0.js";import{C as Ae,H as pe,E as Je}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.2e1a29f5.js";import{C as ce}from"../chunks/CodeBlock.f899176c.js";function Qe(me){let m,H,B,L,j,z,u,P,$,oe="块依赖于<code>PipelineState</code>和<code>BlockState</code>数据结构进行通信和数据共享。",I,_,Me="<thead><tr><th>状态</th> <th>描述</th></tr></thead> <tbody><tr><td><code>PipelineState</code></td> <td>维护管道执行所需的整体数据，并允许块读取和更新其数据。</td></tr> <tr><td><code>BlockState</code></td> <td>允许每个块使用来自<code>inputs</code>的必要数据执行其计算</td></tr></tbody>",G,b,de="本指南解释了状态如何工作以及它们如何连接块。",Y,U,F,S,fe="<code>PipelineState</code>是所有块的全局状态容器。它维护管道的完整运行时状态，并为块提供了一种结构化的方式来读取和写入共享数据。",W,h,re="<code>PipelineState</code>中有两个字典用于结构化数据。",N,w,Te="<li><code>values</code>字典是一个<strong>可变</strong>状态，包含用户提供的输入值的副本和由块生成的中间输出值。如果一个块修改了一个<code>input</code>，它将在调用<code>set_block_state</code>后反映在<code>values</code>字典中。</li>",X,k,O,y,V,x,je="<code>BlockState</code>是<code>PipelineState</code>中相关变量的局部视图，单个块需要这些变量来执行其计算。",D,g,ue="直接作为属性访问这些变量，如<code>block_state.image</code>。",q,v,K,A,$e="当一个块的<code>__call__</code>方法被执行时，它用<code>self.get_block_state(state)</code>检索<code>BlockState</code>，执行其操作，并用<code>self.set_block_state(state, block_state)</code>更新<code>PipelineState</code>。",ee,J,te,Q,le,C,_e="<code>PipelineState</code>和<code>BlockState</code>的交互由块的<code>inputs</code>和<code>intermediate_outputs</code>定义。",se,E,be=`<li><code>inputs</code>,
一个块可以修改输入 - 比如 <code>block_state.image</code> - 并且这个改变可以通过调用 <code>set_block_state</code> 全局传播到 <code>PipelineState</code>。</li> <li><code>intermediate_outputs</code>，是一个块创建的新变量。它被添加到 <code>PipelineState</code> 的 <code>values</code> 字典中，并且可以作为后续块的可用变量，或者由用户作为管道的最终输出访问。</li>`,ne,R,ae,Z,ie;return j=new Ae({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new pe({props:{title:"状态",local:"状态",headingTag:"h1"}}),U=new pe({props:{title:"PipelineState",local:"pipelinestate",headingTag:"h2"}}),k=new ce({props:{code:"UGlwZWxpbmVTdGF0ZSglMEElMjAlMjB2YWx1ZXMlM0QlN0IlMEElMjAlMjAlMjAlMjAncHJvbXB0JyUzQSUyMCdhJTIwY2F0JyUwQSUyMCUyMCUyMCUyMCdndWlkYW5jZV9zY2FsZSclM0ElMjA3LjAlMEElMjAlMjAlMjAlMjAnbnVtX2luZmVyZW5jZV9zdGVwcyclM0ElMjAyNSUwQSUyMCUyMCUyMCUyMCdwcm9tcHRfZW1iZWRzJyUzQSUyMFRlbnNvcihkdHlwZSUzRHRvcmNoLmZsb2F0MzIlMkMlMjBzaGFwZSUzRHRvcmNoLlNpemUoJTVCMSUyQyUyMDElMkMlMjAxJTJDJTIwMSU1RCkpJTBBJTIwJTIwJTIwJTIwJ25lZ2F0aXZlX3Byb21wdF9lbWJlZHMnJTNBJTIwTm9uZSUwQSUyMCUyMCU3RCUyQyUwQSk=",highlighted:`PipelineState(
  values={
    <span class="hljs-string">&#x27;prompt&#x27;</span>: <span class="hljs-string">&#x27;a cat&#x27;</span>
    <span class="hljs-string">&#x27;guidance_scale&#x27;</span>: <span class="hljs-number">7.0</span>
    <span class="hljs-string">&#x27;num_inference_steps&#x27;</span>: <span class="hljs-number">25</span>
    <span class="hljs-string">&#x27;prompt_embeds&#x27;</span>: Tensor(dtype=torch.float32, shape=torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]))
    <span class="hljs-string">&#x27;negative_prompt_embeds&#x27;</span>: <span class="hljs-literal">None</span>
  },
)`,wrap:!1}}),y=new pe({props:{title:"BlockState",local:"blockstate",headingTag:"h2"}}),v=new ce({props:{code:"QmxvY2tTdGF0ZSglMEElMjAlMjAlMjAlMjBpbWFnZSUzQSUyMCUzQ1BJTC5JbWFnZS5JbWFnZSUyMGltYWdlJTIwbW9kZSUzRFJHQiUyMHNpemUlM0Q1MTJ4NTEyJTIwYXQlMjAweDdGM0VDQzQ5NDY0MCUzRSUwQSk=",highlighted:`BlockState(
    image: &lt;PIL.Image.Image image mode=RGB size=512x512 at <span class="hljs-number">0x7F3ECC494640</span>&gt;
)`,wrap:!1}}),J=new ce({props:{code:"ZGVmJTIwX19jYWxsX18oc2VsZiUyQyUyMGNvbXBvbmVudHMlMkMlMjBzdGF0ZSklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjAlRTYlQTMlODAlRTclQjQlQTJCbG9ja1N0YXRlJTBBJTIwJTIwJTIwJTIwYmxvY2tfc3RhdGUlMjAlM0QlMjBzZWxmLmdldF9ibG9ja19zdGF0ZShzdGF0ZSklMEElMEElMjAlMjAlMjAlMjAlMjMlMjAlRTUlQUYlQjklRTglQkUlOTMlRTUlODUlQTUlRTglQkYlOUIlRTglQTElOEMlRTglQUUlQTElRTclQUUlOTclRTclOUElODQlRTklODAlQkIlRTglQkUlOTElMEElMEElMjAlMjAlMjAlMjAlMjMlMjAlRTYlOUIlQjQlRTYlOTYlQjBQaXBlbGluZVN0YXRlJTBBJTIwJTIwJTIwJTIwc2VsZi5zZXRfYmxvY2tfc3RhdGUoc3RhdGUlMkMlMjBibG9ja19zdGF0ZSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBjb21wb25lbnRzJTJDJTIwc3RhdGU=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, components, state</span>):
    <span class="hljs-comment"># 检索BlockState</span>
    block_state = self.get_block_state(state)

    <span class="hljs-comment"># 对输入进行计算的逻辑</span>

    <span class="hljs-comment"># 更新PipelineState</span>
    self.set_block_state(state, block_state)
    <span class="hljs-keyword">return</span> components, state`,wrap:!1}}),Q=new pe({props:{title:"状态交互",local:"状态交互",headingTag:"h2"}}),R=new Je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/modular_diffusers/modular_diffusers_states.md"}}),{c(){m=i("meta"),H=n(),B=i("p"),L=n(),o(j.$$.fragment),z=n(),o(u.$$.fragment),P=n(),$=i("p"),$.innerHTML=oe,I=n(),_=i("table"),_.innerHTML=Me,G=n(),b=i("p"),b.textContent=de,Y=n(),o(U.$$.fragment),F=n(),S=i("p"),S.innerHTML=fe,W=n(),h=i("p"),h.innerHTML=re,N=n(),w=i("ul"),w.innerHTML=Te,X=n(),o(k.$$.fragment),O=n(),o(y.$$.fragment),V=n(),x=i("p"),x.innerHTML=je,D=n(),g=i("p"),g.innerHTML=ue,q=n(),o(v.$$.fragment),K=n(),A=i("p"),A.innerHTML=$e,ee=n(),o(J.$$.fragment),te=n(),o(Q.$$.fragment),le=n(),C=i("p"),C.innerHTML=_e,se=n(),E=i("ul"),E.innerHTML=be,ne=n(),o(R.$$.fragment),ae=n(),Z=i("p"),this.h()},l(e){const t=ge("svelte-u9bgzb",document.head);m=p(t,"META",{name:!0,content:!0}),t.forEach(l),H=a(e),B=p(e,"P",{}),Ue(B).forEach(l),L=a(e),M(j.$$.fragment,e),z=a(e),M(u.$$.fragment,e),P=a(e),$=p(e,"P",{"data-svelte-h":!0}),c($)!=="svelte-14qbh1a"&&($.innerHTML=oe),I=a(e),_=p(e,"TABLE",{"data-svelte-h":!0}),c(_)!=="svelte-1doqcsn"&&(_.innerHTML=Me),G=a(e),b=p(e,"P",{"data-svelte-h":!0}),c(b)!=="svelte-1ht9qr9"&&(b.textContent=de),Y=a(e),M(U.$$.fragment,e),F=a(e),S=p(e,"P",{"data-svelte-h":!0}),c(S)!=="svelte-m6yhz7"&&(S.innerHTML=fe),W=a(e),h=p(e,"P",{"data-svelte-h":!0}),c(h)!=="svelte-16dnrm6"&&(h.innerHTML=re),N=a(e),w=p(e,"UL",{"data-svelte-h":!0}),c(w)!=="svelte-1qfy6r7"&&(w.innerHTML=Te),X=a(e),M(k.$$.fragment,e),O=a(e),M(y.$$.fragment,e),V=a(e),x=p(e,"P",{"data-svelte-h":!0}),c(x)!=="svelte-1tytuyb"&&(x.innerHTML=je),D=a(e),g=p(e,"P",{"data-svelte-h":!0}),c(g)!=="svelte-rwb9z3"&&(g.innerHTML=ue),q=a(e),M(v.$$.fragment,e),K=a(e),A=p(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-10dg35y"&&(A.innerHTML=$e),ee=a(e),M(J.$$.fragment,e),te=a(e),M(Q.$$.fragment,e),le=a(e),C=p(e,"P",{"data-svelte-h":!0}),c(C)!=="svelte-1ke7ett"&&(C.innerHTML=_e),se=a(e),E=p(e,"UL",{"data-svelte-h":!0}),c(E)!=="svelte-n3zb5x"&&(E.innerHTML=be),ne=a(e),M(R.$$.fragment,e),ae=a(e),Z=p(e,"P",{}),Ue(Z).forEach(l),this.h()},h(){Se(m,"name","hf:doc:metadata"),Se(m,"content",Ce)},m(e,t){ve(document.head,m),s(e,H,t),s(e,B,t),s(e,L,t),d(j,e,t),s(e,z,t),d(u,e,t),s(e,P,t),s(e,$,t),s(e,I,t),s(e,_,t),s(e,G,t),s(e,b,t),s(e,Y,t),d(U,e,t),s(e,F,t),s(e,S,t),s(e,W,t),s(e,h,t),s(e,N,t),s(e,w,t),s(e,X,t),d(k,e,t),s(e,O,t),d(y,e,t),s(e,V,t),s(e,x,t),s(e,D,t),s(e,g,t),s(e,q,t),d(v,e,t),s(e,K,t),s(e,A,t),s(e,ee,t),d(J,e,t),s(e,te,t),d(Q,e,t),s(e,le,t),s(e,C,t),s(e,se,t),s(e,E,t),s(e,ne,t),d(R,e,t),s(e,ae,t),s(e,Z,t),ie=!0},p:we,i(e){ie||(f(j.$$.fragment,e),f(u.$$.fragment,e),f(U.$$.fragment,e),f(k.$$.fragment,e),f(y.$$.fragment,e),f(v.$$.fragment,e),f(J.$$.fragment,e),f(Q.$$.fragment,e),f(R.$$.fragment,e),ie=!0)},o(e){r(j.$$.fragment,e),r(u.$$.fragment,e),r(U.$$.fragment,e),r(k.$$.fragment,e),r(y.$$.fragment,e),r(v.$$.fragment,e),r(J.$$.fragment,e),r(Q.$$.fragment,e),r(R.$$.fragment,e),ie=!1},d(e){e&&(l(H),l(B),l(L),l(z),l(P),l($),l(I),l(_),l(G),l(b),l(Y),l(F),l(S),l(W),l(h),l(N),l(w),l(X),l(O),l(V),l(x),l(D),l(g),l(q),l(K),l(A),l(ee),l(te),l(le),l(C),l(se),l(E),l(ne),l(ae),l(Z)),l(m),T(j,e),T(u,e),T(U,e),T(k,e),T(y,e),T(v,e),T(J,e),T(Q,e),T(R,e)}}}const Ce='{"title":"状态","local":"状态","sections":[{"title":"PipelineState","local":"pipelinestate","sections":[],"depth":2},{"title":"BlockState","local":"blockstate","sections":[],"depth":2},{"title":"状态交互","local":"状态交互","sections":[],"depth":2}],"depth":1}';function Ee(me){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends ye{constructor(m){super(),xe(this,m,Ee,Qe,he,{})}}export{Le as component};
