import{s as De,o as ye,n as Te}from"../chunks/scheduler.8c3d61f6.js";import{S as Me,i as we,g as f,s as d,r as h,A as Ce,h as l,f as r,c as i,j as H,u as g,x as $,k as X,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 je}from"../chunks/EditOnGithub.1e64e623.js";function ke(S){let o,u="This API is 🧪 experimental.";return{c(){o=f("p"),o.textContent=u},l(a){o=l(a,"P",{"data-svelte-h":!0}),$(o)!=="svelte-89q1io"&&(o.textContent=u)},m(a,F){m(a,o,F)},p:Te,d(a){a&&r(o)}}}function Le(S){let o,u="This API is 🧪 experimental.";return{c(){o=f("p"),o.textContent=u},l(a){o=l(a,"P",{"data-svelte-h":!0}),$(o)!=="svelte-89q1io"&&(o.textContent=u)},m(a,F){m(a,o,F)},p:Te,d(a){a&&r(o)}}}function Ve(S){let o,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,j,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>',de,v,k,ie,z,Pe='The <a href="/docs/diffusers/pr_10136/en/api/models/flux_transformer#diffusers.FluxTransformer2DModel">FluxTransformer2DModel</a> forward method.',ae,p,L,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,D,V,me,U,be="Sets the attention processor to use to compute attention.",ue,_,I,pe,q,$e="Disables the fused QKV projection if enabled.",_e,y,ee,G,oe,Q,te;return M=new ve({props:{title:"FluxTransformer2DModel",local:"fluxtransformer2dmodel",headingTag:"h1"}}),C=new ve({props:{title:"FluxTransformer2DModel",local:"diffusers.FluxTransformer2DModel",headingTag:"h2"}}),j=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"}}),k=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>
`}}),L=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:[ke]},$$scope:{ctx:S}}}),V=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.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.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"}}),I=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"}}),y=new Fe({props:{warning:!0,$$slots:{default:[Le]},$$scope:{ctx:S}}}),G=new je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/flux_transformer.md"}}),{c(){o=f("meta"),u=d(),a=f("p"),F=d(),h(M.$$.fragment),B=d(),w=f("p"),w.innerHTML=he,Y=d(),h(C.$$.fragment),Z=d(),n=f("div"),h(j.$$.fragment),re=d(),E=f("p"),E.textContent=ge,ne=d(),K=f("p"),K.innerHTML=Ae,de=d(),v=f("div"),h(k.$$.fragment),ie=d(),z=f("p"),z.innerHTML=Pe,ae=d(),p=f("div"),h(L.$$.fragment),ce=d(),R=f("p"),R.textContent=xe,fe=d(),h(T.$$.fragment),le=d(),D=f("div"),h(V.$$.fragment),me=d(),U=f("p"),U.textContent=be,ue=d(),_=f("div"),h(I.$$.fragment),pe=d(),q=f("p"),q.textContent=$e,_e=d(),h(y.$$.fragment),ee=d(),h(G.$$.fragment),oe=d(),Q=f("p"),this.h()},l(e){const s=Ce("svelte-u9bgzb",document.head);o=l(s,"META",{name:!0,content:!0}),s.forEach(r),u=i(e),a=l(e,"P",{}),H(a).forEach(r),F=i(e),g(M.$$.fragment,e),B=i(e),w=l(e,"P",{"data-svelte-h":!0}),$(w)!=="svelte-e6h9db"&&(w.innerHTML=he),Y=i(e),g(C.$$.fragment,e),Z=i(e),n=l(e,"DIV",{class:!0});var c=H(n);g(j.$$.fragment,c),re=i(c),E=l(c,"P",{"data-svelte-h":!0}),$(E)!=="svelte-19p4ty0"&&(E.textContent=ge),ne=i(c),K=l(c,"P",{"data-svelte-h":!0}),$(K)!=="svelte-mxgguy"&&(K.innerHTML=Ae),de=i(c),v=l(c,"DIV",{class:!0});var N=H(v);g(k.$$.fragment,N),ie=i(N),z=l(N,"P",{"data-svelte-h":!0}),$(z)!=="svelte-1vz4j57"&&(z.innerHTML=Pe),N.forEach(r),ae=i(c),p=l(c,"DIV",{class:!0});var J=H(p);g(L.$$.fragment,J),ce=i(J),R=l(J,"P",{"data-svelte-h":!0}),$(R)!=="svelte-1254b9i"&&(R.textContent=xe),fe=i(J),g(T.$$.fragment,J),J.forEach(r),le=i(c),D=l(c,"DIV",{class:!0});var se=H(D);g(V.$$.fragment,se),me=i(se),U=l(se,"P",{"data-svelte-h":!0}),$(U)!=="svelte-1o77hl2"&&(U.textContent=be),se.forEach(r),ue=i(c),_=l(c,"DIV",{class:!0});var O=H(_);g(I.$$.fragment,O),pe=i(O),q=l(O,"P",{"data-svelte-h":!0}),$(q)!=="svelte-1vhtc74"&&(q.textContent=$e),_e=i(O),g(y.$$.fragment,O),O.forEach(r),c.forEach(r),ee=i(e),g(G.$$.fragment,e),oe=i(e),Q=l(e,"P",{}),H(Q).forEach(r),this.h()},h(){X(o,"name","hf:doc:metadata"),X(o,"content",Ie),X(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(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,s){t(document.head,o),m(e,u,s),m(e,a,s),m(e,F,s),A(M,e,s),m(e,B,s),m(e,w,s),m(e,Y,s),A(C,e,s),m(e,Z,s),m(e,n,s),A(j,n,null),t(n,re),t(n,E),t(n,ne),t(n,K),t(n,de),t(n,v),A(k,v,null),t(v,ie),t(v,z),t(n,ae),t(n,p),A(L,p,null),t(p,ce),t(p,R),t(p,fe),A(T,p,null),t(n,le),t(n,D),A(V,D,null),t(D,me),t(D,U),t(n,ue),t(n,_),A(I,_,null),t(_,pe),t(_,q),t(_,_e),A(y,_,null),m(e,ee,s),A(G,e,s),m(e,oe,s),m(e,Q,s),te=!0},p(e,[s]){const c={};s&2&&(c.$$scope={dirty:s,ctx:e}),T.$set(c);const N={};s&2&&(N.$$scope={dirty:s,ctx:e}),y.$set(N)},i(e){te||(P(M.$$.fragment,e),P(C.$$.fragment,e),P(j.$$.fragment,e),P(k.$$.fragment,e),P(L.$$.fragment,e),P(T.$$.fragment,e),P(V.$$.fragment,e),P(I.$$.fragment,e),P(y.$$.fragment,e),P(G.$$.fragment,e),te=!0)},o(e){x(M.$$.fragment,e),x(C.$$.fragment,e),x(j.$$.fragment,e),x(k.$$.fragment,e),x(L.$$.fragment,e),x(T.$$.fragment,e),x(V.$$.fragment,e),x(I.$$.fragment,e),x(y.$$.fragment,e),x(G.$$.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(oe),r(Q)),r(o),b(M,e),b(C,e),b(j),b(k),b(L),b(T),b(V),b(I),b(y),b(G,e)}}}const Ie='{"title":"FluxTransformer2DModel","local":"fluxtransformer2dmodel","sections":[{"title":"FluxTransformer2DModel","local":"diffusers.FluxTransformer2DModel","sections":[],"depth":2}],"depth":1}';function Ge(S){return ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ke extends Me{constructor(o){super(),we(this,o,Ge,Ve,De,{})}}export{Ke as component};
