import{s as Le,o as Ee,n as ze}from"../chunks/scheduler.8c3d61f6.js";import{S as Ie,i as qe,g as c,s as a,r as p,A as Ae,h as l,f as n,c as i,j as k,u,x as T,k as C,y as t,a as m,v as h,d as _,t as g,w as $}from"../chunks/index.da70eac4.js";import{T as Ce}from"../chunks/Tip.1d9b8c37.js";import{D as Y}from"../chunks/Docstring.ee4b6913.js";import{H as Pe,E as He}from"../chunks/EditOnGithub.1e64e623.js";function Ne(O){let o,b="This API is 🧪 experimental.";return{c(){o=c("p"),o.textContent=b},l(f){o=l(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-89q1io"&&(o.textContent=b)},m(f,x){m(f,o,x)},p:ze,d(f){f&&n(o)}}}function Fe(O){let o,b="This API is 🧪 experimental.";return{c(){o=c("p"),o.textContent=b},l(f){o=l(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-89q1io"&&(o.textContent=b)},m(f,x){m(f,o,x)},p:ze,d(f){f&&n(o)}}}function Ve(O){let o,b,f,x,P,ee,z,Te='The Transformer model introduced in <a href="https://hf.co/papers/2403.03206" rel="nofollow">Stable Diffusion 3</a>. Its novelty lies in the MMDiT transformer block.',te,L,oe,s,E,de,U,xe="The Transformer model introduced in Stable Diffusion 3.",ce,K,we='Reference: <a href="https://arxiv.org/abs/2403.03206" rel="nofollow">https://arxiv.org/abs/2403.03206</a>',le,w,I,fe,Q,Me=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,me,M,q,pe,R,Se='The <a href="/docs/diffusers/v0.30.2/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> forward method.',ue,v,A,he,G,ye=`Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.`,_e,S,ge,y,H,$e,W,je="Sets the attention processor to use to compute attention.",be,D,N,ve,B,ke="Disables the fused QKV projection if enabled.",De,j,ne,F,re,Z,se;return P=new Pe({props:{title:"SD3 Transformer Model",local:"sd3-transformer-model",headingTag:"h1"}}),L=new Pe({props:{title:"SD3Transformer2DModel",local:"diffusers.SD3Transformer2DModel",headingTag:"h2"}}),E=new Y({props:{name:"class diffusers.SD3Transformer2DModel",anchor:"diffusers.SD3Transformer2DModel",parameters:[{name:"sample_size",val:": int = 128"},{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 16"},{name:"num_layers",val:": int = 18"},{name:"attention_head_dim",val:": int = 64"},{name:"num_attention_heads",val:": int = 18"},{name:"joint_attention_dim",val:": int = 4096"},{name:"caption_projection_dim",val:": int = 1152"},{name:"pooled_projection_dim",val:": int = 2048"},{name:"out_channels",val:": int = 16"},{name:"pos_embed_max_size",val:": int = 96"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>) &#x2014; The width of the latent images. This is fixed during training since
it is used to learn a number of position embeddings.`,name:"sample_size"},{anchor:"diffusers.SD3Transformer2DModel.patch_size",description:"<strong>patch_size</strong> (<code>int</code>) &#x2014; Patch size to turn the input data into small patches.",name:"patch_size"},{anchor:"diffusers.SD3Transformer2DModel.in_channels",description:"<strong>in_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014; The number of channels in the input.",name:"in_channels"},{anchor:"diffusers.SD3Transformer2DModel.num_layers",description:"<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 18) &#x2014; The number of layers of Transformer blocks to use.",name:"num_layers"},{anchor:"diffusers.SD3Transformer2DModel.attention_head_dim",description:"<strong>attention_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014; The number of channels in each head.",name:"attention_head_dim"},{anchor:"diffusers.SD3Transformer2DModel.num_attention_heads",description:"<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 18) &#x2014; The number of heads to use for multi-head attention.",name:"num_attention_heads"},{anchor:"diffusers.SD3Transformer2DModel.cross_attention_dim",description:"<strong>cross_attention_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014; The number of <code>encoder_hidden_states</code> dimensions to use.",name:"cross_attention_dim"},{anchor:"diffusers.SD3Transformer2DModel.caption_projection_dim",description:"<strong>caption_projection_dim</strong> (<code>int</code>) &#x2014; Number of dimensions to use when projecting the <code>encoder_hidden_states</code>.",name:"caption_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.pooled_projection_dim",description:"<strong>pooled_projection_dim</strong> (<code>int</code>) &#x2014; Number of dimensions to use when projecting the <code>pooled_projections</code>.",name:"pooled_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.out_channels",description:"<strong>out_channels</strong> (<code>int</code>, defaults to 16) &#x2014; Number of output channels.",name:"out_channels"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L35"}}),I=new Y({props:{name:"enable_forward_chunking",anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": Optional = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The chunk size of the feed-forward layers. If not specified, will run feed-forward layer individually
over each tensor of dim=<code>dim</code>.`,name:"chunk_size"},{anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking.dim",description:`<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
The dimension over which the feed-forward computation should be chunked. Choose between dim=0 (batch)
or dim=1 (sequence length).`,name:"dim"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L111"}}),q=new Y({props:{name:"forward",anchor:"diffusers.SD3Transformer2DModel.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"encoder_hidden_states",val:": FloatTensor = None"},{name:"pooled_projections",val:": FloatTensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"block_controlnet_hidden_states",val:": List = None"},{name:"joint_attention_kwargs",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, channel, height, width)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.SD3Transformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, sequence_len, embed_dims)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.SD3Transformer2DModel.forward.pooled_projections",description:`<strong>pooled_projections</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, projection_dim)</code>) &#x2014; Embeddings projected
from the embeddings of input conditions.`,name:"pooled_projections"},{anchor:"diffusers.SD3Transformer2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.
block_controlnet_hidden_states &#x2014; (<code>list</code> of <code>torch.Tensor</code>):
A list of tensors that if specified are added to the residuals of transformer blocks.`,name:"timestep"},{anchor:"diffusers.SD3Transformer2DModel.forward.joint_attention_kwargs",description:`<strong>joint_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"joint_attention_kwargs"},{anchor:"diffusers.SD3Transformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L256",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a
<code>tuple</code> where the first element is the sample tensor.</p>
`}}),A=new Y({props:{name:"fuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L213"}}),S=new Ce({props:{warning:!0,$$slots:{default:[Ne]},$$scope:{ctx:O}}}),H=new Y({props:{name:"set_attn_processor",anchor:"diffusers.SD3Transformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.set_attn_processor.processor",description:`<strong>processor</strong> (<code>dict</code> of <code>AttentionProcessor</code> or only <code>AttentionProcessor</code>) &#x2014;
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for <strong>all</strong> <code>Attention</code> layers.</p>
<p>If <code>processor</code> is a dict, the key needs to define the path to the corresponding cross attention
processor. This is strongly recommended when setting trainable attention processors.`,name:"processor"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L178"}}),N=new Y({props:{name:"unfuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.30.2/src/diffusers/models/transformers/transformer_sd3.py#L239"}}),j=new Ce({props:{warning:!0,$$slots:{default:[Fe]},$$scope:{ctx:O}}}),F=new He({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/sd3_transformer2d.md"}}),{c(){o=c("meta"),b=a(),f=c("p"),x=a(),p(P.$$.fragment),ee=a(),z=c("p"),z.innerHTML=Te,te=a(),p(L.$$.fragment),oe=a(),s=c("div"),p(E.$$.fragment),de=a(),U=c("p"),U.textContent=xe,ce=a(),K=c("p"),K.innerHTML=we,le=a(),w=c("div"),p(I.$$.fragment),fe=a(),Q=c("p"),Q.innerHTML=Me,me=a(),M=c("div"),p(q.$$.fragment),pe=a(),R=c("p"),R.innerHTML=Se,ue=a(),v=c("div"),p(A.$$.fragment),he=a(),G=c("p"),G.textContent=ye,_e=a(),p(S.$$.fragment),ge=a(),y=c("div"),p(H.$$.fragment),$e=a(),W=c("p"),W.textContent=je,be=a(),D=c("div"),p(N.$$.fragment),ve=a(),B=c("p"),B.textContent=ke,De=a(),p(j.$$.fragment),ne=a(),p(F.$$.fragment),re=a(),Z=c("p"),this.h()},l(e){const r=Ae("svelte-u9bgzb",document.head);o=l(r,"META",{name:!0,content:!0}),r.forEach(n),b=i(e),f=l(e,"P",{}),k(f).forEach(n),x=i(e),u(P.$$.fragment,e),ee=i(e),z=l(e,"P",{"data-svelte-h":!0}),T(z)!=="svelte-hv1bl6"&&(z.innerHTML=Te),te=i(e),u(L.$$.fragment,e),oe=i(e),s=l(e,"DIV",{class:!0});var d=k(s);u(E.$$.fragment,d),de=i(d),U=l(d,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1f9jxt2"&&(U.textContent=xe),ce=i(d),K=l(d,"P",{"data-svelte-h":!0}),T(K)!=="svelte-5lf8o6"&&(K.innerHTML=we),le=i(d),w=l(d,"DIV",{class:!0});var V=k(w);u(I.$$.fragment,V),fe=i(V),Q=l(V,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-2m23sy"&&(Q.innerHTML=Me),V.forEach(n),me=i(d),M=l(d,"DIV",{class:!0});var ae=k(M);u(q.$$.fragment,ae),pe=i(ae),R=l(ae,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1i5kf3h"&&(R.innerHTML=Se),ae.forEach(n),ue=i(d),v=l(d,"DIV",{class:!0});var J=k(v);u(A.$$.fragment,J),he=i(J),G=l(J,"P",{"data-svelte-h":!0}),T(G)!=="svelte-1254b9i"&&(G.textContent=ye),_e=i(J),u(S.$$.fragment,J),J.forEach(n),ge=i(d),y=l(d,"DIV",{class:!0});var ie=k(y);u(H.$$.fragment,ie),$e=i(ie),W=l(ie,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1o77hl2"&&(W.textContent=je),ie.forEach(n),be=i(d),D=l(d,"DIV",{class:!0});var X=k(D);u(N.$$.fragment,X),ve=i(X),B=l(X,"P",{"data-svelte-h":!0}),T(B)!=="svelte-1vhtc74"&&(B.textContent=ke),De=i(X),u(j.$$.fragment,X),X.forEach(n),d.forEach(n),ne=i(e),u(F.$$.fragment,e),re=i(e),Z=l(e,"P",{}),k(Z).forEach(n),this.h()},h(){C(o,"name","hf:doc:metadata"),C(o,"content",Oe),C(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,r){t(document.head,o),m(e,b,r),m(e,f,r),m(e,x,r),h(P,e,r),m(e,ee,r),m(e,z,r),m(e,te,r),h(L,e,r),m(e,oe,r),m(e,s,r),h(E,s,null),t(s,de),t(s,U),t(s,ce),t(s,K),t(s,le),t(s,w),h(I,w,null),t(w,fe),t(w,Q),t(s,me),t(s,M),h(q,M,null),t(M,pe),t(M,R),t(s,ue),t(s,v),h(A,v,null),t(v,he),t(v,G),t(v,_e),h(S,v,null),t(s,ge),t(s,y),h(H,y,null),t(y,$e),t(y,W),t(s,be),t(s,D),h(N,D,null),t(D,ve),t(D,B),t(D,De),h(j,D,null),m(e,ne,r),h(F,e,r),m(e,re,r),m(e,Z,r),se=!0},p(e,[r]){const d={};r&2&&(d.$$scope={dirty:r,ctx:e}),S.$set(d);const V={};r&2&&(V.$$scope={dirty:r,ctx:e}),j.$set(V)},i(e){se||(_(P.$$.fragment,e),_(L.$$.fragment,e),_(E.$$.fragment,e),_(I.$$.fragment,e),_(q.$$.fragment,e),_(A.$$.fragment,e),_(S.$$.fragment,e),_(H.$$.fragment,e),_(N.$$.fragment,e),_(j.$$.fragment,e),_(F.$$.fragment,e),se=!0)},o(e){g(P.$$.fragment,e),g(L.$$.fragment,e),g(E.$$.fragment,e),g(I.$$.fragment,e),g(q.$$.fragment,e),g(A.$$.fragment,e),g(S.$$.fragment,e),g(H.$$.fragment,e),g(N.$$.fragment,e),g(j.$$.fragment,e),g(F.$$.fragment,e),se=!1},d(e){e&&(n(b),n(f),n(x),n(ee),n(z),n(te),n(oe),n(s),n(ne),n(re),n(Z)),n(o),$(P,e),$(L,e),$(E),$(I),$(q),$(A),$(S),$(H),$(N),$(j),$(F,e)}}}const Oe='{"title":"SD3 Transformer Model","local":"sd3-transformer-model","sections":[{"title":"SD3Transformer2DModel","local":"diffusers.SD3Transformer2DModel","sections":[],"depth":2}],"depth":1}';function Ue(O){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends Ie{constructor(o){super(),qe(this,o,Ue,Ve,Le,{})}}export{Be as component};
