import{s as Ce,n as De,o as Ve}from"../chunks/scheduler.53228c21.js";import{S as we,i as Xe,e as i,s as n,c,h as qe,a as d,d as o,b as s,f as R,g as p,j as x,k as $,l as a,m as r,n as u,t as g,o as _,p as h}from"../chunks/index.100fac89.js";import{C as je}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as ae}from"../chunks/Docstring.49101787.js";import{C as He}from"../chunks/CodeBlock.d30a6509.js";import{H as ge,E as Ue}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function ke(_e){let b,G,W,A,M,N,y,Q,C,he='A Diffusion Transformer model for 3D data from <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a> was introduced in <a href="https://github.com/THUDM/CogVideo/blob/main/resources/CogVideoX.pdf" rel="nofollow">CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer</a> by Tsinghua University &amp; ZhipuAI.',K,D,be="The model can be loaded with the following code snippet.",Y,V,F,w,B,l,X,ie,E,Te='A Transformer model for video-like data in <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a>.',de,m,q,le,z,ve=`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.`,me,j,xe="<p>&gt; This API is 🧪 experimental.</p>",fe,f,H,ce,O,$e="Disables the fused QKV projection if enabled.",pe,U,Me="<p>&gt; This API is 🧪 experimental.</p>",ee,k,te,T,L,ue,I,ye='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',oe,Z,ne,S,se;return M=new je({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new ge({props:{title:"CogVideoXTransformer3DModel",local:"cogvideoxtransformer3dmodel",headingTag:"h1"}}),V=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZGVvWFRyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQ29nVmlkZW9YVHJhbnNmb3JtZXIzRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJUSFVETSUyRkNvZ1ZpZGVvWC0yYiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel

transformer = CogVideoXTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;THUDM/CogVideoX-2b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),w=new ge({props:{title:"CogVideoXTransformer3DModel",local:"diffusers.CogVideoXTransformer3DModel",headingTag:"h2"}}),X=new ae({props:{name:"class diffusers.CogVideoXTransformer3DModel",anchor:"diffusers.CogVideoXTransformer3DModel",parameters:[{name:"num_attention_heads",val:": int = 30"},{name:"attention_head_dim",val:": int = 64"},{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": typing.Optional[int] = 16"},{name:"flip_sin_to_cos",val:": bool = True"},{name:"freq_shift",val:": int = 0"},{name:"time_embed_dim",val:": int = 512"},{name:"ofs_embed_dim",val:": typing.Optional[int] = None"},{name:"text_embed_dim",val:": int = 4096"},{name:"num_layers",val:": int = 30"},{name:"dropout",val:": float = 0.0"},{name:"attention_bias",val:": bool = True"},{name:"sample_width",val:": int = 90"},{name:"sample_height",val:": int = 60"},{name:"sample_frames",val:": int = 49"},{name:"patch_size",val:": int = 2"},{name:"patch_size_t",val:": typing.Optional[int] = None"},{name:"temporal_compression_ratio",val:": int = 4"},{name:"max_text_seq_length",val:": int = 226"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"timestep_activation_fn",val:": str = 'silu'"},{name:"norm_elementwise_affine",val:": bool = True"},{name:"norm_eps",val:": float = 1e-05"},{name:"spatial_interpolation_scale",val:": float = 1.875"},{name:"temporal_interpolation_scale",val:": float = 1.0"},{name:"use_rotary_positional_embeddings",val:": bool = False"},{name:"use_learned_positional_embeddings",val:": bool = False"},{name:"patch_bias",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CogVideoXTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>30</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CogVideoXTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CogVideoXTransformer3DModel.flip_sin_to_cos",description:`<strong>flip_sin_to_cos</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to flip the sin to cos in the time embedding.`,name:"flip_sin_to_cos"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.ofs_embed_dim",description:`<strong>ofs_embed_dim</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
Output dimension of &#x201C;ofs&#x201D; embeddings used in CogVideoX-5b-I2B in version 1.5`,name:"ofs_embed_dim"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.dropout",description:`<strong>dropout</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The dropout probability to use.`,name:"dropout"},{anchor:"diffusers.CogVideoXTransformer3DModel.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use bias in the attention projection layers.`,name:"attention_bias"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_width",description:`<strong>sample_width</strong> (<code>int</code>, defaults to <code>90</code>) &#x2014;
The width of the input latents.`,name:"sample_width"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_height",description:`<strong>sample_height</strong> (<code>int</code>, defaults to <code>60</code>) &#x2014;
The height of the input latents.`,name:"sample_height"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_frames",description:`<strong>sample_frames</strong> (<code>int</code>, defaults to <code>49</code>) &#x2014;
The number of frames in the input latents. Note that this parameter was incorrectly initialized to 49
instead of 13 because CogVideoX processed 13 latent frames at once in its default and recommended settings,
but cannot be changed to the correct value to ensure backwards compatibility. To create a transformer with
K latent frames, the correct value to pass here would be: ((K - 1) * temporal_compression_ratio + 1).`,name:"sample_frames"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.temporal_compression_ratio",description:`<strong>temporal_compression_ratio</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
The compression ratio across the temporal dimension. See documentation for <code>sample_frames</code>.`,name:"temporal_compression_ratio"},{anchor:"diffusers.CogVideoXTransformer3DModel.max_text_seq_length",description:`<strong>max_text_seq_length</strong> (<code>int</code>, defaults to <code>226</code>) &#x2014;
The maximum sequence length of the input text embeddings.`,name:"max_text_seq_length"},{anchor:"diffusers.CogVideoXTransformer3DModel.activation_fn",description:`<strong>activation_fn</strong> (<code>str</code>, defaults to <code>&quot;gelu-approximate&quot;</code>) &#x2014;
Activation function to use in feed-forward.`,name:"activation_fn"},{anchor:"diffusers.CogVideoXTransformer3DModel.timestep_activation_fn",description:`<strong>timestep_activation_fn</strong> (<code>str</code>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
Activation function to use when generating the timestep embeddings.`,name:"timestep_activation_fn"},{anchor:"diffusers.CogVideoXTransformer3DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use elementwise affine in normalization layers.`,name:"norm_elementwise_affine"},{anchor:"diffusers.CogVideoXTransformer3DModel.norm_eps",description:`<strong>norm_eps</strong> (<code>float</code>, defaults to <code>1e-5</code>) &#x2014;
The epsilon value to use in normalization layers.`,name:"norm_eps"},{anchor:"diffusers.CogVideoXTransformer3DModel.spatial_interpolation_scale",description:`<strong>spatial_interpolation_scale</strong> (<code>float</code>, defaults to <code>1.875</code>) &#x2014;
Scaling factor to apply in 3D positional embeddings across spatial dimensions.`,name:"spatial_interpolation_scale"},{anchor:"diffusers.CogVideoXTransformer3DModel.temporal_interpolation_scale",description:`<strong>temporal_interpolation_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
Scaling factor to apply in 3D positional embeddings across temporal dimensions.`,name:"temporal_interpolation_scale"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L160"}}),q=new ae({props:{name:"fuse_qkv_projections",anchor:"diffusers.CogVideoXTransformer3DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L335"}}),H=new ae({props:{name:"unfuse_qkv_projections",anchor:"diffusers.CogVideoXTransformer3DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L357"}}),k=new ge({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),L=new ae({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/main/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/main/src/diffusers/models/modeling_outputs.py#L21"}}),Z=new Ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogvideox_transformer3d.md"}}),{c(){b=i("meta"),G=n(),W=i("p"),A=n(),c(M.$$.fragment),N=n(),c(y.$$.fragment),Q=n(),C=i("p"),C.innerHTML=he,K=n(),D=i("p"),D.textContent=be,Y=n(),c(V.$$.fragment),F=n(),c(w.$$.fragment),B=n(),l=i("div"),c(X.$$.fragment),ie=n(),E=i("p"),E.innerHTML=Te,de=n(),m=i("div"),c(q.$$.fragment),le=n(),z=i("p"),z.textContent=ve,me=n(),j=i("blockquote"),j.innerHTML=xe,fe=n(),f=i("div"),c(H.$$.fragment),ce=n(),O=i("p"),O.textContent=$e,pe=n(),U=i("blockquote"),U.innerHTML=Me,ee=n(),c(k.$$.fragment),te=n(),T=i("div"),c(L.$$.fragment),ue=n(),I=i("p"),I.innerHTML=ye,oe=n(),c(Z.$$.fragment),ne=n(),S=i("p"),this.h()},l(e){const t=qe("svelte-u9bgzb",document.head);b=d(t,"META",{name:!0,content:!0}),t.forEach(o),G=s(e),W=d(e,"P",{}),R(W).forEach(o),A=s(e),p(M.$$.fragment,e),N=s(e),p(y.$$.fragment,e),Q=s(e),C=d(e,"P",{"data-svelte-h":!0}),x(C)!=="svelte-2g99jo"&&(C.innerHTML=he),K=s(e),D=d(e,"P",{"data-svelte-h":!0}),x(D)!=="svelte-1vuni30"&&(D.textContent=be),Y=s(e),p(V.$$.fragment,e),F=s(e),p(w.$$.fragment,e),B=s(e),l=d(e,"DIV",{class:!0});var v=R(l);p(X.$$.fragment,v),ie=s(v),E=d(v,"P",{"data-svelte-h":!0}),x(E)!=="svelte-98fbmm"&&(E.innerHTML=Te),de=s(v),m=d(v,"DIV",{class:!0});var J=R(m);p(q.$$.fragment,J),le=s(J),z=d(J,"P",{"data-svelte-h":!0}),x(z)!=="svelte-1254b9i"&&(z.textContent=ve),me=s(J),j=d(J,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(j)!=="svelte-6y4o4y"&&(j.innerHTML=xe),J.forEach(o),fe=s(v),f=d(v,"DIV",{class:!0});var P=R(f);p(H.$$.fragment,P),ce=s(P),O=d(P,"P",{"data-svelte-h":!0}),x(O)!=="svelte-1vhtc74"&&(O.textContent=$e),pe=s(P),U=d(P,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(U)!=="svelte-6y4o4y"&&(U.innerHTML=Me),P.forEach(o),v.forEach(o),ee=s(e),p(k.$$.fragment,e),te=s(e),T=d(e,"DIV",{class:!0});var re=R(T);p(L.$$.fragment,re),ue=s(re),I=d(re,"P",{"data-svelte-h":!0}),x(I)!=="svelte-1x8c0js"&&(I.innerHTML=ye),re.forEach(o),oe=s(e),p(Z.$$.fragment,e),ne=s(e),S=d(e,"P",{}),R(S).forEach(o),this.h()},h(){$(b,"name","hf:doc:metadata"),$(b,"content",Le),$(j,"class","warning"),$(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(U,"class","warning"),$(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(T,"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){a(document.head,b),r(e,G,t),r(e,W,t),r(e,A,t),u(M,e,t),r(e,N,t),u(y,e,t),r(e,Q,t),r(e,C,t),r(e,K,t),r(e,D,t),r(e,Y,t),u(V,e,t),r(e,F,t),u(w,e,t),r(e,B,t),r(e,l,t),u(X,l,null),a(l,ie),a(l,E),a(l,de),a(l,m),u(q,m,null),a(m,le),a(m,z),a(m,me),a(m,j),a(l,fe),a(l,f),u(H,f,null),a(f,ce),a(f,O),a(f,pe),a(f,U),r(e,ee,t),u(k,e,t),r(e,te,t),r(e,T,t),u(L,T,null),a(T,ue),a(T,I),r(e,oe,t),u(Z,e,t),r(e,ne,t),r(e,S,t),se=!0},p:De,i(e){se||(g(M.$$.fragment,e),g(y.$$.fragment,e),g(V.$$.fragment,e),g(w.$$.fragment,e),g(X.$$.fragment,e),g(q.$$.fragment,e),g(H.$$.fragment,e),g(k.$$.fragment,e),g(L.$$.fragment,e),g(Z.$$.fragment,e),se=!0)},o(e){_(M.$$.fragment,e),_(y.$$.fragment,e),_(V.$$.fragment,e),_(w.$$.fragment,e),_(X.$$.fragment,e),_(q.$$.fragment,e),_(H.$$.fragment,e),_(k.$$.fragment,e),_(L.$$.fragment,e),_(Z.$$.fragment,e),se=!1},d(e){e&&(o(G),o(W),o(A),o(N),o(Q),o(C),o(K),o(D),o(Y),o(F),o(B),o(l),o(ee),o(te),o(T),o(oe),o(ne),o(S)),o(b),h(M,e),h(y,e),h(V,e),h(w,e),h(X),h(q),h(H),h(k,e),h(L),h(Z,e)}}}const Le='{"title":"CogVideoXTransformer3DModel","local":"cogvideoxtransformer3dmodel","sections":[{"title":"CogVideoXTransformer3DModel","local":"diffusers.CogVideoXTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function Ze(_e){return Ve(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends we{constructor(b){super(),Xe(this,b,Ze,ke,Ce,{})}}export{Re as component};
