import{s as _e,n as Te,o as we}from"../chunks/scheduler.8c3d61f6.js";import{S as be,i as ve,g as a,s,r as f,A as Me,h as d,f as t,c as r,j as E,u,x as R,k as H,y as l,a as n,v as p,d as g,t as h,w as _}from"../chunks/index.da70eac4.js";import{D as te}from"../chunks/Docstring.6b390b9a.js";import{C as $e}from"../chunks/CodeBlock.00a903b3.js";import{H as le,E as De}from"../chunks/EditOnGithub.1e64e623.js";function xe(ce){let c,O,X,S,v,j,M,me='A Diffusion Transformer model for 2D data from <a href="https://github.com/THUDM/CogView3" rel="nofollow">CogView3Plus</a> was introduced in <a href="https://huggingface.co/papers/2403.05121" rel="nofollow">CogView3: Finer and Faster Text-to-Image Generation via Relay Diffusion</a> by Tsinghua University &amp; ZhipuAI.',G,$,fe="The model can be loaded with the following code snippet.",q,D,A,x,N,i,C,se,L,ue=`The Transformer model introduced in <a href="https://huggingface.co/papers/2403.05121" rel="nofollow">CogView3: Finer and Faster Text-to-Image Generation via Relay
Diffusion</a>.`,re,T,y,ne,U,pe='The <a href="/docs/diffusers/pr_7018/en/api/models/cogview3plus_transformer2d#diffusers.CogView3PlusTransformer2DModel">CogView3PlusTransformer2DModel</a> forward method.',ie,w,V,ae,I,ge="Sets the attention processor to use to compute attention.",F,P,Y,m,z,de,k,he='The output of <a href="/docs/diffusers/pr_7018/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',B,Z,J,W,Q;return v=new le({props:{title:"CogView3PlusTransformer2DModel",local:"cogview3plustransformer2dmodel",headingTag:"h1"}}),D=new $e({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZXczUGx1c1RyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXZhZSUyMCUzRCUyMENvZ1ZpZXczUGx1c1RyYW5zZm9ybWVyMkRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyVEhVRE0lMkZDb2dWaWV3M1BsdXMtM2IlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogView3PlusTransformer2DModel

vae = CogView3PlusTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;THUDM/CogView3Plus-3b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),x=new le({props:{title:"CogView3PlusTransformer2DModel",local:"diffusers.CogView3PlusTransformer2DModel",headingTag:"h2"}}),C=new te({props:{name:"class diffusers.CogView3PlusTransformer2DModel",anchor:"diffusers.CogView3PlusTransformer2DModel",parameters:[{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 16"},{name:"num_layers",val:": int = 30"},{name:"attention_head_dim",val:": int = 40"},{name:"num_attention_heads",val:": int = 64"},{name:"out_channels",val:": int = 16"},{name:"text_embed_dim",val:": int = 4096"},{name:"time_embed_dim",val:": int = 512"},{name:"condition_dim",val:": int = 256"},{name:"pos_embed_max_size",val:": int = 128"},{name:"sample_size",val:": int = 128"}],parametersDescription:[{anchor:"diffusers.CogView3PlusTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The size of the patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.CogView3PlusTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>30</code>) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.CogView3PlusTransformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.CogView3PlusTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CogView3PlusTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CogView3PlusTransformer2DModel.text_embed_dim",description:`<strong>text_embed_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
Input dimension of text embeddings from the text encoder.`,name:"text_embed_dim"},{anchor:"diffusers.CogView3PlusTransformer2DModel.time_embed_dim",description:`<strong>time_embed_dim</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
Output dimension of timestep embeddings.`,name:"time_embed_dim"},{anchor:"diffusers.CogView3PlusTransformer2DModel.condition_dim",description:`<strong>condition_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
The embedding dimension of the input SDXL-style resolution conditions (original_size, target_size,
crop_coords).`,name:"condition_dim"},{anchor:"diffusers.CogView3PlusTransformer2DModel.pos_embed_max_size",description:`<strong>pos_embed_max_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The maximum resolution of the positional embeddings, from which slices of shape <code>H x W</code> are taken and added
to input patched latents, where <code>H</code> and <code>W</code> are the latent height and width respectively. A value of 128
means that the maximum supported height and width for image generation is <code>128 * vae_scale_factor * patch_size =&gt; 128 * 8 * 2 =&gt; 2048</code>.`,name:"pos_embed_max_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The base resolution of input latents. If height/width is not provided during generation, this value is used
to determine the resolution as <code>sample_size * vae_scale_factor =&gt; 128 * 8 =&gt; 1024</code>`,name:"sample_size"}],source:"https://github.com/huggingface/diffusers/blob/vr_7018/src/diffusers/models/transformers/transformer_cogview3plus.py#L133"}}),y=new te({props:{name:"forward",anchor:"diffusers.CogView3PlusTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"timestep",val:": LongTensor"},{name:"original_size",val:": Tensor"},{name:"target_size",val:": Tensor"},{name:"crop_coords",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input <code>hidden_states</code> of shape <code>(batch size, channel, height, width)</code>.`,name:"hidden_states"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) of shape
<code>(batch_size, sequence_len, text_embed_dim)</code>`,name:"encoder_hidden_states"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.original_size",description:`<strong>original_size</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for original image size as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"original_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.target_size",description:`<strong>target_size</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for target image size as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"target_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.crop_coords",description:`<strong>crop_coords</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for crop coordinates as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"crop_coords"},{anchor:"diffusers.CogView3PlusTransformer2DModel.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 <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_7018/src/diffusers/models/transformers/transformer_cogview3plus.py#L294",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The denoised latents using provided inputs as conditioning.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.Tensor</code> or <code>~models.transformer_2d.Transformer2DModelOutput</code></p>
`}}),V=new te({props:{name:"set_attn_processor",anchor:"diffusers.CogView3PlusTransformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.CogView3PlusTransformer2DModel.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_7018/src/diffusers/models/transformers/transformer_cogview3plus.py#L256"}}),P=new le({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),z=new te({props:{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",parameters:[{name:"sample",val:": torch.Tensor"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>(batch size, num_vector_embeds - 1, num_latent_pixels)</code> if <a href="/docs/diffusers/pr_7018/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input. If discrete, returns probability
distributions for the unnoised latent pixels.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/vr_7018/src/diffusers/models/modeling_outputs.py#L20"}}),Z=new De({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogview3plus_transformer2d.md"}}),{c(){c=a("meta"),O=s(),X=a("p"),S=s(),f(v.$$.fragment),j=s(),M=a("p"),M.innerHTML=me,G=s(),$=a("p"),$.textContent=fe,q=s(),f(D.$$.fragment),A=s(),f(x.$$.fragment),N=s(),i=a("div"),f(C.$$.fragment),se=s(),L=a("p"),L.innerHTML=ue,re=s(),T=a("div"),f(y.$$.fragment),ne=s(),U=a("p"),U.innerHTML=pe,ie=s(),w=a("div"),f(V.$$.fragment),ae=s(),I=a("p"),I.textContent=ge,F=s(),f(P.$$.fragment),Y=s(),m=a("div"),f(z.$$.fragment),de=s(),k=a("p"),k.innerHTML=he,B=s(),f(Z.$$.fragment),J=s(),W=a("p"),this.h()},l(e){const o=Me("svelte-u9bgzb",document.head);c=d(o,"META",{name:!0,content:!0}),o.forEach(t),O=r(e),X=d(e,"P",{}),E(X).forEach(t),S=r(e),u(v.$$.fragment,e),j=r(e),M=d(e,"P",{"data-svelte-h":!0}),R(M)!=="svelte-1vlmqph"&&(M.innerHTML=me),G=r(e),$=d(e,"P",{"data-svelte-h":!0}),R($)!=="svelte-1vuni30"&&($.textContent=fe),q=r(e),u(D.$$.fragment,e),A=r(e),u(x.$$.fragment,e),N=r(e),i=d(e,"DIV",{class:!0});var b=E(i);u(C.$$.fragment,b),se=r(b),L=d(b,"P",{"data-svelte-h":!0}),R(L)!=="svelte-1y8vmfa"&&(L.innerHTML=ue),re=r(b),T=d(b,"DIV",{class:!0});var K=E(T);u(y.$$.fragment,K),ne=r(K),U=d(K,"P",{"data-svelte-h":!0}),R(U)!=="svelte-1npti2i"&&(U.innerHTML=pe),K.forEach(t),ie=r(b),w=d(b,"DIV",{class:!0});var ee=E(w);u(V.$$.fragment,ee),ae=r(ee),I=d(ee,"P",{"data-svelte-h":!0}),R(I)!=="svelte-1o77hl2"&&(I.textContent=ge),ee.forEach(t),b.forEach(t),F=r(e),u(P.$$.fragment,e),Y=r(e),m=d(e,"DIV",{class:!0});var oe=E(m);u(z.$$.fragment,oe),de=r(oe),k=d(oe,"P",{"data-svelte-h":!0}),R(k)!=="svelte-n4uv2"&&(k.innerHTML=he),oe.forEach(t),B=r(e),u(Z.$$.fragment,e),J=r(e),W=d(e,"P",{}),E(W).forEach(t),this.h()},h(){H(c,"name","hf:doc:metadata"),H(c,"content",Ce),H(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(w,"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"),H(m,"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,o){l(document.head,c),n(e,O,o),n(e,X,o),n(e,S,o),p(v,e,o),n(e,j,o),n(e,M,o),n(e,G,o),n(e,$,o),n(e,q,o),p(D,e,o),n(e,A,o),p(x,e,o),n(e,N,o),n(e,i,o),p(C,i,null),l(i,se),l(i,L),l(i,re),l(i,T),p(y,T,null),l(T,ne),l(T,U),l(i,ie),l(i,w),p(V,w,null),l(w,ae),l(w,I),n(e,F,o),p(P,e,o),n(e,Y,o),n(e,m,o),p(z,m,null),l(m,de),l(m,k),n(e,B,o),p(Z,e,o),n(e,J,o),n(e,W,o),Q=!0},p:Te,i(e){Q||(g(v.$$.fragment,e),g(D.$$.fragment,e),g(x.$$.fragment,e),g(C.$$.fragment,e),g(y.$$.fragment,e),g(V.$$.fragment,e),g(P.$$.fragment,e),g(z.$$.fragment,e),g(Z.$$.fragment,e),Q=!0)},o(e){h(v.$$.fragment,e),h(D.$$.fragment,e),h(x.$$.fragment,e),h(C.$$.fragment,e),h(y.$$.fragment,e),h(V.$$.fragment,e),h(P.$$.fragment,e),h(z.$$.fragment,e),h(Z.$$.fragment,e),Q=!1},d(e){e&&(t(O),t(X),t(S),t(j),t(M),t(G),t($),t(q),t(A),t(N),t(i),t(F),t(Y),t(m),t(B),t(J),t(W)),t(c),_(v,e),_(D,e),_(x,e),_(C),_(y),_(V),_(P,e),_(z),_(Z,e)}}}const Ce='{"title":"CogView3PlusTransformer2DModel","local":"cogview3plustransformer2dmodel","sections":[{"title":"CogView3PlusTransformer2DModel","local":"diffusers.CogView3PlusTransformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function ye(ce){return we(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends be{constructor(c){super(),ve(this,c,ye,xe,_e,{})}}export{Ue as component};
