import{s as Se,o as Oe,n as Ve}from"../chunks/scheduler.8c3d61f6.js";import{S as Fe,i as Ue,g as l,s as r,r as f,A as We,h as m,f as o,c as a,j as D,u as p,x as y,k as x,y as t,a as u,v as h,d as _,t as g,w as b}from"../chunks/index.589a98e8.js";import{T as Ae}from"../chunks/Tip.42aa8582.js";import{D as W}from"../chunks/Docstring.27406313.js";import{H as Ne,E as Be}from"../chunks/EditOnGithub.e5a8d9cb.js";function Ke(B){let n,v="This API is 🧪 experimental.";return{c(){n=l("p"),n.textContent=v},l(c){n=m(c,"P",{"data-svelte-h":!0}),y(n)!=="svelte-89q1io"&&(n.textContent=v)},m(c,M){u(c,n,M)},p:Ve,d(c){c&&o(n)}}}function Qe(B){let n,v="This API is 🧪 experimental.";return{c(){n=l("p"),n.textContent=v},l(c){n=m(c,"P",{"data-svelte-h":!0}),y(n)!=="svelte-89q1io"&&(n.textContent=v)},m(c,M){u(c,n,M)},p:Ve,d(c){c&&o(n)}}}function Ge(B){let n,v,c,M,j,oe,E,ze='A Diffusion Transformer model for 2D data from <a href="https://github.com/Tencent/HunyuanDiT" rel="nofollow">Hunyuan-DiT</a>.',se,q,re,s,L,ue,K,ke="HunYuanDiT: Diffusion model with a Transformer backbone.",fe,Q,Ce="Inherit ModelMixin and ConfigMixin to be compatible with the sampler StableDiffusionPipeline of diffusers.",pe,H,I,he,G,Pe=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,_e,w,A,ge,R,je='The <a href="/docs/diffusers/pr_8408/en/api/models/hunyuan_transformer2d#diffusers.HunyuanDiT2DModel">HunyuanDiT2DModel</a> forward method.',be,$,N,ye,Y,Ee=`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.`,ve,z,$e,k,V,Te,J,qe="Sets the attention processor to use to compute attention.",De,C,S,xe,X,Le="Disables custom attention processors and sets the default attention implementation.",Me,T,O,He,Z,Ie="Disables the fused QKV projection if enabled.",we,P,ae,F,ie,ne,de;return j=new Ne({props:{title:"HunyuanDiT2DModel",local:"hunyuandit2dmodel",headingTag:"h1"}}),q=new Ne({props:{title:"HunyuanDiT2DModel",local:"diffusers.HunyuanDiT2DModel",headingTag:"h2"}}),L=new W({props:{name:"class diffusers.HunyuanDiT2DModel",anchor:"diffusers.HunyuanDiT2DModel",parameters:[{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 88"},{name:"in_channels",val:": Optional = None"},{name:"patch_size",val:": Optional = None"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"sample_size",val:" = 32"},{name:"hidden_size",val:" = 1152"},{name:"num_layers",val:": int = 28"},{name:"mlp_ratio",val:": float = 4.0"},{name:"learn_sigma",val:": bool = True"},{name:"cross_attention_dim",val:": int = 1024"},{name:"norm_type",val:": str = 'layer_norm'"},{name:"cross_attention_dim_t5",val:": int = 2048"},{name:"pooled_projection_dim",val:": int = 1024"},{name:"text_len",val:": int = 77"},{name:"text_len_t5",val:": int = 256"},{name:"use_style_cond_and_image_meta_size",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.HunyuanDiT2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 88) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.HunyuanDiT2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of channels in the input and output (specify if the input is <strong>continuous</strong>).`,name:"in_channels"},{anchor:"diffusers.HunyuanDiT2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of the patch to use for the input.`,name:"patch_size"},{anchor:"diffusers.HunyuanDiT2DModel.activation_fn",description:`<strong>activation_fn</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;geglu&quot;</code>) &#x2014;
Activation function to use in feed-forward.`,name:"activation_fn"},{anchor:"diffusers.HunyuanDiT2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, <em>optional</em>) &#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.HunyuanDiT2DModel.dropout",description:`<strong>dropout</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability to use.`,name:"dropout"},{anchor:"diffusers.HunyuanDiT2DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of dimension in the clip text embedding.`,name:"cross_attention_dim"},{anchor:"diffusers.HunyuanDiT2DModel.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of hidden layer in the conditioning embedding layers.`,name:"hidden_size"},{anchor:"diffusers.HunyuanDiT2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.HunyuanDiT2DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
The ratio of the hidden layer size to the input size.`,name:"mlp_ratio"},{anchor:"diffusers.HunyuanDiT2DModel.learn_sigma",description:`<strong>learn_sigma</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to predict variance.`,name:"learn_sigma"},{anchor:"diffusers.HunyuanDiT2DModel.cross_attention_dim_t5",description:`<strong>cross_attention_dim_t5</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number dimensions in t5 text embedding.`,name:"cross_attention_dim_t5"},{anchor:"diffusers.HunyuanDiT2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of the pooled projection.`,name:"pooled_projection_dim"},{anchor:"diffusers.HunyuanDiT2DModel.text_len",description:`<strong>text_len</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the clip text embedding.`,name:"text_len"},{anchor:"diffusers.HunyuanDiT2DModel.text_len_t5",description:`<strong>text_len_t5</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the T5 text embedding.`,name:"text_len_t5"},{anchor:"diffusers.HunyuanDiT2DModel.use_style_cond_and_image_meta_size",description:`<strong>use_style_cond_and_image_meta_size</strong> (<code>bool</code>,  <em>optional</em>) &#x2014;
Whether or not to use style condition and image meta size. True for version &lt;=1.1, False for version &gt;= 1.2`,name:"use_style_cond_and_image_meta_size"}],source:"https://github.com/huggingface/diffusers/blob/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L203"}}),I=new W({props:{name:"enable_forward_chunking",anchor:"diffusers.HunyuanDiT2DModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": Optional = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.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.HunyuanDiT2DModel.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/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L537"}}),A=new W({props:{name:"forward",anchor:"diffusers.HunyuanDiT2DModel.forward",parameters:[{name:"hidden_states",val:""},{name:"timestep",val:""},{name:"encoder_hidden_states",val:" = None"},{name:"text_embedding_mask",val:" = None"},{name:"encoder_hidden_states_t5",val:" = None"},{name:"text_embedding_mask_t5",val:" = None"},{name:"image_meta_size",val:" = None"},{name:"style",val:" = None"},{name:"image_rotary_emb",val:" = None"},{name:"controlnet_block_samples",val:" = None"},{name:"return_dict",val:" = True"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch size, dim, height, width)</code>) &#x2014;
The input tensor.`,name:"hidden_states"},{anchor:"diffusers.HunyuanDiT2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.HunyuanDiT2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of <code>BertModel</code>.
text_embedding_mask &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of <code>BertModel</code>.`,name:"encoder_hidden_states"},{anchor:"diffusers.HunyuanDiT2DModel.forward.encoder_hidden_states_t5",description:`<strong>encoder_hidden_states_t5</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of T5 Text Encoder.
text_embedding_mask_t5 &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of T5 Text Encoder.`,name:"encoder_hidden_states_t5"},{anchor:"diffusers.HunyuanDiT2DModel.forward.image_meta_size",description:`<strong>image_meta_size</strong> (torch.Tensor) &#x2014;
Conditional embedding indicate the image sizes
style &#x2014; torch.Tensor:
Conditional embedding indicate the style`,name:"image_meta_size"},{anchor:"diffusers.HunyuanDiT2DModel.forward.image_rotary_emb",description:`<strong>image_rotary_emb</strong> (<code>torch.Tensor</code>) &#x2014;
The image rotary embeddings to apply on query and key tensors during attention calculation.
return_dict &#x2014; bool
Whether to return a dictionary.`,name:"image_rotary_emb"}],source:"https://github.com/huggingface/diffusers/blob/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L424"}}),N=new W({props:{name:"fuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L321"}}),z=new Ae({props:{warning:!0,$$slots:{default:[Ke]},$$scope:{ctx:B}}}),V=new W({props:{name:"set_attn_processor",anchor:"diffusers.HunyuanDiT2DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DModel.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_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L384"}}),S=new W({props:{name:"set_default_attn_processor",anchor:"diffusers.HunyuanDiT2DModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L418"}}),O=new W({props:{name:"unfuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_8408/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L345"}}),P=new Ae({props:{warning:!0,$$slots:{default:[Qe]},$$scope:{ctx:B}}}),F=new Be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuan_transformer2d.md"}}),{c(){n=l("meta"),v=r(),c=l("p"),M=r(),f(j.$$.fragment),oe=r(),E=l("p"),E.innerHTML=ze,se=r(),f(q.$$.fragment),re=r(),s=l("div"),f(L.$$.fragment),ue=r(),K=l("p"),K.textContent=ke,fe=r(),Q=l("p"),Q.textContent=Ce,pe=r(),H=l("div"),f(I.$$.fragment),he=r(),G=l("p"),G.innerHTML=Pe,_e=r(),w=l("div"),f(A.$$.fragment),ge=r(),R=l("p"),R.innerHTML=je,be=r(),$=l("div"),f(N.$$.fragment),ye=r(),Y=l("p"),Y.textContent=Ee,ve=r(),f(z.$$.fragment),$e=r(),k=l("div"),f(V.$$.fragment),Te=r(),J=l("p"),J.textContent=qe,De=r(),C=l("div"),f(S.$$.fragment),xe=r(),X=l("p"),X.textContent=Le,Me=r(),T=l("div"),f(O.$$.fragment),He=r(),Z=l("p"),Z.textContent=Ie,we=r(),f(P.$$.fragment),ae=r(),f(F.$$.fragment),ie=r(),ne=l("p"),this.h()},l(e){const i=We("svelte-u9bgzb",document.head);n=m(i,"META",{name:!0,content:!0}),i.forEach(o),v=a(e),c=m(e,"P",{}),D(c).forEach(o),M=a(e),p(j.$$.fragment,e),oe=a(e),E=m(e,"P",{"data-svelte-h":!0}),y(E)!=="svelte-nkajjv"&&(E.innerHTML=ze),se=a(e),p(q.$$.fragment,e),re=a(e),s=m(e,"DIV",{class:!0});var d=D(s);p(L.$$.fragment,d),ue=a(d),K=m(d,"P",{"data-svelte-h":!0}),y(K)!=="svelte-rv6x8u"&&(K.textContent=ke),fe=a(d),Q=m(d,"P",{"data-svelte-h":!0}),y(Q)!=="svelte-wuyqug"&&(Q.textContent=Ce),pe=a(d),H=m(d,"DIV",{class:!0});var U=D(H);p(I.$$.fragment,U),he=a(U),G=m(U,"P",{"data-svelte-h":!0}),y(G)!=="svelte-2m23sy"&&(G.innerHTML=Pe),U.forEach(o),_e=a(d),w=m(d,"DIV",{class:!0});var le=D(w);p(A.$$.fragment,le),ge=a(le),R=m(le,"P",{"data-svelte-h":!0}),y(R)!=="svelte-m44y5j"&&(R.innerHTML=je),le.forEach(o),be=a(d),$=m(d,"DIV",{class:!0});var ee=D($);p(N.$$.fragment,ee),ye=a(ee),Y=m(ee,"P",{"data-svelte-h":!0}),y(Y)!=="svelte-1254b9i"&&(Y.textContent=Ee),ve=a(ee),p(z.$$.fragment,ee),ee.forEach(o),$e=a(d),k=m(d,"DIV",{class:!0});var me=D(k);p(V.$$.fragment,me),Te=a(me),J=m(me,"P",{"data-svelte-h":!0}),y(J)!=="svelte-1o77hl2"&&(J.textContent=qe),me.forEach(o),De=a(d),C=m(d,"DIV",{class:!0});var ce=D(C);p(S.$$.fragment,ce),xe=a(ce),X=m(ce,"P",{"data-svelte-h":!0}),y(X)!=="svelte-1lxcwhv"&&(X.textContent=Le),ce.forEach(o),Me=a(d),T=m(d,"DIV",{class:!0});var te=D(T);p(O.$$.fragment,te),He=a(te),Z=m(te,"P",{"data-svelte-h":!0}),y(Z)!=="svelte-1vhtc74"&&(Z.textContent=Ie),we=a(te),p(P.$$.fragment,te),te.forEach(o),d.forEach(o),ae=a(e),p(F.$$.fragment,e),ie=a(e),ne=m(e,"P",{}),D(ne).forEach(o),this.h()},h(){x(n,"name","hf:doc:metadata"),x(n,"content",Re),x(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(w,"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(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(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,i){t(document.head,n),u(e,v,i),u(e,c,i),u(e,M,i),h(j,e,i),u(e,oe,i),u(e,E,i),u(e,se,i),h(q,e,i),u(e,re,i),u(e,s,i),h(L,s,null),t(s,ue),t(s,K),t(s,fe),t(s,Q),t(s,pe),t(s,H),h(I,H,null),t(H,he),t(H,G),t(s,_e),t(s,w),h(A,w,null),t(w,ge),t(w,R),t(s,be),t(s,$),h(N,$,null),t($,ye),t($,Y),t($,ve),h(z,$,null),t(s,$e),t(s,k),h(V,k,null),t(k,Te),t(k,J),t(s,De),t(s,C),h(S,C,null),t(C,xe),t(C,X),t(s,Me),t(s,T),h(O,T,null),t(T,He),t(T,Z),t(T,we),h(P,T,null),u(e,ae,i),h(F,e,i),u(e,ie,i),u(e,ne,i),de=!0},p(e,[i]){const d={};i&2&&(d.$$scope={dirty:i,ctx:e}),z.$set(d);const U={};i&2&&(U.$$scope={dirty:i,ctx:e}),P.$set(U)},i(e){de||(_(j.$$.fragment,e),_(q.$$.fragment,e),_(L.$$.fragment,e),_(I.$$.fragment,e),_(A.$$.fragment,e),_(N.$$.fragment,e),_(z.$$.fragment,e),_(V.$$.fragment,e),_(S.$$.fragment,e),_(O.$$.fragment,e),_(P.$$.fragment,e),_(F.$$.fragment,e),de=!0)},o(e){g(j.$$.fragment,e),g(q.$$.fragment,e),g(L.$$.fragment,e),g(I.$$.fragment,e),g(A.$$.fragment,e),g(N.$$.fragment,e),g(z.$$.fragment,e),g(V.$$.fragment,e),g(S.$$.fragment,e),g(O.$$.fragment,e),g(P.$$.fragment,e),g(F.$$.fragment,e),de=!1},d(e){e&&(o(v),o(c),o(M),o(oe),o(E),o(se),o(re),o(s),o(ae),o(ie),o(ne)),o(n),b(j,e),b(q,e),b(L),b(I),b(A),b(N),b(z),b(V),b(S),b(O),b(P),b(F,e)}}}const Re='{"title":"HunyuanDiT2DModel","local":"hunyuandit2dmodel","sections":[{"title":"HunyuanDiT2DModel","local":"diffusers.HunyuanDiT2DModel","sections":[],"depth":2}],"depth":1}';function Ye(B){return Oe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nt extends Fe{constructor(n){super(),Ue(this,n,Ye,Ge,Se,{})}}export{nt as component};
