import{s as X,n as Y,o as ee}from"../chunks/scheduler.53228c21.js";import{S as ne,i as te,e as m,s as a,c as $,h as oe,a as l,d as t,b as s,f as U,g as v,j as R,k as q,l as T,m as o,n as M,t as w,o as y,p as z}from"../chunks/index.100fac89.js";import{C as re}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as K}from"../chunks/Docstring.49101787.js";import{H as Q,E as ae}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function se(W){let i,A,L,C,f,N,c,O,p,Z='A Transformer model for image-like data from <a href="https://huggingface.co/papers/2212.09748" rel="nofollow">DiT</a>.',P,u,E,r,h,V,D,B='A 2D Transformer model as introduced in DiT (<a href="https://huggingface.co/papers/2212.09748" rel="nofollow">https://huggingface.co/papers/2212.09748</a>).',j,d,_,G,b,J='The <a href="/docs/diffusers/main/en/api/models/dit_transformer2d#diffusers.DiTTransformer2DModel">DiTTransformer2DModel</a> forward method.',H,g,S,k,I;return f=new re({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new Q({props:{title:"DiTTransformer2DModel",local:"dittransformer2dmodel",headingTag:"h1"}}),u=new Q({props:{title:"DiTTransformer2DModel",local:"diffusers.DiTTransformer2DModel",headingTag:"h2"}}),h=new K({props:{name:"class diffusers.DiTTransformer2DModel",anchor:"diffusers.DiTTransformer2DModel",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:": typing.Optional[int] = None"},{name:"num_layers",val:": int = 28"},{name:"dropout",val:": float = 0.0"},{name:"norm_num_groups",val:": int = 32"},{name:"attention_bias",val:": bool = True"},{name:"sample_size",val:": int = 32"},{name:"patch_size",val:": int = 2"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"num_embeds_ada_norm",val:": typing.Optional[int] = 1000"},{name:"upcast_attention",val:": bool = False"},{name:"norm_type",val:": str = 'ada_norm_zero'"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-05"}],parametersDescription:[{anchor:"diffusers.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.in_channels",description:"<strong>in_channels</strong> (int, defaults to 4) &#x2014; The number of channels in the input.",name:"in_channels"},{anchor:"diffusers.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.sample_size",description:`<strong>sample_size</strong> (int, defaults to 32) &#x2014;
The width of the latent images. This parameter is fixed during training.`,name:"sample_size"},{anchor:"diffusers.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.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.DiTTransformer2DModel.norm_eps",description:`<strong>norm_eps</strong> (float, optional, defaults to 1e-5) &#x2014;
A small constant added to the denominator in normalization layers to prevent division by zero.`,name:"norm_eps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/dit_transformer_2d.py#L31"}}),_=new K({props:{name:"forward",anchor:"diffusers.DiTTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"timestep",val:": typing.Optional[torch.LongTensor] = None"},{name:"class_labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"cross_attention_kwargs",val:": typing.Dict[str, typing.Any] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DiTTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.LongTensor</code> of shape <code>(batch size, num latent pixels)</code> if discrete, <code>torch.FloatTensor</code> of shape <code>(batch size, channel, height, width)</code> if continuous) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.DiTTransformer2DModel.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>.`,name:"timestep"},{anchor:"diffusers.DiTTransformer2DModel.forward.class_labels",description:`<strong>class_labels</strong> ( <code>torch.LongTensor</code> of shape <code>(batch size, num classes)</code>, <em>optional</em>) &#x2014;
Used to indicate class labels conditioning. Optional class labels to be applied as an embedding in
<code>AdaLayerZeroNorm</code>.`,name:"class_labels"},{anchor:"diffusers.DiTTransformer2DModel.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.DiTTransformer2DModel.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/main/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/main/src/diffusers/models/transformers/dit_transformer_2d.py#L148",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>
`}}),g=new ae({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/dit_transformer2d.md"}}),{c(){i=m("meta"),A=a(),L=m("p"),C=a(),$(f.$$.fragment),N=a(),$(c.$$.fragment),O=a(),p=m("p"),p.innerHTML=Z,P=a(),$(u.$$.fragment),E=a(),r=m("div"),$(h.$$.fragment),V=a(),D=m("p"),D.innerHTML=B,j=a(),d=m("div"),$(_.$$.fragment),G=a(),b=m("p"),b.innerHTML=J,H=a(),$(g.$$.fragment),S=a(),k=m("p"),this.h()},l(e){const n=oe("svelte-u9bgzb",document.head);i=l(n,"META",{name:!0,content:!0}),n.forEach(t),A=s(e),L=l(e,"P",{}),U(L).forEach(t),C=s(e),v(f.$$.fragment,e),N=s(e),v(c.$$.fragment,e),O=s(e),p=l(e,"P",{"data-svelte-h":!0}),R(p)!=="svelte-14u6i1s"&&(p.innerHTML=Z),P=s(e),v(u.$$.fragment,e),E=s(e),r=l(e,"DIV",{class:!0});var x=U(r);v(h.$$.fragment,x),V=s(x),D=l(x,"P",{"data-svelte-h":!0}),R(D)!=="svelte-auif6k"&&(D.innerHTML=B),j=s(x),d=l(x,"DIV",{class:!0});var F=U(d);v(_.$$.fragment,F),G=s(F),b=l(F,"P",{"data-svelte-h":!0}),R(b)!=="svelte-f3xg4i"&&(b.innerHTML=J),F.forEach(t),x.forEach(t),H=s(e),v(g.$$.fragment,e),S=s(e),k=l(e,"P",{}),U(k).forEach(t),this.h()},h(){q(i,"name","hf:doc:metadata"),q(i,"content",ie),q(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(r,"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){T(document.head,i),o(e,A,n),o(e,L,n),o(e,C,n),M(f,e,n),o(e,N,n),M(c,e,n),o(e,O,n),o(e,p,n),o(e,P,n),M(u,e,n),o(e,E,n),o(e,r,n),M(h,r,null),T(r,V),T(r,D),T(r,j),T(r,d),M(_,d,null),T(d,G),T(d,b),o(e,H,n),M(g,e,n),o(e,S,n),o(e,k,n),I=!0},p:Y,i(e){I||(w(f.$$.fragment,e),w(c.$$.fragment,e),w(u.$$.fragment,e),w(h.$$.fragment,e),w(_.$$.fragment,e),w(g.$$.fragment,e),I=!0)},o(e){y(f.$$.fragment,e),y(c.$$.fragment,e),y(u.$$.fragment,e),y(h.$$.fragment,e),y(_.$$.fragment,e),y(g.$$.fragment,e),I=!1},d(e){e&&(t(A),t(L),t(C),t(N),t(O),t(p),t(P),t(E),t(r),t(H),t(S),t(k)),t(i),z(f,e),z(c,e),z(u,e),z(h),z(_),z(g,e)}}}const ie='{"title":"DiTTransformer2DModel","local":"dittransformer2dmodel","sections":[{"title":"DiTTransformer2DModel","local":"diffusers.DiTTransformer2DModel","sections":[],"depth":2}],"depth":1}';function de(W){return ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ue extends ne{constructor(i){super(),te(this,i,de,se,X,{})}}export{ue as component};
