import{s as Me,n as we,o as ke}from"../chunks/scheduler.53228c21.js";import{S as Se,i as je,e as i,s as r,c as u,h as Le,a as d,d as n,b as s,f as H,g as h,j as x,k as _,l as t,m as c,n as g,t as b,o as T,p as D}from"../chunks/index.100fac89.js";import{C as ze}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as F}from"../chunks/Docstring.49101787.js";import{H as ye,E as Ce}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function qe(he){let p,G,U,R,y,W,M,J,w,_e='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.',X,k,Y,a,S,re,I,ge='The Transformer model introduced in <a href="https://huggingface.co/papers/2403.03206" rel="nofollow">Stable Diffusion 3</a>.',se,v,j,ae,O,be=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,ie,$,L,de,N,Te='The <a href="/docs/diffusers/main/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> forward method.',le,m,z,ce,A,De=`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.`,me,C,ve="<p>&gt; This API is 🧪 experimental.</p>",fe,f,q,pe,V,$e="Disables the fused QKV projection if enabled.",ue,P,xe="<p>&gt; This API is 🧪 experimental.</p>",Z,E,ee,B,te;return y=new ze({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),M=new ye({props:{title:"SD3 Transformer Model",local:"sd3-transformer-model",headingTag:"h1"}}),k=new ye({props:{title:"SD3Transformer2DModel",local:"diffusers.SD3Transformer2DModel",headingTag:"h2"}}),S=new F({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"},{name:"dual_attention_layers",val:": typing.Tuple[int, ...] = ()"},{name:"qk_norm",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The width/height of the latents. 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>, defaults to <code>2</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>, defaults to <code>16</code>) &#x2014;
The number of latent channels in the input.`,name:"in_channels"},{anchor:"diffusers.SD3Transformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>18</code>) &#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>, defaults to <code>64</code>) &#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>, defaults to <code>18</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.SD3Transformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
The embedding dimension to use for joint text-image attention.`,name:"joint_attention_dim"},{anchor:"diffusers.SD3Transformer2DModel.caption_projection_dim",description:`<strong>caption_projection_dim</strong> (<code>int</code>, defaults to <code>1152</code>) &#x2014;
The embedding dimension of caption embeddings.`,name:"caption_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, defaults to <code>2048</code>) &#x2014;
The embedding dimension of pooled text projections.`,name:"pooled_projection_dim"},{anchor:"diffusers.SD3Transformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of latent channels in the output.`,name:"out_channels"},{anchor:"diffusers.SD3Transformer2DModel.pos_embed_max_size",description:`<strong>pos_embed_max_size</strong> (<code>int</code>, defaults to <code>96</code>) &#x2014;
The maximum latent height/width of positional embeddings.`,name:"pos_embed_max_size"},{anchor:"diffusers.SD3Transformer2DModel.dual_attention_layers",description:`<strong>dual_attention_layers</strong> (<code>Tuple[int, ...]</code>, defaults to <code>()</code>) &#x2014;
The number of dual-stream transformer blocks to use.`,name:"dual_attention_layers"},{anchor:"diffusers.SD3Transformer2DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The normalization to use for query and key in the attention layer. If <code>None</code>, no normalization is used.`,name:"qk_norm"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_sd3.py#L79"}}),j=new F({props:{name:"enable_forward_chunking",anchor:"diffusers.SD3Transformer2DModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": typing.Optional[int] = 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/main/src/diffusers/models/transformers/transformer_sd3.py#L175"}}),L=new F({props:{name:"forward",anchor:"diffusers.SD3Transformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"pooled_projections",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"block_controlnet_hidden_states",val:": typing.List = None"},{name:"joint_attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"return_dict",val:": bool = True"},{name:"skip_layers",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"diffusers.SD3Transformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</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.Tensor</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.Tensor</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.`,name:"timestep"},{anchor:"diffusers.SD3Transformer2DModel.forward.block_controlnet_hidden_states",description:`<strong>block_controlnet_hidden_states</strong> (<code>list</code> of <code>torch.Tensor</code>) &#x2014;
A list of tensors that if specified are added to the residuals of transformer blocks.`,name:"block_controlnet_hidden_states"},{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"},{anchor:"diffusers.SD3Transformer2DModel.forward.skip_layers",description:`<strong>skip_layers</strong> (<code>list</code> of <code>int</code>, <em>optional</em>) &#x2014;
A list of layer indices to skip during the forward pass.`,name:"skip_layers"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_sd3.py#L248",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>
`}}),z=new F({props:{name:"fuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_sd3.py#L217"}}),q=new F({props:{name:"unfuse_qkv_projections",anchor:"diffusers.SD3Transformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_sd3.py#L239"}}),E=new Ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/sd3_transformer2d.md"}}),{c(){p=i("meta"),G=r(),U=i("p"),R=r(),u(y.$$.fragment),W=r(),u(M.$$.fragment),J=r(),w=i("p"),w.innerHTML=_e,X=r(),u(k.$$.fragment),Y=r(),a=i("div"),u(S.$$.fragment),re=r(),I=i("p"),I.innerHTML=ge,se=r(),v=i("div"),u(j.$$.fragment),ae=r(),O=i("p"),O.innerHTML=be,ie=r(),$=i("div"),u(L.$$.fragment),de=r(),N=i("p"),N.innerHTML=Te,le=r(),m=i("div"),u(z.$$.fragment),ce=r(),A=i("p"),A.textContent=De,me=r(),C=i("blockquote"),C.innerHTML=ve,fe=r(),f=i("div"),u(q.$$.fragment),pe=r(),V=i("p"),V.textContent=$e,ue=r(),P=i("blockquote"),P.innerHTML=xe,Z=r(),u(E.$$.fragment),ee=r(),B=i("p"),this.h()},l(e){const o=Le("svelte-u9bgzb",document.head);p=d(o,"META",{name:!0,content:!0}),o.forEach(n),G=s(e),U=d(e,"P",{}),H(U).forEach(n),R=s(e),h(y.$$.fragment,e),W=s(e),h(M.$$.fragment,e),J=s(e),w=d(e,"P",{"data-svelte-h":!0}),x(w)!=="svelte-hv1bl6"&&(w.innerHTML=_e),X=s(e),h(k.$$.fragment,e),Y=s(e),a=d(e,"DIV",{class:!0});var l=H(a);h(S.$$.fragment,l),re=s(l),I=d(l,"P",{"data-svelte-h":!0}),x(I)!=="svelte-18dv5mn"&&(I.innerHTML=ge),se=s(l),v=d(l,"DIV",{class:!0});var ne=H(v);h(j.$$.fragment,ne),ae=s(ne),O=d(ne,"P",{"data-svelte-h":!0}),x(O)!=="svelte-2m23sy"&&(O.innerHTML=be),ne.forEach(n),ie=s(l),$=d(l,"DIV",{class:!0});var oe=H($);h(L.$$.fragment,oe),de=s(oe),N=d(oe,"P",{"data-svelte-h":!0}),x(N)!=="svelte-1fdt9lr"&&(N.innerHTML=Te),oe.forEach(n),le=s(l),m=d(l,"DIV",{class:!0});var K=H(m);h(z.$$.fragment,K),ce=s(K),A=d(K,"P",{"data-svelte-h":!0}),x(A)!=="svelte-1254b9i"&&(A.textContent=De),me=s(K),C=d(K,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(C)!=="svelte-6y4o4y"&&(C.innerHTML=ve),K.forEach(n),fe=s(l),f=d(l,"DIV",{class:!0});var Q=H(f);h(q.$$.fragment,Q),pe=s(Q),V=d(Q,"P",{"data-svelte-h":!0}),x(V)!=="svelte-1vhtc74"&&(V.textContent=$e),ue=s(Q),P=d(Q,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(P)!=="svelte-6y4o4y"&&(P.innerHTML=xe),Q.forEach(n),l.forEach(n),Z=s(e),h(E.$$.fragment,e),ee=s(e),B=d(e,"P",{}),H(B).forEach(n),this.h()},h(){_(p,"name","hf:doc:metadata"),_(p,"content",Pe),_(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(C,"class","warning"),_(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(P,"class","warning"),_(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),_(a,"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,o){t(document.head,p),c(e,G,o),c(e,U,o),c(e,R,o),g(y,e,o),c(e,W,o),g(M,e,o),c(e,J,o),c(e,w,o),c(e,X,o),g(k,e,o),c(e,Y,o),c(e,a,o),g(S,a,null),t(a,re),t(a,I),t(a,se),t(a,v),g(j,v,null),t(v,ae),t(v,O),t(a,ie),t(a,$),g(L,$,null),t($,de),t($,N),t(a,le),t(a,m),g(z,m,null),t(m,ce),t(m,A),t(m,me),t(m,C),t(a,fe),t(a,f),g(q,f,null),t(f,pe),t(f,V),t(f,ue),t(f,P),c(e,Z,o),g(E,e,o),c(e,ee,o),c(e,B,o),te=!0},p:we,i(e){te||(b(y.$$.fragment,e),b(M.$$.fragment,e),b(k.$$.fragment,e),b(S.$$.fragment,e),b(j.$$.fragment,e),b(L.$$.fragment,e),b(z.$$.fragment,e),b(q.$$.fragment,e),b(E.$$.fragment,e),te=!0)},o(e){T(y.$$.fragment,e),T(M.$$.fragment,e),T(k.$$.fragment,e),T(S.$$.fragment,e),T(j.$$.fragment,e),T(L.$$.fragment,e),T(z.$$.fragment,e),T(q.$$.fragment,e),T(E.$$.fragment,e),te=!1},d(e){e&&(n(G),n(U),n(R),n(W),n(J),n(w),n(X),n(Y),n(a),n(Z),n(ee),n(B)),n(p),D(y,e),D(M,e),D(k,e),D(S),D(j),D(L),D(z),D(q),D(E,e)}}}const Pe='{"title":"SD3 Transformer Model","local":"sd3-transformer-model","sections":[{"title":"SD3Transformer2DModel","local":"diffusers.SD3Transformer2DModel","sections":[],"depth":2}],"depth":1}';function Ee(he){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends Se{constructor(p){super(),je(this,p,Ee,qe,Me,{})}}export{Ve as component};
