import{s as De,o as Ae,n as Te}from"../chunks/scheduler.8c3d61f6.js";import{S as Pe,i as we,g as l,s,r as h,A as Me,h as m,f as o,c as a,j as E,u as g,x as M,k as F,y as r,a as c,v as x,d as b,t as v,w as $}from"../chunks/index.da70eac4.js";import{T as ve}from"../chunks/Tip.1d9b8c37.js";import{D as R}from"../chunks/Docstring.6b390b9a.js";import{H as $e,E as ye}from"../chunks/EditOnGithub.1e64e623.js";function ke(S){let t,p="This API is 🧪 experimental.";return{c(){t=l("p"),t.textContent=p},l(i){t=m(i,"P",{"data-svelte-h":!0}),M(t)!=="svelte-89q1io"&&(t.textContent=p)},m(i,T){c(i,t,T)},p:Te,d(i){i&&o(t)}}}function Ce(S){let t,p="This API is 🧪 experimental.";return{c(){t=l("p"),t.textContent=p},l(i){t=m(i,"P",{"data-svelte-h":!0}),M(t)!=="svelte-89q1io"&&(t.textContent=p)},m(i,T){c(i,t,T)},p:Te,d(i){i&&o(t)}}}function ze(S){let t,p,i,T,y,J,k,ue='A Transformer model for image-like data from <a href="https://huggingface.co/papers/2310.00426" rel="nofollow">PixArt-Alpha</a> and <a href="https://huggingface.co/papers/2403.04692" rel="nofollow">PixArt-Sigma</a>.',X,C,Y,d,z,oe,H,_e=`A 2D Transformer model as introduced in PixArt family of models (<a href="https://arxiv.org/abs/2310.00426" rel="nofollow">https://arxiv.org/abs/2310.00426</a>,
<a href="https://arxiv.org/abs/2403.04692" rel="nofollow">https://arxiv.org/abs/2403.04692</a>).`,re,D,N,se,V,he='The <a href="/docs/diffusers/v0.30.3/en/api/models/pixart_transformer2d#diffusers.PixArtTransformer2DModel">PixArtTransformer2DModel</a> forward method.',ae,u,I,ie,U,ge=`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.`,de,A,le,P,O,me,K,xe="Sets the attention processor to use to compute attention.",fe,_,L,ce,W,be="Disables the fused QKV projection if enabled.",pe,w,Z,j,ee,G,te;return y=new $e({props:{title:"PixArtTransformer2DModel",local:"pixarttransformer2dmodel",headingTag:"h1"}}),C=new $e({props:{title:"PixArtTransformer2DModel",local:"diffusers.PixArtTransformer2DModel",headingTag:"h2"}}),z=new R({props:{name:"class diffusers.PixArtTransformer2DModel",anchor:"diffusers.PixArtTransformer2DModel",parameters:[{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 72"},{name:"in_channels",val:": int = 4"},{name:"out_channels",val:": Optional = 8"},{name:"num_layers",val:": int = 28"},{name:"dropout",val:": float = 0.0"},{name:"norm_num_groups",val:": int = 32"},{name:"cross_attention_dim",val:": Optional = 1152"},{name:"attention_bias",val:": bool = True"},{name:"sample_size",val:": int = 128"},{name:"patch_size",val:": int = 2"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"num_embeds_ada_norm",val:": Optional = 1000"},{name:"upcast_attention",val:": bool = False"},{name:"norm_type",val:": str = 'ada_norm_single'"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-06"},{name:"interpolation_scale",val:": Optional = None"},{name:"use_additional_conditions",val:": Optional = None"},{name:"caption_channels",val:": Optional = None"},{name:"attention_type",val:": Optional = 'default'"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.num_attention_heads",description:"<strong>num_attention_heads</strong> (int, optional, defaults to 16) &#x2014; The number of heads to use for multi-head attention.",name:"num_attention_heads"},{anchor:"diffusers.PixArtTransformer2DModel.attention_head_dim",description:"<strong>attention_head_dim</strong> (int, optional, defaults to 72) &#x2014; The number of channels in each head.",name:"attention_head_dim"},{anchor:"diffusers.PixArtTransformer2DModel.in_channels",description:"<strong>in_channels</strong> (int, defaults to 4) &#x2014; The number of channels in the input.",name:"in_channels"},{anchor:"diffusers.PixArtTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (int, optional) &#x2014;
The number of channels in the output. Specify this parameter if the output channel number differs from the
input.`,name:"out_channels"},{anchor:"diffusers.PixArtTransformer2DModel.num_layers",description:"<strong>num_layers</strong> (int, optional, defaults to 28) &#x2014; The number of layers of Transformer blocks to use.",name:"num_layers"},{anchor:"diffusers.PixArtTransformer2DModel.dropout",description:"<strong>dropout</strong> (float, optional, defaults to 0.0) &#x2014; The dropout probability to use within the Transformer blocks.",name:"dropout"},{anchor:"diffusers.PixArtTransformer2DModel.norm_num_groups",description:`<strong>norm_num_groups</strong> (int, optional, defaults to 32) &#x2014;
Number of groups for group normalization within Transformer blocks.`,name:"norm_num_groups"},{anchor:"diffusers.PixArtTransformer2DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (int, optional) &#x2014;
The dimensionality for cross-attention layers, typically matching the encoder&#x2019;s hidden dimension.`,name:"cross_attention_dim"},{anchor:"diffusers.PixArtTransformer2DModel.attention_bias",description:`<strong>attention_bias</strong> (bool, optional, defaults to True) &#x2014;
Configure if the Transformer blocks&#x2019; attention should contain a bias parameter.`,name:"attention_bias"},{anchor:"diffusers.PixArtTransformer2DModel.sample_size",description:`<strong>sample_size</strong> (int, defaults to 128) &#x2014;
The width of the latent images. This parameter is fixed during training.`,name:"sample_size"},{anchor:"diffusers.PixArtTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (int, defaults to 2) &#x2014;
Size of the patches the model processes, relevant for architectures working on non-sequential data.`,name:"patch_size"},{anchor:"diffusers.PixArtTransformer2DModel.activation_fn",description:`<strong>activation_fn</strong> (str, optional, defaults to &#x201C;gelu-approximate&#x201D;) &#x2014;
Activation function to use in feed-forward networks within Transformer blocks.`,name:"activation_fn"},{anchor:"diffusers.PixArtTransformer2DModel.num_embeds_ada_norm",description:`<strong>num_embeds_ada_norm</strong> (int, optional, defaults to 1000) &#x2014;
Number of embeddings for AdaLayerNorm, fixed during training and affects the maximum denoising steps during
inference.`,name:"num_embeds_ada_norm"},{anchor:"diffusers.PixArtTransformer2DModel.upcast_attention",description:`<strong>upcast_attention</strong> (bool, optional, defaults to False) &#x2014;
If true, upcasts the attention mechanism dimensions for potentially improved performance.`,name:"upcast_attention"},{anchor:"diffusers.PixArtTransformer2DModel.norm_type",description:`<strong>norm_type</strong> (str, optional, defaults to &#x201C;ada_norm_zero&#x201D;) &#x2014;
Specifies the type of normalization used, can be &#x2018;ada_norm_zero&#x2019;.`,name:"norm_type"},{anchor:"diffusers.PixArtTransformer2DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (bool, optional, defaults to False) &#x2014;
If true, enables element-wise affine parameters in the normalization layers.`,name:"norm_elementwise_affine"},{anchor:"diffusers.PixArtTransformer2DModel.norm_eps",description:`<strong>norm_eps</strong> (float, optional, defaults to 1e-6) &#x2014;
A small constant added to the denominator in normalization layers to prevent division by zero.`,name:"norm_eps"},{anchor:"diffusers.PixArtTransformer2DModel.interpolation_scale",description:"<strong>interpolation_scale</strong> (int, optional) &#x2014; Scale factor to use during interpolating the position embeddings.",name:"interpolation_scale"},{anchor:"diffusers.PixArtTransformer2DModel.use_additional_conditions",description:"<strong>use_additional_conditions</strong> (bool, optional) &#x2014; If we&#x2019;re using additional conditions as inputs.",name:"use_additional_conditions"},{anchor:"diffusers.PixArtTransformer2DModel.attention_type",description:"<strong>attention_type</strong> (str, optional, defaults to &#x201C;default&#x201D;) &#x2014; Kind of attention mechanism to be used.",name:"attention_type"},{anchor:"diffusers.PixArtTransformer2DModel.caption_channels",description:`<strong>caption_channels</strong> (int, optional, defaults to None) &#x2014;
Number of channels to use for projecting the caption embeddings.`,name:"caption_channels"},{anchor:"diffusers.PixArtTransformer2DModel.use_linear_projection",description:`<strong>use_linear_projection</strong> (bool, optional, defaults to False) &#x2014;
Deprecated argument. Will be removed in a future version.`,name:"use_linear_projection"},{anchor:"diffusers.PixArtTransformer2DModel.num_vector_embeds",description:`<strong>num_vector_embeds</strong> (bool, optional, defaults to False) &#x2014;
Deprecated argument. Will be removed in a future version.`,name:"num_vector_embeds"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.3/src/diffusers/models/transformers/pixart_transformer_2d.py#L32"}}),N=new R({props:{name:"forward",anchor:"diffusers.PixArtTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Optional = None"},{name:"timestep",val:": Optional = None"},{name:"added_cond_kwargs",val:": Dict = None"},{name:"cross_attention_kwargs",val:": Dict = None"},{name:"attention_mask",val:": Optional = None"},{name:"encoder_attention_mask",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.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.PixArtTransformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. If not given, cross-attention defaults to
self-attention.`,name:"encoder_hidden_states"},{anchor:"diffusers.PixArtTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Used to indicate denoising step. Optional timestep to be applied as an embedding in <code>AdaLayerNorm</code>.
added_cond_kwargs &#x2014; (<code>Dict[str, Any]</code>, <em>optional</em>): Additional conditions to be used as inputs.`,name:"timestep"},{anchor:"diffusers.PixArtTransformer2DModel.forward.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> ( <code>Dict[str, Any]</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:"cross_attention_kwargs"},{anchor:"diffusers.PixArtTransformer2DModel.forward.attention_mask",description:`<strong>attention_mask</strong> ( <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. If <code>1</code> the mask
is kept, otherwise if <code>0</code> it is discarded. Mask will be converted into a bias, which adds large
negative values to the attention scores corresponding to &#x201C;discard&#x201D; tokens.`,name:"attention_mask"},{anchor:"diffusers.PixArtTransformer2DModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> ( <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Cross-attention mask applied to <code>encoder_hidden_states</code>. Two formats supported:</p>
<ul>
<li>Mask <code>(batch, sequence_length)</code> True = keep, False = discard.</li>
<li>Bias <code>(batch, 1, sequence_length)</code> 0 = keep, -10000 = discard.</li>
</ul>
<p>If <code>ndim == 2</code>: will be interpreted as a mask, then converted into a bias consistent with the format
above. This bias will be added to the cross-attention scores.`,name:"encoder_attention_mask"},{anchor:"diffusers.PixArtTransformer2DModel.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 <a href="/docs/diffusers/v0.30.3/en/api/models/unet2d-cond#diffusers.models.unets.unet_2d_condition.UNet2DConditionOutput">UNet2DConditionOutput</a> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.30.3/src/diffusers/models/transformers/pixart_transformer_2d.py#L290",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>
`}}),I=new R({props:{name:"fuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.30.3/src/diffusers/models/transformers/pixart_transformer_2d.py#L251"}}),A=new ve({props:{warning:!0,$$slots:{default:[ke]},$$scope:{ctx:S}}}),O=new R({props:{name:"set_attn_processor",anchor:"diffusers.PixArtTransformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.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/v0.30.3/src/diffusers/models/transformers/pixart_transformer_2d.py#L216"}}),L=new R({props:{name:"unfuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.30.3/src/diffusers/models/transformers/pixart_transformer_2d.py#L277"}}),w=new ve({props:{warning:!0,$$slots:{default:[Ce]},$$scope:{ctx:S}}}),j=new ye({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/pixart_transformer2d.md"}}),{c(){t=l("meta"),p=s(),i=l("p"),T=s(),h(y.$$.fragment),J=s(),k=l("p"),k.innerHTML=ue,X=s(),h(C.$$.fragment),Y=s(),d=l("div"),h(z.$$.fragment),oe=s(),H=l("p"),H.innerHTML=_e,re=s(),D=l("div"),h(N.$$.fragment),se=s(),V=l("p"),V.innerHTML=he,ae=s(),u=l("div"),h(I.$$.fragment),ie=s(),U=l("p"),U.textContent=ge,de=s(),h(A.$$.fragment),le=s(),P=l("div"),h(O.$$.fragment),me=s(),K=l("p"),K.textContent=xe,fe=s(),_=l("div"),h(L.$$.fragment),ce=s(),W=l("p"),W.textContent=be,pe=s(),h(w.$$.fragment),Z=s(),h(j.$$.fragment),ee=s(),G=l("p"),this.h()},l(e){const n=Me("svelte-u9bgzb",document.head);t=m(n,"META",{name:!0,content:!0}),n.forEach(o),p=a(e),i=m(e,"P",{}),E(i).forEach(o),T=a(e),g(y.$$.fragment,e),J=a(e),k=m(e,"P",{"data-svelte-h":!0}),M(k)!=="svelte-p8z7gn"&&(k.innerHTML=ue),X=a(e),g(C.$$.fragment,e),Y=a(e),d=m(e,"DIV",{class:!0});var f=E(d);g(z.$$.fragment,f),oe=a(f),H=m(f,"P",{"data-svelte-h":!0}),M(H)!=="svelte-1pwq02h"&&(H.innerHTML=_e),re=a(f),D=m(f,"DIV",{class:!0});var q=E(D);g(N.$$.fragment,q),se=a(q),V=m(q,"P",{"data-svelte-h":!0}),M(V)!=="svelte-2aotau"&&(V.innerHTML=he),q.forEach(o),ae=a(f),u=m(f,"DIV",{class:!0});var Q=E(u);g(I.$$.fragment,Q),ie=a(Q),U=m(Q,"P",{"data-svelte-h":!0}),M(U)!=="svelte-1254b9i"&&(U.textContent=ge),de=a(Q),g(A.$$.fragment,Q),Q.forEach(o),le=a(f),P=m(f,"DIV",{class:!0});var ne=E(P);g(O.$$.fragment,ne),me=a(ne),K=m(ne,"P",{"data-svelte-h":!0}),M(K)!=="svelte-1o77hl2"&&(K.textContent=xe),ne.forEach(o),fe=a(f),_=m(f,"DIV",{class:!0});var B=E(_);g(L.$$.fragment,B),ce=a(B),W=m(B,"P",{"data-svelte-h":!0}),M(W)!=="svelte-1vhtc74"&&(W.textContent=be),pe=a(B),g(w.$$.fragment,B),B.forEach(o),f.forEach(o),Z=a(e),g(j.$$.fragment,e),ee=a(e),G=m(e,"P",{}),E(G).forEach(o),this.h()},h(){F(t,"name","hf:doc:metadata"),F(t,"content",Ne),F(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(d,"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,n){r(document.head,t),c(e,p,n),c(e,i,n),c(e,T,n),x(y,e,n),c(e,J,n),c(e,k,n),c(e,X,n),x(C,e,n),c(e,Y,n),c(e,d,n),x(z,d,null),r(d,oe),r(d,H),r(d,re),r(d,D),x(N,D,null),r(D,se),r(D,V),r(d,ae),r(d,u),x(I,u,null),r(u,ie),r(u,U),r(u,de),x(A,u,null),r(d,le),r(d,P),x(O,P,null),r(P,me),r(P,K),r(d,fe),r(d,_),x(L,_,null),r(_,ce),r(_,W),r(_,pe),x(w,_,null),c(e,Z,n),x(j,e,n),c(e,ee,n),c(e,G,n),te=!0},p(e,[n]){const f={};n&2&&(f.$$scope={dirty:n,ctx:e}),A.$set(f);const q={};n&2&&(q.$$scope={dirty:n,ctx:e}),w.$set(q)},i(e){te||(b(y.$$.fragment,e),b(C.$$.fragment,e),b(z.$$.fragment,e),b(N.$$.fragment,e),b(I.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(L.$$.fragment,e),b(w.$$.fragment,e),b(j.$$.fragment,e),te=!0)},o(e){v(y.$$.fragment,e),v(C.$$.fragment,e),v(z.$$.fragment,e),v(N.$$.fragment,e),v(I.$$.fragment,e),v(A.$$.fragment,e),v(O.$$.fragment,e),v(L.$$.fragment,e),v(w.$$.fragment,e),v(j.$$.fragment,e),te=!1},d(e){e&&(o(p),o(i),o(T),o(J),o(k),o(X),o(Y),o(d),o(Z),o(ee),o(G)),o(t),$(y,e),$(C,e),$(z),$(N),$(I),$(A),$(O),$(L),$(w),$(j,e)}}}const Ne='{"title":"PixArtTransformer2DModel","local":"pixarttransformer2dmodel","sections":[{"title":"PixArtTransformer2DModel","local":"diffusers.PixArtTransformer2DModel","sections":[],"depth":2}],"depth":1}';function Ie(S){return Ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fe extends Pe{constructor(t){super(),we(this,t,Ie,ze,De,{})}}export{Fe as component};
