import{s as ye,o as De,n as Te}from"../chunks/scheduler.8c3d61f6.js";import{S as Me,i as we,g as f,s as i,r as h,A as Ce,h as l,f as r,c as d,j as N,u as g,x as $,k as H,y as t,a as m,v as A,d as P,t as x,w as b}from"../chunks/index.da70eac4.js";import{T as Fe}from"../chunks/Tip.1d9b8c37.js";import{D as W}from"../chunks/Docstring.6b390b9a.js";import{H as ve,E as Le}from"../chunks/EditOnGithub.1e64e623.js";function je(X){let s,u="This API is 🧪 experimental.";return{c(){s=f("p"),s.textContent=u},l(a){s=l(a,"P",{"data-svelte-h":!0}),$(s)!=="svelte-89q1io"&&(s.textContent=u)},m(a,F){m(a,s,F)},p:Te,d(a){a&&r(s)}}}function ke(X){let s,u="This API is 🧪 experimental.";return{c(){s=f("p"),s.textContent=u},l(a){s=l(a,"P",{"data-svelte-h":!0}),$(s)!=="svelte-89q1io"&&(s.textContent=u)},m(a,F){m(a,s,F)},p:Te,d(a){a&&r(s)}}}function Se(X){let s,u,a,F,M,B,w,he='A Transformer model for image-like data from <a href="https://blackforestlabs.ai/announcing-black-forest-labs/" rel="nofollow">Flux</a>.',Y,C,Z,n,L,re,E,ge="The Transformer model introduced in Flux.",ne,K,Ae='Reference: <a href="https://blackforestlabs.ai/announcing-black-forest-labs/" rel="nofollow">https://blackforestlabs.ai/announcing-black-forest-labs/</a>',ie,v,j,de,z,Pe='The <a href="/docs/diffusers/pr_10136/en/api/models/flux_transformer#diffusers.FluxTransformer2DModel">FluxTransformer2DModel</a> forward method.',ae,_,k,ce,R,xe=`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.`,fe,T,le,y,S,me,U,be="Sets the attention processor to use to compute attention.",ue,p,G,_e,q,$e="Disables the fused QKV projection if enabled.",pe,D,ee,V,se,Q,te;return M=new ve({props:{title:"FluxTransformer2DModel",local:"fluxtransformer2dmodel",headingTag:"h1"}}),C=new ve({props:{title:"FluxTransformer2DModel",local:"diffusers.FluxTransformer2DModel",headingTag:"h2"}}),L=new W({props:{name:"class diffusers.FluxTransformer2DModel",anchor:"diffusers.FluxTransformer2DModel",parameters:[{name:"patch_size",val:": int = 1"},{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": typing.Optional[int] = None"},{name:"num_layers",val:": int = 19"},{name:"num_single_layers",val:": int = 38"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 24"},{name:"joint_attention_dim",val:": int = 4096"},{name:"pooled_projection_dim",val:": int = 768"},{name:"guidance_embeds",val:": bool = False"},{name:"axes_dims_rope",val:": typing.Tuple[int] = (16, 56, 56)"}],parametersDescription:[{anchor:"diffusers.FluxTransformer2DModel.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.FluxTransformer2DModel.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.FluxTransformer2DModel.num_layers",description:"<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 18) &#x2014; The number of layers of MMDiT blocks to use.",name:"num_layers"},{anchor:"diffusers.FluxTransformer2DModel.num_single_layers",description:"<strong>num_single_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 18) &#x2014; The number of layers of single DiT blocks to use.",name:"num_single_layers"},{anchor:"diffusers.FluxTransformer2DModel.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.FluxTransformer2DModel.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.FluxTransformer2DModel.joint_attention_dim",description:"<strong>joint_attention_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014; The number of <code>encoder_hidden_states</code> dimensions to use.",name:"joint_attention_dim"},{anchor:"diffusers.FluxTransformer2DModel.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.FluxTransformer2DModel.guidance_embeds",description:"<strong>guidance_embeds</strong> (<code>bool</code>, defaults to False) &#x2014; Whether to use guidance embeddings.",name:"guidance_embeds"}],source:"https://github.com/huggingface/diffusers/blob/vr_10136/src/diffusers/models/transformers/transformer_flux.py#L215"}}),j=new W({props:{name:"forward",anchor:"diffusers.FluxTransformer2DModel.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:"img_ids",val:": Tensor = None"},{name:"txt_ids",val:": Tensor = None"},{name:"guidance",val:": Tensor = None"},{name:"joint_attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"controlnet_block_samples",val:" = None"},{name:"controlnet_single_block_samples",val:" = None"},{name:"return_dict",val:": bool = True"},{name:"controlnet_blocks_repeat",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.FluxTransformer2DModel.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.FluxTransformer2DModel.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.FluxTransformer2DModel.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.FluxTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.FluxTransformer2DModel.forward.block_controlnet_hidden_states",description:`<strong>block_controlnet_hidden_states</strong> &#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:"block_controlnet_hidden_states"},{anchor:"diffusers.FluxTransformer2DModel.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.FluxTransformer2DModel.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/vr_10136/src/diffusers/models/transformers/transformer_flux.py#L398",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>
`}}),k=new W({props:{name:"fuse_qkv_projections",anchor:"diffusers.FluxTransformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10136/src/diffusers/models/transformers/transformer_flux.py#L355"}}),T=new Fe({props:{warning:!0,$$slots:{default:[je]},$$scope:{ctx:X}}}),S=new W({props:{name:"set_attn_processor",anchor:"diffusers.FluxTransformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor, typing.Dict[str, typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor]]]"}],parametersDescription:[{anchor:"diffusers.FluxTransformer2DModel.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/vr_10136/src/diffusers/models/transformers/transformer_flux.py#L320"}}),G=new W({props:{name:"unfuse_qkv_projections",anchor:"diffusers.FluxTransformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_10136/src/diffusers/models/transformers/transformer_flux.py#L381"}}),D=new Fe({props:{warning:!0,$$slots:{default:[ke]},$$scope:{ctx:X}}}),V=new Le({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/flux_transformer.md"}}),{c(){s=f("meta"),u=i(),a=f("p"),F=i(),h(M.$$.fragment),B=i(),w=f("p"),w.innerHTML=he,Y=i(),h(C.$$.fragment),Z=i(),n=f("div"),h(L.$$.fragment),re=i(),E=f("p"),E.textContent=ge,ne=i(),K=f("p"),K.innerHTML=Ae,ie=i(),v=f("div"),h(j.$$.fragment),de=i(),z=f("p"),z.innerHTML=Pe,ae=i(),_=f("div"),h(k.$$.fragment),ce=i(),R=f("p"),R.textContent=xe,fe=i(),h(T.$$.fragment),le=i(),y=f("div"),h(S.$$.fragment),me=i(),U=f("p"),U.textContent=be,ue=i(),p=f("div"),h(G.$$.fragment),_e=i(),q=f("p"),q.textContent=$e,pe=i(),h(D.$$.fragment),ee=i(),h(V.$$.fragment),se=i(),Q=f("p"),this.h()},l(e){const o=Ce("svelte-u9bgzb",document.head);s=l(o,"META",{name:!0,content:!0}),o.forEach(r),u=d(e),a=l(e,"P",{}),N(a).forEach(r),F=d(e),g(M.$$.fragment,e),B=d(e),w=l(e,"P",{"data-svelte-h":!0}),$(w)!=="svelte-e6h9db"&&(w.innerHTML=he),Y=d(e),g(C.$$.fragment,e),Z=d(e),n=l(e,"DIV",{class:!0});var c=N(n);g(L.$$.fragment,c),re=d(c),E=l(c,"P",{"data-svelte-h":!0}),$(E)!=="svelte-19p4ty0"&&(E.textContent=ge),ne=d(c),K=l(c,"P",{"data-svelte-h":!0}),$(K)!=="svelte-mxgguy"&&(K.innerHTML=Ae),ie=d(c),v=l(c,"DIV",{class:!0});var I=N(v);g(j.$$.fragment,I),de=d(I),z=l(I,"P",{"data-svelte-h":!0}),$(z)!=="svelte-1vz4j57"&&(z.innerHTML=Pe),I.forEach(r),ae=d(c),_=l(c,"DIV",{class:!0});var J=N(_);g(k.$$.fragment,J),ce=d(J),R=l(J,"P",{"data-svelte-h":!0}),$(R)!=="svelte-1254b9i"&&(R.textContent=xe),fe=d(J),g(T.$$.fragment,J),J.forEach(r),le=d(c),y=l(c,"DIV",{class:!0});var oe=N(y);g(S.$$.fragment,oe),me=d(oe),U=l(oe,"P",{"data-svelte-h":!0}),$(U)!=="svelte-1o77hl2"&&(U.textContent=be),oe.forEach(r),ue=d(c),p=l(c,"DIV",{class:!0});var O=N(p);g(G.$$.fragment,O),_e=d(O),q=l(O,"P",{"data-svelte-h":!0}),$(q)!=="svelte-1vhtc74"&&(q.textContent=$e),pe=d(O),g(D.$$.fragment,O),O.forEach(r),c.forEach(r),ee=d(e),g(V.$$.fragment,e),se=d(e),Q=l(e,"P",{}),N(Q).forEach(r),this.h()},h(){H(s,"name","hf:doc:metadata"),H(s,"content",Ge),H(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(n,"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,s),m(e,u,o),m(e,a,o),m(e,F,o),A(M,e,o),m(e,B,o),m(e,w,o),m(e,Y,o),A(C,e,o),m(e,Z,o),m(e,n,o),A(L,n,null),t(n,re),t(n,E),t(n,ne),t(n,K),t(n,ie),t(n,v),A(j,v,null),t(v,de),t(v,z),t(n,ae),t(n,_),A(k,_,null),t(_,ce),t(_,R),t(_,fe),A(T,_,null),t(n,le),t(n,y),A(S,y,null),t(y,me),t(y,U),t(n,ue),t(n,p),A(G,p,null),t(p,_e),t(p,q),t(p,pe),A(D,p,null),m(e,ee,o),A(V,e,o),m(e,se,o),m(e,Q,o),te=!0},p(e,[o]){const c={};o&2&&(c.$$scope={dirty:o,ctx:e}),T.$set(c);const I={};o&2&&(I.$$scope={dirty:o,ctx:e}),D.$set(I)},i(e){te||(P(M.$$.fragment,e),P(C.$$.fragment,e),P(L.$$.fragment,e),P(j.$$.fragment,e),P(k.$$.fragment,e),P(T.$$.fragment,e),P(S.$$.fragment,e),P(G.$$.fragment,e),P(D.$$.fragment,e),P(V.$$.fragment,e),te=!0)},o(e){x(M.$$.fragment,e),x(C.$$.fragment,e),x(L.$$.fragment,e),x(j.$$.fragment,e),x(k.$$.fragment,e),x(T.$$.fragment,e),x(S.$$.fragment,e),x(G.$$.fragment,e),x(D.$$.fragment,e),x(V.$$.fragment,e),te=!1},d(e){e&&(r(u),r(a),r(F),r(B),r(w),r(Y),r(Z),r(n),r(ee),r(se),r(Q)),r(s),b(M,e),b(C,e),b(L),b(j),b(k),b(T),b(S),b(G),b(D),b(V,e)}}}const Ge='{"title":"FluxTransformer2DModel","local":"fluxtransformer2dmodel","sections":[{"title":"FluxTransformer2DModel","local":"diffusers.FluxTransformer2DModel","sections":[],"depth":2}],"depth":1}';function Ve(X){return De(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ke extends Me{constructor(s){super(),we(this,s,Ve,Se,ye,{})}}export{Ke as component};
