import{s as Q,n as X,o as Y}from"../chunks/scheduler.8c3d61f6.js";import{S as Z,i as ee,g as l,s as a,r as A,A as te,h as m,f as n,c as s,j as H,u as w,x as W,k as S,y as g,a as r,v as P,d as M,t as y,w as $}from"../chunks/index.589a98e8.js";import{D as R}from"../chunks/Docstring.27406313.js";import{H as J,E as ne}from"../chunks/EditOnGithub.e5a8d9cb.js";function oe(V){let i,k,v,z,f,N,c,B='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>.',O,p,C,o,u,q,x,G=`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>).`,j,d,_,U,b,K='The <a href="/docs/diffusers/pr_8489/en/api/models/pixart_transformer2d#diffusers.PixArtTransformer2DModel">PixArtTransformer2DModel</a> forward method.',L,h,I,D,F;return f=new J({props:{title:"PixArtTransformer2DModel",local:"pixarttransformer2dmodel",headingTag:"h1"}}),p=new J({props:{title:"PixArtTransformer2DModel",local:"diffusers.PixArtTransformer2DModel",headingTag:"h2"}}),u=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/vr_8489/src/diffusers/models/transformers/pixart_transformer_2d.py#L31"}}),_=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/pr_8489/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/vr_8489/src/diffusers/models/transformers/pixart_transformer_2d.py#L189",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>
`}}),h=new ne({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/pixart_transformer2d.md"}}),{c(){i=l("meta"),k=a(),v=l("p"),z=a(),A(f.$$.fragment),N=a(),c=l("p"),c.innerHTML=B,O=a(),A(p.$$.fragment),C=a(),o=l("div"),A(u.$$.fragment),q=a(),x=l("p"),x.innerHTML=G,j=a(),d=l("div"),A(_.$$.fragment),U=a(),b=l("p"),b.innerHTML=K,L=a(),A(h.$$.fragment),I=a(),D=l("p"),this.h()},l(e){const t=te("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),k=s(e),v=m(e,"P",{}),H(v).forEach(n),z=s(e),w(f.$$.fragment,e),N=s(e),c=m(e,"P",{"data-svelte-h":!0}),W(c)!=="svelte-1roynff"&&(c.innerHTML=B),O=s(e),w(p.$$.fragment,e),C=s(e),o=m(e,"DIV",{class:!0});var T=H(o);w(u.$$.fragment,T),q=s(T),x=m(T,"P",{"data-svelte-h":!0}),W(x)!=="svelte-1pwq02h"&&(x.innerHTML=G),j=s(T),d=m(T,"DIV",{class:!0});var E=H(d);w(_.$$.fragment,E),U=s(E),b=m(E,"P",{"data-svelte-h":!0}),W(b)!=="svelte-cs9djq"&&(b.innerHTML=K),E.forEach(n),T.forEach(n),L=s(e),w(h.$$.fragment,e),I=s(e),D=m(e,"P",{}),H(D).forEach(n),this.h()},h(){S(i,"name","hf:doc:metadata"),S(i,"content",re),S(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(o,"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,t){g(document.head,i),r(e,k,t),r(e,v,t),r(e,z,t),P(f,e,t),r(e,N,t),r(e,c,t),r(e,O,t),P(p,e,t),r(e,C,t),r(e,o,t),P(u,o,null),g(o,q),g(o,x),g(o,j),g(o,d),P(_,d,null),g(d,U),g(d,b),r(e,L,t),P(h,e,t),r(e,I,t),r(e,D,t),F=!0},p:X,i(e){F||(M(f.$$.fragment,e),M(p.$$.fragment,e),M(u.$$.fragment,e),M(_.$$.fragment,e),M(h.$$.fragment,e),F=!0)},o(e){y(f.$$.fragment,e),y(p.$$.fragment,e),y(u.$$.fragment,e),y(_.$$.fragment,e),y(h.$$.fragment,e),F=!1},d(e){e&&(n(k),n(v),n(z),n(N),n(c),n(O),n(C),n(o),n(L),n(I),n(D)),n(i),$(f,e),$(p,e),$(u),$(_),$(h,e)}}}const re='{"title":"PixArtTransformer2DModel","local":"pixarttransformer2dmodel","sections":[{"title":"PixArtTransformer2DModel","local":"diffusers.PixArtTransformer2DModel","sections":[],"depth":2}],"depth":1}';function ae(V){return Y(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class me extends Z{constructor(i){super(),ee(this,i,ae,oe,Q,{})}}export{me as component};
