import{s as je,n as Ne,o as Ie}from"../chunks/scheduler.53228c21.js";import{S as Oe,i as Ve,e as r,s as n,c as f,h as Ae,a as d,d as o,b as s,f as M,g as _,j as p,k as h,l as t,m,n as g,t as y,o as b,p as T}from"../chunks/index.100fac89.js";import{C as Se}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as G}from"../chunks/Docstring.49101787.js";import{H as Pe,E as Be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function Ke(xe){let D,J,R,X,H,Z,w,ee,k,$e='A Diffusion Transformer model for 2D data from <a href="https://github.com/Tencent/HunyuanDiT" rel="nofollow">Hunyuan-DiT</a>.',te,z,ne,i,C,le,V,Me="HunYuanDiT: Diffusion model with a Transformer backbone.",me,A,He="Inherit ModelMixin and ConfigMixin to be compatible with the sampler StableDiffusionPipeline of diffusers.",ue,v,L,ce,S,we=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,fe,x,q,_e,B,ke='The <a href="/docs/diffusers/main/en/api/models/hunyuan_transformer2d#diffusers.HunyuanDiT2DModel">HunyuanDiT2DModel</a> forward method.',pe,u,E,he,K,ze=`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.`,ge,P,Ce="<p>&gt; This API is 🧪 experimental.</p>",ye,$,j,be,Q,Le="Disables custom attention processors and sets the default attention implementation.",Te,c,N,De,U,qe="Disables the fused QKV projection if enabled.",ve,I,Ee="<p>&gt; This API is 🧪 experimental.</p>",oe,O,se,Y,ie;return H=new Se({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new Pe({props:{title:"HunyuanDiT2DModel",local:"hunyuandit2dmodel",headingTag:"h1"}}),z=new Pe({props:{title:"HunyuanDiT2DModel",local:"diffusers.HunyuanDiT2DModel",headingTag:"h2"}}),C=new G({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:": typing.Optional[int] = None"},{name:"patch_size",val:": typing.Optional[int] = 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/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L203"}}),L=new G({props:{name:"enable_forward_chunking",anchor:"diffusers.HunyuanDiT2DModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": typing.Optional[int] = 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/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L472"}}),q=new G({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>.`,name:"encoder_hidden_states"},{anchor:"diffusers.HunyuanDiT2DModel.forward.text_embedding_mask",description:`<strong>text_embedding_mask</strong> &#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:"text_embedding_mask"},{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.`,name:"encoder_hidden_states_t5"},{anchor:"diffusers.HunyuanDiT2DModel.forward.text_embedding_mask_t5",description:`<strong>text_embedding_mask_t5</strong> &#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:"text_embedding_mask_t5"},{anchor:"diffusers.HunyuanDiT2DModel.forward.image_meta_size",description:`<strong>image_meta_size</strong> (torch.Tensor) &#x2014;
Conditional embedding indicate the image sizes`,name:"image_meta_size"},{anchor:"diffusers.HunyuanDiT2DModel.forward.style",description:`<strong>style</strong> &#x2014; torch.Tensor:
Conditional embedding indicate the style`,name:"style"},{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.`,name:"image_rotary_emb"},{anchor:"diffusers.HunyuanDiT2DModel.forward.return_dict",description:`<strong>return_dict</strong> &#x2014; bool
Whether to return a dictionary.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L359"}}),E=new G({props:{name:"fuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L322"}}),j=new G({props:{name:"set_default_attn_processor",anchor:"diffusers.HunyuanDiT2DModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L353"}}),N=new G({props:{name:"unfuse_qkv_projections",anchor:"diffusers.HunyuanDiT2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/hunyuan_transformer_2d.py#L344"}}),O=new Be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuan_transformer2d.md"}}),{c(){D=r("meta"),J=n(),R=r("p"),X=n(),f(H.$$.fragment),Z=n(),f(w.$$.fragment),ee=n(),k=r("p"),k.innerHTML=$e,te=n(),f(z.$$.fragment),ne=n(),i=r("div"),f(C.$$.fragment),le=n(),V=r("p"),V.textContent=Me,me=n(),A=r("p"),A.textContent=He,ue=n(),v=r("div"),f(L.$$.fragment),ce=n(),S=r("p"),S.innerHTML=we,fe=n(),x=r("div"),f(q.$$.fragment),_e=n(),B=r("p"),B.innerHTML=ke,pe=n(),u=r("div"),f(E.$$.fragment),he=n(),K=r("p"),K.textContent=ze,ge=n(),P=r("blockquote"),P.innerHTML=Ce,ye=n(),$=r("div"),f(j.$$.fragment),be=n(),Q=r("p"),Q.textContent=Le,Te=n(),c=r("div"),f(N.$$.fragment),De=n(),U=r("p"),U.textContent=qe,ve=n(),I=r("blockquote"),I.innerHTML=Ee,oe=n(),f(O.$$.fragment),se=n(),Y=r("p"),this.h()},l(e){const a=Ae("svelte-u9bgzb",document.head);D=d(a,"META",{name:!0,content:!0}),a.forEach(o),J=s(e),R=d(e,"P",{}),M(R).forEach(o),X=s(e),_(H.$$.fragment,e),Z=s(e),_(w.$$.fragment,e),ee=s(e),k=d(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-nkajjv"&&(k.innerHTML=$e),te=s(e),_(z.$$.fragment,e),ne=s(e),i=d(e,"DIV",{class:!0});var l=M(i);_(C.$$.fragment,l),le=s(l),V=d(l,"P",{"data-svelte-h":!0}),p(V)!=="svelte-rv6x8u"&&(V.textContent=Me),me=s(l),A=d(l,"P",{"data-svelte-h":!0}),p(A)!=="svelte-wuyqug"&&(A.textContent=He),ue=s(l),v=d(l,"DIV",{class:!0});var ae=M(v);_(L.$$.fragment,ae),ce=s(ae),S=d(ae,"P",{"data-svelte-h":!0}),p(S)!=="svelte-2m23sy"&&(S.innerHTML=we),ae.forEach(o),fe=s(l),x=d(l,"DIV",{class:!0});var re=M(x);_(q.$$.fragment,re),_e=s(re),B=d(re,"P",{"data-svelte-h":!0}),p(B)!=="svelte-eoo91"&&(B.innerHTML=ke),re.forEach(o),pe=s(l),u=d(l,"DIV",{class:!0});var F=M(u);_(E.$$.fragment,F),he=s(F),K=d(F,"P",{"data-svelte-h":!0}),p(K)!=="svelte-1254b9i"&&(K.textContent=ze),ge=s(F),P=d(F,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(P)!=="svelte-6y4o4y"&&(P.innerHTML=Ce),F.forEach(o),ye=s(l),$=d(l,"DIV",{class:!0});var de=M($);_(j.$$.fragment,de),be=s(de),Q=d(de,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-1lxcwhv"&&(Q.textContent=Le),de.forEach(o),Te=s(l),c=d(l,"DIV",{class:!0});var W=M(c);_(N.$$.fragment,W),De=s(W),U=d(W,"P",{"data-svelte-h":!0}),p(U)!=="svelte-1vhtc74"&&(U.textContent=qe),ve=s(W),I=d(W,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),p(I)!=="svelte-6y4o4y"&&(I.innerHTML=Ee),W.forEach(o),l.forEach(o),oe=s(e),_(O.$$.fragment,e),se=s(e),Y=d(e,"P",{}),M(Y).forEach(o),this.h()},h(){h(D,"name","hf:doc:metadata"),h(D,"content",Qe),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(x,"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","warning"),h(u,"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(I,"class","warning"),h(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(i,"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,a){t(document.head,D),m(e,J,a),m(e,R,a),m(e,X,a),g(H,e,a),m(e,Z,a),g(w,e,a),m(e,ee,a),m(e,k,a),m(e,te,a),g(z,e,a),m(e,ne,a),m(e,i,a),g(C,i,null),t(i,le),t(i,V),t(i,me),t(i,A),t(i,ue),t(i,v),g(L,v,null),t(v,ce),t(v,S),t(i,fe),t(i,x),g(q,x,null),t(x,_e),t(x,B),t(i,pe),t(i,u),g(E,u,null),t(u,he),t(u,K),t(u,ge),t(u,P),t(i,ye),t(i,$),g(j,$,null),t($,be),t($,Q),t(i,Te),t(i,c),g(N,c,null),t(c,De),t(c,U),t(c,ve),t(c,I),m(e,oe,a),g(O,e,a),m(e,se,a),m(e,Y,a),ie=!0},p:Ne,i(e){ie||(y(H.$$.fragment,e),y(w.$$.fragment,e),y(z.$$.fragment,e),y(C.$$.fragment,e),y(L.$$.fragment,e),y(q.$$.fragment,e),y(E.$$.fragment,e),y(j.$$.fragment,e),y(N.$$.fragment,e),y(O.$$.fragment,e),ie=!0)},o(e){b(H.$$.fragment,e),b(w.$$.fragment,e),b(z.$$.fragment,e),b(C.$$.fragment,e),b(L.$$.fragment,e),b(q.$$.fragment,e),b(E.$$.fragment,e),b(j.$$.fragment,e),b(N.$$.fragment,e),b(O.$$.fragment,e),ie=!1},d(e){e&&(o(J),o(R),o(X),o(Z),o(ee),o(k),o(te),o(ne),o(i),o(oe),o(se),o(Y)),o(D),T(H,e),T(w,e),T(z,e),T(C),T(L),T(q),T(E),T(j),T(N),T(O,e)}}}const Qe='{"title":"HunyuanDiT2DModel","local":"hunyuandit2dmodel","sections":[{"title":"HunyuanDiT2DModel","local":"diffusers.HunyuanDiT2DModel","sections":[],"depth":2}],"depth":1}';function Ue(xe){return Ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends Oe{constructor(D){super(),Ve(this,D,Ue,Ke,je,{})}}export{Je as component};
