import{s as Ue,n as he,o as Se}from"../chunks/scheduler.5c93273d.js";import{S as we,i as ke,g as i,s as a,r as M,A as ye,h as p,f as l,c as n,j as _e,u as d,x as c,k as be,y as Ae,a as s,v as m,d as r,t as f,w as T}from"../chunks/index.e43dd92b.js";import{C as ie}from"../chunks/CodeBlock.6896320e.js";import{H as ne,E as ge}from"../chunks/getInferenceSnippets.bd93e167.js";function ve(pe){let o,Z,R,H,j,L,u,ce="块依赖于<code>PipelineState</code>和<code>BlockState</code>数据结构进行通信和数据共享。",z,$,oe="<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>",P,_,Me="本指南解释了状态如何工作以及它们如何连接块。",I,b,G,U,de="<code>PipelineState</code>是所有块的全局状态容器。它维护管道的完整运行时状态，并为块提供了一种结构化的方式来读取和写入共享数据。",Y,h,me="<code>PipelineState</code>中有两个字典用于结构化数据。",F,S,re="<li><code>values</code>字典是一个<strong>可变</strong>状态，包含用户提供的输入值的副本和由块生成的中间输出值。如果一个块修改了一个<code>input</code>，它将在调用<code>set_block_state</code>后反映在<code>values</code>字典中。</li>",W,w,N,k,X,y,fe="<code>BlockState</code>是<code>PipelineState</code>中相关变量的局部视图，单个块需要这些变量来执行其计算。",O,A,Te="直接作为属性访问这些变量，如<code>block_state.image</code>。",V,g,D,v,je="当一个块的<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>。",q,x,K,J,ee,Q,ue="<code>PipelineState</code>和<code>BlockState</code>的交互由块的<code>inputs</code>和<code>intermediate_outputs</code>定义。",te,E,$e=`<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>`,le,C,se,B,ae;return j=new ne({props:{title:"状态",local:"状态",headingTag:"h1"}}),b=new ne({props:{title:"PipelineState",local:"pipelinestate",headingTag:"h2"}}),w=new ie({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}}),k=new ne({props:{title:"BlockState",local:"blockstate",headingTag:"h2"}}),g=new ie({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}}),x=new ie({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}}),J=new ne({props:{title:"状态交互",local:"状态交互",headingTag:"h2"}}),C=new ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/modular_diffusers/modular_diffusers_states.md"}}),{c(){o=i("meta"),Z=a(),R=i("p"),H=a(),M(j.$$.fragment),L=a(),u=i("p"),u.innerHTML=ce,z=a(),$=i("table"),$.innerHTML=oe,P=a(),_=i("p"),_.textContent=Me,I=a(),M(b.$$.fragment),G=a(),U=i("p"),U.innerHTML=de,Y=a(),h=i("p"),h.innerHTML=me,F=a(),S=i("ul"),S.innerHTML=re,W=a(),M(w.$$.fragment),N=a(),M(k.$$.fragment),X=a(),y=i("p"),y.innerHTML=fe,O=a(),A=i("p"),A.innerHTML=Te,V=a(),M(g.$$.fragment),D=a(),v=i("p"),v.innerHTML=je,q=a(),M(x.$$.fragment),K=a(),M(J.$$.fragment),ee=a(),Q=i("p"),Q.innerHTML=ue,te=a(),E=i("ul"),E.innerHTML=$e,le=a(),M(C.$$.fragment),se=a(),B=i("p"),this.h()},l(e){const t=ye("svelte-u9bgzb",document.head);o=p(t,"META",{name:!0,content:!0}),t.forEach(l),Z=n(e),R=p(e,"P",{}),_e(R).forEach(l),H=n(e),d(j.$$.fragment,e),L=n(e),u=p(e,"P",{"data-svelte-h":!0}),c(u)!=="svelte-14qbh1a"&&(u.innerHTML=ce),z=n(e),$=p(e,"TABLE",{"data-svelte-h":!0}),c($)!=="svelte-1doqcsn"&&($.innerHTML=oe),P=n(e),_=p(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-1ht9qr9"&&(_.textContent=Me),I=n(e),d(b.$$.fragment,e),G=n(e),U=p(e,"P",{"data-svelte-h":!0}),c(U)!=="svelte-m6yhz7"&&(U.innerHTML=de),Y=n(e),h=p(e,"P",{"data-svelte-h":!0}),c(h)!=="svelte-16dnrm6"&&(h.innerHTML=me),F=n(e),S=p(e,"UL",{"data-svelte-h":!0}),c(S)!=="svelte-1qfy6r7"&&(S.innerHTML=re),W=n(e),d(w.$$.fragment,e),N=n(e),d(k.$$.fragment,e),X=n(e),y=p(e,"P",{"data-svelte-h":!0}),c(y)!=="svelte-1tytuyb"&&(y.innerHTML=fe),O=n(e),A=p(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-rwb9z3"&&(A.innerHTML=Te),V=n(e),d(g.$$.fragment,e),D=n(e),v=p(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-10dg35y"&&(v.innerHTML=je),q=n(e),d(x.$$.fragment,e),K=n(e),d(J.$$.fragment,e),ee=n(e),Q=p(e,"P",{"data-svelte-h":!0}),c(Q)!=="svelte-1ke7ett"&&(Q.innerHTML=ue),te=n(e),E=p(e,"UL",{"data-svelte-h":!0}),c(E)!=="svelte-n3zb5x"&&(E.innerHTML=$e),le=n(e),d(C.$$.fragment,e),se=n(e),B=p(e,"P",{}),_e(B).forEach(l),this.h()},h(){be(o,"name","hf:doc:metadata"),be(o,"content",xe)},m(e,t){Ae(document.head,o),s(e,Z,t),s(e,R,t),s(e,H,t),m(j,e,t),s(e,L,t),s(e,u,t),s(e,z,t),s(e,$,t),s(e,P,t),s(e,_,t),s(e,I,t),m(b,e,t),s(e,G,t),s(e,U,t),s(e,Y,t),s(e,h,t),s(e,F,t),s(e,S,t),s(e,W,t),m(w,e,t),s(e,N,t),m(k,e,t),s(e,X,t),s(e,y,t),s(e,O,t),s(e,A,t),s(e,V,t),m(g,e,t),s(e,D,t),s(e,v,t),s(e,q,t),m(x,e,t),s(e,K,t),m(J,e,t),s(e,ee,t),s(e,Q,t),s(e,te,t),s(e,E,t),s(e,le,t),m(C,e,t),s(e,se,t),s(e,B,t),ae=!0},p:he,i(e){ae||(r(j.$$.fragment,e),r(b.$$.fragment,e),r(w.$$.fragment,e),r(k.$$.fragment,e),r(g.$$.fragment,e),r(x.$$.fragment,e),r(J.$$.fragment,e),r(C.$$.fragment,e),ae=!0)},o(e){f(j.$$.fragment,e),f(b.$$.fragment,e),f(w.$$.fragment,e),f(k.$$.fragment,e),f(g.$$.fragment,e),f(x.$$.fragment,e),f(J.$$.fragment,e),f(C.$$.fragment,e),ae=!1},d(e){e&&(l(Z),l(R),l(H),l(L),l(u),l(z),l($),l(P),l(_),l(I),l(G),l(U),l(Y),l(h),l(F),l(S),l(W),l(N),l(X),l(y),l(O),l(A),l(V),l(D),l(v),l(q),l(K),l(ee),l(Q),l(te),l(E),l(le),l(se),l(B)),l(o),T(j,e),T(b,e),T(w,e),T(k,e),T(g,e),T(x,e),T(J,e),T(C,e)}}}const xe='{"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 Je(pe){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends we{constructor(o){super(),ke(this,o,Je,ve,Ue,{})}}export{Be as component};
