import{s as Ct,o as jt,n as It}from"../chunks/scheduler.8c3d61f6.js";import{S as Ut,i as Zt,g as i,s,r as f,A as Nt,h as d,f as o,c as a,j as M,u as m,x as v,k as I,y as r,a as n,v as c,d as u,t as g,w as h}from"../chunks/index.da70eac4.js";import{D as L}from"../chunks/Docstring.8332ccfe.js";import{C as Jt}from"../chunks/CodeBlock.a9c4becf.js";import{E as Mt}from"../chunks/ExampleCodeBlock.cacf0f06.js";import{H as C,E as Vt}from"../chunks/getInferenceSnippets.4986d68f.js";function Lt(re){let p,J="Example:",$,_,b;return _=new Jt({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29nVmlkZW9YVHJhbnNmb3JtZXIzRE1vZGVsJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBDb2dWaWRlb1hUcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQSUwQWFwcGx5X2xheWVyd2lzZV9jYXN0aW5nKCUwQSUyMCUyMCUyMCUyMHRyYW5zZm9ybWVyJTJDJTBBJTIwJTIwJTIwJTIwc3RvcmFnZV9kdHlwZSUzRHRvcmNoLmZsb2F0OF9lNG0zZm4lMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjBza2lwX21vZHVsZXNfcGF0dGVybiUzRCU1QiUyMnBhdGNoX2VtYmVkJTIyJTJDJTIwJTIybm9ybSUyMiUyQyUyMCUyMnByb2pfb3V0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwbm9uX2Jsb2NraW5nJTNEVHJ1ZSUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel

<span class="hljs-meta">&gt;&gt;&gt; </span>transformer = CogVideoXTransformer3DModel.from_pretrained(
<span class="hljs-meta">... </span>    model_id, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>apply_layerwise_casting(
<span class="hljs-meta">... </span>    transformer,
<span class="hljs-meta">... </span>    storage_dtype=torch.float8_e4m3fn,
<span class="hljs-meta">... </span>    compute_dtype=torch.bfloat16,
<span class="hljs-meta">... </span>    skip_modules_pattern=[<span class="hljs-string">&quot;patch_embed&quot;</span>, <span class="hljs-string">&quot;norm&quot;</span>, <span class="hljs-string">&quot;proj_out&quot;</span>],
<span class="hljs-meta">... </span>    non_blocking=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){p=i("p"),p.textContent=J,$=s(),f(_.$$.fragment)},l(l){p=d(l,"P",{"data-svelte-h":!0}),v(p)!=="svelte-11lpom8"&&(p.textContent=J),$=a(l),m(_.$$.fragment,l)},m(l,w){n(l,p,w),n(l,$,w),c(_,l,w),b=!0},p:It,i(l){b||(u(_.$$.fragment,l),b=!0)},o(l){g(_.$$.fragment,l),b=!1},d(l){l&&(o(p),o($)),h(_,l)}}}function Dt(re){let p,J="Example:",$,_,b;return _=new Jt({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZGVvWFRyYW5zZm9ybWVyM0RNb2RlbCUwQWZyb20lMjBkaWZmdXNlcnMuaG9va3MlMjBpbXBvcnQlMjBhcHBseV9ncm91cF9vZmZsb2FkaW5nJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBDb2dWaWRlb1hUcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlRIVURNJTJGQ29nVmlkZW9YLTViJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQSUwQWFwcGx5X2dyb3VwX29mZmxvYWRpbmcoJTBBJTIwJTIwJTIwJTIwdHJhbnNmb3JtZXIlMkMlMEElMjAlMjAlMjAlMjBvbmxvYWRfZGV2aWNlJTNEdG9yY2guZGV2aWNlKCUyMmN1ZGElMjIpJTJDJTBBJTIwJTIwJTIwJTIwb2ZmbG9hZF9kZXZpY2UlM0R0b3JjaC5kZXZpY2UoJTIyY3B1JTIyKSUyQyUwQSUyMCUyMCUyMCUyMG9mZmxvYWRfdHlwZSUzRCUyMmJsb2NrX2xldmVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2Jsb2Nrc19wZXJfZ3JvdXAlM0QyJTJDJTBBJTIwJTIwJTIwJTIwdXNlX3N0cmVhbSUzRFRydWUlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.hooks <span class="hljs-keyword">import</span> apply_group_offloading

<span class="hljs-meta">&gt;&gt;&gt; </span>transformer = CogVideoXTransformer3DModel.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;THUDM/CogVideoX-5b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>apply_group_offloading(
<span class="hljs-meta">... </span>    transformer,
<span class="hljs-meta">... </span>    onload_device=torch.device(<span class="hljs-string">&quot;cuda&quot;</span>),
<span class="hljs-meta">... </span>    offload_device=torch.device(<span class="hljs-string">&quot;cpu&quot;</span>),
<span class="hljs-meta">... </span>    offload_type=<span class="hljs-string">&quot;block_level&quot;</span>,
<span class="hljs-meta">... </span>    num_blocks_per_group=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    use_stream=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){p=i("p"),p.textContent=J,$=s(),f(_.$$.fragment)},l(l){p=d(l,"P",{"data-svelte-h":!0}),v(p)!=="svelte-11lpom8"&&(p.textContent=J),$=a(l),m(_.$$.fragment,l)},m(l,w){n(l,p,w),n(l,$,w),c(_,l,w),b=!0},p:It,i(l){b||(u(_.$$.fragment,l),b=!0)},o(l){g(_.$$.fragment,l),b=!1},d(l){l&&(o(p),o($)),h(_,l)}}}function Pt(re){let p,J,$,_,b,l,w,pt="Utility and helper functions for working with 🤗 Diffusers.",ke,E,xe,j,q,Se,ie,ft="Convert a numpy image or a batch of images to a PIL image.",Me,F,Ie,U,G,Ae,de,mt="Convert a torch image to a PIL image.",Je,R,Ce,Z,H,Qe,pe,ct="Loads <code>image</code> to a PIL Image.",je,W,Ue,z,X,Ze,S,Ne,k,A,Ye,fe,ut=`quality:
Video output quality. Default is 5. Uses variable bit rate. Highest quality is 10, lowest is 0. Set to None to
prevent variable bitrate flags to FFMPEG so you can manually specify them using output_params instead.
Specifying a fixed bitrate using <code>bitrate</code> disables this parameter.`,Oe,me,gt=`bitrate:
Set a constant bitrate for the video encoding. Default is None causing <code>quality</code> parameter to be used instead.
Better quality videos with smaller file sizes will result from using the <code>quality</code> variable bitrate parameter
rather than specifying a fixed bitrate with this parameter.`,Ke,ce,ht=`macro_block_size:
Size constraint for video. Width and height, must be divisible by this number. If not divisible by this number
imageio will tell ffmpeg to scale the image up to the next closest size divisible by this number. Most codecs
are compatible with a macroblock size of 16 (default), some can go smaller (4, 8). To disable this automatic
feature set it to None or 1, however be warned many players can’t decode videos that are odd in size and some
codecs will produce poor results or fail. See <a href="https://en.wikipedia.org/wiki/Macroblock" rel="nofollow">https://en.wikipedia.org/wiki/Macroblock</a>.`,Ve,Q,Le,N,Y,et,ue,_t="Prepares a single grid of images. Useful for visualization purposes.",De,O,Pe,V,K,tt,ge,yt=`A helper function to create random tensors on the desired <code>device</code> with the desired <code>dtype</code>. When
passing a list of generators, you can seed each batch size individually. If CPU generators are passed, the tensor
is always created on the CPU.`,Be,ee,Ee,x,te,ot,he,bt=`Applies layerwise casting to a given module. The module expected here is a Diffusers ModelMixin but it can be any
nn.Module using diffusers layers or pytorch primitives.`,st,D,qe,oe,Fe,y,se,at,_e,vt=`Applies group offloading to the internal layers of a torch.nn.Module. To understand what group offloading is, and
where it is beneficial, we need to first provide some context on how other supported offloading methods work.`,nt,ye,$t="Typically, offloading is done at two levels:",lt,be,wt=`<li>Module-level: In Diffusers, this can be enabled using the <code>ModelMixin::enable_model_cpu_offload()</code> method. It
works by offloading each component of a pipeline to the CPU for storage, and onloading to the accelerator device
when needed for computation. This method is more memory-efficient than keeping all components on the accelerator,
but the memory requirements are still quite high. For this method to work, one needs memory equivalent to size of
the model in runtime dtype + size of largest intermediate activation tensors to be able to complete the forward
pass.</li> <li>Leaf-level: In Diffusers, this can be enabled using the <code>ModelMixin::enable_sequential_cpu_offload()</code> method. It
works by offloading the lowest leaf-level parameters of the computation graph to the CPU for storage, and
onloading only the leafs to the accelerator device for computation. This uses the lowest amount of accelerator
memory, but can be slower due to the excessive number of device synchronizations.</li>`,rt,ve,Tt=`Group offloading is a middle ground between the two methods. It works by offloading groups of internal layers,
(either <code>torch.nn.ModuleList</code> or <code>torch.nn.Sequential</code>). This method uses lower memory than module-level
offloading. It is also faster than leaf-level/sequential offloading, as the number of device synchronizations is
reduced.`,it,$e,kt=`Another supported feature (for CUDA devices with support for asynchronous data transfer streams) is the ability to
overlap data transfer and computation to reduce the overall execution time compared to sequential offloading. This
is enabled using layer prefetching with streams, i.e., the layer that is to be executed next starts onloading to
the accelerator device while the current layer is being executed - this increases the memory requirements slightly.
Note that this implementation also supports leaf-level offloading but can be made much faster when using streams.`,dt,P,Ge,ae,Re,Te,He;return b=new C({props:{title:"Utilities",local:"utilities",headingTag:"h1"}}),E=new C({props:{title:"numpy_to_pil",local:"diffusers.utils.numpy_to_pil",headingTag:"h2"}}),q=new L({props:{name:"diffusers.utils.numpy_to_pil",anchor:"diffusers.utils.numpy_to_pil",parameters:[{name:"images",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L37"}}),F=new C({props:{title:"pt_to_pil",local:"diffusers.utils.pt_to_pil",headingTag:"h2"}}),G=new L({props:{name:"diffusers.utils.pt_to_pil",anchor:"diffusers.utils.pt_to_pil",parameters:[{name:"images",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L27"}}),R=new C({props:{title:"load_image",local:"diffusers.utils.load_image",headingTag:"h2"}}),H=new L({props:{name:"diffusers.utils.load_image",anchor:"diffusers.utils.load_image",parameters:[{name:"image",val:": typing.Union[str, PIL.Image.Image]"},{name:"convert_method",val:": typing.Optional[typing.Callable[[PIL.Image.Image], PIL.Image.Image]] = None"}],parametersDescription:[{anchor:"diffusers.utils.load_image.image",description:`<strong>image</strong> (<code>str</code> or <code>PIL.Image.Image</code>) &#x2014;
The image to convert to the PIL Image format.`,name:"image"},{anchor:"diffusers.utils.load_image.convert_method",description:`<strong>convert_method</strong> (Callable[[PIL.Image.Image], PIL.Image.Image], <em>optional</em>) &#x2014;
A conversion method to apply to the image after loading it. When set to <code>None</code> the image will be converted
&#x201C;RGB&#x201D;.`,name:"convert_method"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/loading_utils.py#L14",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A PIL Image.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>PIL.Image.Image</code></p>
`}}),W=new C({props:{title:"export_to_gif",local:"diffusers.utils.export_to_gif",headingTag:"h2"}}),X=new L({props:{name:"diffusers.utils.export_to_gif",anchor:"diffusers.utils.export_to_gif",parameters:[{name:"image",val:": typing.List[PIL.Image.Image]"},{name:"output_gif_path",val:": str = None"},{name:"fps",val:": int = 10"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/export_utils.py#L28"}}),S=new C({props:{title:"export_to_video",local:"diffusers.utils.export_to_video",headingTag:"h2"}}),A=new L({props:{name:"diffusers.utils.export_to_video",anchor:"diffusers.utils.export_to_video",parameters:[{name:"video_frames",val:": typing.Union[typing.List[numpy.ndarray], typing.List[PIL.Image.Image]]"},{name:"output_video_path",val:": str = None"},{name:"fps",val:": int = 10"},{name:"quality",val:": float = 5.0"},{name:"bitrate",val:": typing.Optional[int] = None"},{name:"macro_block_size",val:": typing.Optional[int] = 16"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/export_utils.py#L141"}}),Q=new C({props:{title:"make_image_grid",local:"diffusers.utils.make_image_grid",headingTag:"h2"}}),Y=new L({props:{name:"diffusers.utils.make_image_grid",anchor:"diffusers.utils.make_image_grid",parameters:[{name:"images",val:": typing.List[PIL.Image.Image]"},{name:"rows",val:": int"},{name:"cols",val:": int"},{name:"resize",val:": int = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L53"}}),O=new C({props:{title:"randn_tensor",local:"diffusers.utils.torch_utils.randn_tensor",headingTag:"h2"}}),K=new L({props:{name:"diffusers.utils.torch_utils.randn_tensor",anchor:"diffusers.utils.torch_utils.randn_tensor",parameters:[{name:"shape",val:": typing.Union[typing.Tuple, typing.List]"},{name:"generator",val:": typing.Union[typing.List[ForwardRef('torch.Generator')], ForwardRef('torch.Generator'), NoneType] = None"},{name:"device",val:": typing.Union[str, ForwardRef('torch.device'), NoneType] = None"},{name:"dtype",val:": typing.Optional[ForwardRef('torch.dtype')] = None"},{name:"layout",val:": typing.Optional[ForwardRef('torch.layout')] = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/torch_utils.py#L38"}}),ee=new C({props:{title:"apply_layerwise_casting",local:"diffusers.hooks.apply_layerwise_casting",headingTag:"h2"}}),te=new L({props:{name:"diffusers.hooks.apply_layerwise_casting",anchor:"diffusers.hooks.apply_layerwise_casting",parameters:[{name:"module",val:": Module"},{name:"storage_dtype",val:": dtype"},{name:"compute_dtype",val:": dtype"},{name:"skip_modules_pattern",val:": typing.Union[str, typing.Tuple[str, ...]] = 'auto'"},{name:"skip_modules_classes",val:": typing.Optional[typing.Tuple[typing.Type[torch.nn.modules.module.Module], ...]] = None"},{name:"non_blocking",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.hooks.apply_layerwise_casting.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) &#x2014;
The module whose leaf modules will be cast to a high precision dtype for computation, and to a low
precision dtype for storage.`,name:"module"},{anchor:"diffusers.hooks.apply_layerwise_casting.storage_dtype",description:`<strong>storage_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The dtype to cast the module to before/after the forward pass for storage.`,name:"storage_dtype"},{anchor:"diffusers.hooks.apply_layerwise_casting.compute_dtype",description:`<strong>compute_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The dtype to cast the module to during the forward pass for computation.`,name:"compute_dtype"},{anchor:"diffusers.hooks.apply_layerwise_casting.skip_modules_pattern",description:`<strong>skip_modules_pattern</strong> (<code>Tuple[str, ...]</code>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
A list of patterns to match the names of the modules to skip during the layerwise casting process. If set
to <code>&quot;auto&quot;</code>, the default patterns are used. If set to <code>None</code>, no modules are skipped. If set to <code>None</code>
alongside <code>skip_modules_classes</code> being <code>None</code>, the layerwise casting is applied directly to the module
instead of its internal submodules.`,name:"skip_modules_pattern"},{anchor:"diffusers.hooks.apply_layerwise_casting.skip_modules_classes",description:`<strong>skip_modules_classes</strong> (<code>Tuple[Type[torch.nn.Module], ...]</code>, defaults to <code>None</code>) &#x2014;
A list of module classes to skip during the layerwise casting process.`,name:"skip_modules_classes"},{anchor:"diffusers.hooks.apply_layerwise_casting.non_blocking",description:`<strong>non_blocking</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, the weight casting operations are non-blocking.`,name:"non_blocking"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/hooks/layerwise_casting.py#L106"}}),D=new Mt({props:{anchor:"diffusers.hooks.apply_layerwise_casting.example",$$slots:{default:[Lt]},$$scope:{ctx:re}}}),oe=new C({props:{title:"apply_group_offloading",local:"diffusers.hooks.apply_group_offloading",headingTag:"h2"}}),se=new L({props:{name:"diffusers.hooks.apply_group_offloading",anchor:"diffusers.hooks.apply_group_offloading",parameters:[{name:"module",val:": Module"},{name:"onload_device",val:": device"},{name:"offload_device",val:": device = device(type='cpu')"},{name:"offload_type",val:": typing.Union[str, diffusers.hooks.group_offloading.GroupOffloadingType] = 'block_level'"},{name:"num_blocks_per_group",val:": typing.Optional[int] = None"},{name:"non_blocking",val:": bool = False"},{name:"use_stream",val:": bool = False"},{name:"record_stream",val:": bool = False"},{name:"low_cpu_mem_usage",val:": bool = False"},{name:"offload_to_disk_path",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"diffusers.hooks.apply_group_offloading.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) &#x2014;
The module to which group offloading is applied.`,name:"module"},{anchor:"diffusers.hooks.apply_group_offloading.onload_device",description:`<strong>onload_device</strong> (<code>torch.device</code>) &#x2014;
The device to which the group of modules are onloaded.`,name:"onload_device"},{anchor:"diffusers.hooks.apply_group_offloading.offload_device",description:`<strong>offload_device</strong> (<code>torch.device</code>, defaults to <code>torch.device(&quot;cpu&quot;)</code>) &#x2014;
The device to which the group of modules are offloaded. This should typically be the CPU. Default is CPU.`,name:"offload_device"},{anchor:"diffusers.hooks.apply_group_offloading.offload_type",description:`<strong>offload_type</strong> (<code>str</code> or <code>GroupOffloadingType</code>, defaults to &#x201C;block_level&#x201D;) &#x2014;
The type of offloading to be applied. Can be one of &#x201C;block_level&#x201D; or &#x201C;leaf_level&#x201D;. Default is
&#x201C;block_level&#x201D;.`,name:"offload_type"},{anchor:"diffusers.hooks.apply_group_offloading.offload_to_disk_path",description:`<strong>offload_to_disk_path</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The path to the directory where parameters will be offloaded. Setting this option can be useful in limited
RAM environment settings where a reasonable speed-memory trade-off is desired.`,name:"offload_to_disk_path"},{anchor:"diffusers.hooks.apply_group_offloading.num_blocks_per_group",description:`<strong>num_blocks_per_group</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of blocks per group when using offload_type=&#x201C;block_level&#x201D;. This is required when using
offload_type=&#x201C;block_level&#x201D;.`,name:"num_blocks_per_group"},{anchor:"diffusers.hooks.apply_group_offloading.non_blocking",description:`<strong>non_blocking</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, offloading and onloading is done with non-blocking data transfer.`,name:"non_blocking"},{anchor:"diffusers.hooks.apply_group_offloading.use_stream",description:`<strong>use_stream</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, offloading and onloading is done asynchronously using a CUDA stream. This can be useful for
overlapping computation and data transfer.`,name:"use_stream"},{anchor:"diffusers.hooks.apply_group_offloading.record_stream",description:`<strong>record_stream</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014; When enabled with <code>use_stream</code>, it marks the current tensor
as having been used by this stream. It is faster at the expense of slightly more memory usage. Refer to the
<a href="https://pytorch.org/docs/stable/generated/torch.Tensor.record_stream.html" rel="nofollow">PyTorch official docs</a> more
details.`,name:"record_stream"},{anchor:"diffusers.hooks.apply_group_offloading.low_cpu_mem_usage",description:`<strong>low_cpu_mem_usage</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, the CPU memory usage is minimized by pinning tensors on-the-fly instead of pre-pinning them. This
option only matters when using streamed CPU offloading (i.e. <code>use_stream=True</code>). This can be useful when
the CPU memory is a bottleneck but may counteract the benefits of using streams.`,name:"low_cpu_mem_usage"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/hooks/group_offloading.py#L458"}}),P=new Mt({props:{anchor:"diffusers.hooks.apply_group_offloading.example",$$slots:{default:[Dt]},$$scope:{ctx:re}}}),ae=new Vt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/utilities.md"}}),{c(){p=i("meta"),J=s(),$=i("p"),_=s(),f(b.$$.fragment),l=s(),w=i("p"),w.textContent=pt,ke=s(),f(E.$$.fragment),xe=s(),j=i("div"),f(q.$$.fragment),Se=s(),ie=i("p"),ie.textContent=ft,Me=s(),f(F.$$.fragment),Ie=s(),U=i("div"),f(G.$$.fragment),Ae=s(),de=i("p"),de.textContent=mt,Je=s(),f(R.$$.fragment),Ce=s(),Z=i("div"),f(H.$$.fragment),Qe=s(),pe=i("p"),pe.innerHTML=ct,je=s(),f(W.$$.fragment),Ue=s(),z=i("div"),f(X.$$.fragment),Ze=s(),f(S.$$.fragment),Ne=s(),k=i("div"),f(A.$$.fragment),Ye=s(),fe=i("p"),fe.innerHTML=ut,Oe=s(),me=i("p"),me.innerHTML=gt,Ke=s(),ce=i("p"),ce.innerHTML=ht,Ve=s(),f(Q.$$.fragment),Le=s(),N=i("div"),f(Y.$$.fragment),et=s(),ue=i("p"),ue.textContent=_t,De=s(),f(O.$$.fragment),Pe=s(),V=i("div"),f(K.$$.fragment),tt=s(),ge=i("p"),ge.innerHTML=yt,Be=s(),f(ee.$$.fragment),Ee=s(),x=i("div"),f(te.$$.fragment),ot=s(),he=i("p"),he.textContent=bt,st=s(),f(D.$$.fragment),qe=s(),f(oe.$$.fragment),Fe=s(),y=i("div"),f(se.$$.fragment),at=s(),_e=i("p"),_e.textContent=vt,nt=s(),ye=i("p"),ye.textContent=$t,lt=s(),be=i("ul"),be.innerHTML=wt,rt=s(),ve=i("p"),ve.innerHTML=Tt,it=s(),$e=i("p"),$e.textContent=kt,dt=s(),f(P.$$.fragment),Ge=s(),f(ae.$$.fragment),Re=s(),Te=i("p"),this.h()},l(e){const t=Nt("svelte-u9bgzb",document.head);p=d(t,"META",{name:!0,content:!0}),t.forEach(o),J=a(e),$=d(e,"P",{}),M($).forEach(o),_=a(e),m(b.$$.fragment,e),l=a(e),w=d(e,"P",{"data-svelte-h":!0}),v(w)!=="svelte-sj662i"&&(w.textContent=pt),ke=a(e),m(E.$$.fragment,e),xe=a(e),j=d(e,"DIV",{class:!0});var ne=M(j);m(q.$$.fragment,ne),Se=a(ne),ie=d(ne,"P",{"data-svelte-h":!0}),v(ie)!=="svelte-49eriv"&&(ie.textContent=ft),ne.forEach(o),Me=a(e),m(F.$$.fragment,e),Ie=a(e),U=d(e,"DIV",{class:!0});var le=M(U);m(G.$$.fragment,le),Ae=a(le),de=d(le,"P",{"data-svelte-h":!0}),v(de)!=="svelte-haxfgr"&&(de.textContent=mt),le.forEach(o),Je=a(e),m(R.$$.fragment,e),Ce=a(e),Z=d(e,"DIV",{class:!0});var We=M(Z);m(H.$$.fragment,We),Qe=a(We),pe=d(We,"P",{"data-svelte-h":!0}),v(pe)!=="svelte-suegrh"&&(pe.innerHTML=ct),We.forEach(o),je=a(e),m(W.$$.fragment,e),Ue=a(e),z=d(e,"DIV",{class:!0});var xt=M(z);m(X.$$.fragment,xt),xt.forEach(o),Ze=a(e),m(S.$$.fragment,e),Ne=a(e),k=d(e,"DIV",{class:!0});var B=M(k);m(A.$$.fragment,B),Ye=a(B),fe=d(B,"P",{"data-svelte-h":!0}),v(fe)!=="svelte-1gg2c2d"&&(fe.innerHTML=ut),Oe=a(B),me=d(B,"P",{"data-svelte-h":!0}),v(me)!=="svelte-fx26ue"&&(me.innerHTML=gt),Ke=a(B),ce=d(B,"P",{"data-svelte-h":!0}),v(ce)!=="svelte-15zmktc"&&(ce.innerHTML=ht),B.forEach(o),Ve=a(e),m(Q.$$.fragment,e),Le=a(e),N=d(e,"DIV",{class:!0});var ze=M(N);m(Y.$$.fragment,ze),et=a(ze),ue=d(ze,"P",{"data-svelte-h":!0}),v(ue)!=="svelte-rk2372"&&(ue.textContent=_t),ze.forEach(o),De=a(e),m(O.$$.fragment,e),Pe=a(e),V=d(e,"DIV",{class:!0});var Xe=M(V);m(K.$$.fragment,Xe),tt=a(Xe),ge=d(Xe,"P",{"data-svelte-h":!0}),v(ge)!=="svelte-11ct46x"&&(ge.innerHTML=yt),Xe.forEach(o),Be=a(e),m(ee.$$.fragment,e),Ee=a(e),x=d(e,"DIV",{class:!0});var we=M(x);m(te.$$.fragment,we),ot=a(we),he=d(we,"P",{"data-svelte-h":!0}),v(he)!=="svelte-owzrds"&&(he.textContent=bt),st=a(we),m(D.$$.fragment,we),we.forEach(o),qe=a(e),m(oe.$$.fragment,e),Fe=a(e),y=d(e,"DIV",{class:!0});var T=M(y);m(se.$$.fragment,T),at=a(T),_e=d(T,"P",{"data-svelte-h":!0}),v(_e)!=="svelte-7b2e3l"&&(_e.textContent=vt),nt=a(T),ye=d(T,"P",{"data-svelte-h":!0}),v(ye)!=="svelte-1b92jfk"&&(ye.textContent=$t),lt=a(T),be=d(T,"UL",{"data-svelte-h":!0}),v(be)!=="svelte-k3tp1z"&&(be.innerHTML=wt),rt=a(T),ve=d(T,"P",{"data-svelte-h":!0}),v(ve)!=="svelte-18cbdz5"&&(ve.innerHTML=Tt),it=a(T),$e=d(T,"P",{"data-svelte-h":!0}),v($e)!=="svelte-17duuep"&&($e.textContent=kt),dt=a(T),m(P.$$.fragment,T),T.forEach(o),Ge=a(e),m(ae.$$.fragment,e),Re=a(e),Te=d(e,"P",{}),M(Te).forEach(o),this.h()},h(){I(p,"name","hf:doc:metadata"),I(p,"content",Bt),I(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(y,"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){r(document.head,p),n(e,J,t),n(e,$,t),n(e,_,t),c(b,e,t),n(e,l,t),n(e,w,t),n(e,ke,t),c(E,e,t),n(e,xe,t),n(e,j,t),c(q,j,null),r(j,Se),r(j,ie),n(e,Me,t),c(F,e,t),n(e,Ie,t),n(e,U,t),c(G,U,null),r(U,Ae),r(U,de),n(e,Je,t),c(R,e,t),n(e,Ce,t),n(e,Z,t),c(H,Z,null),r(Z,Qe),r(Z,pe),n(e,je,t),c(W,e,t),n(e,Ue,t),n(e,z,t),c(X,z,null),n(e,Ze,t),c(S,e,t),n(e,Ne,t),n(e,k,t),c(A,k,null),r(k,Ye),r(k,fe),r(k,Oe),r(k,me),r(k,Ke),r(k,ce),n(e,Ve,t),c(Q,e,t),n(e,Le,t),n(e,N,t),c(Y,N,null),r(N,et),r(N,ue),n(e,De,t),c(O,e,t),n(e,Pe,t),n(e,V,t),c(K,V,null),r(V,tt),r(V,ge),n(e,Be,t),c(ee,e,t),n(e,Ee,t),n(e,x,t),c(te,x,null),r(x,ot),r(x,he),r(x,st),c(D,x,null),n(e,qe,t),c(oe,e,t),n(e,Fe,t),n(e,y,t),c(se,y,null),r(y,at),r(y,_e),r(y,nt),r(y,ye),r(y,lt),r(y,be),r(y,rt),r(y,ve),r(y,it),r(y,$e),r(y,dt),c(P,y,null),n(e,Ge,t),c(ae,e,t),n(e,Re,t),n(e,Te,t),He=!0},p(e,[t]){const ne={};t&2&&(ne.$$scope={dirty:t,ctx:e}),D.$set(ne);const le={};t&2&&(le.$$scope={dirty:t,ctx:e}),P.$set(le)},i(e){He||(u(b.$$.fragment,e),u(E.$$.fragment,e),u(q.$$.fragment,e),u(F.$$.fragment,e),u(G.$$.fragment,e),u(R.$$.fragment,e),u(H.$$.fragment,e),u(W.$$.fragment,e),u(X.$$.fragment,e),u(S.$$.fragment,e),u(A.$$.fragment,e),u(Q.$$.fragment,e),u(Y.$$.fragment,e),u(O.$$.fragment,e),u(K.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(D.$$.fragment,e),u(oe.$$.fragment,e),u(se.$$.fragment,e),u(P.$$.fragment,e),u(ae.$$.fragment,e),He=!0)},o(e){g(b.$$.fragment,e),g(E.$$.fragment,e),g(q.$$.fragment,e),g(F.$$.fragment,e),g(G.$$.fragment,e),g(R.$$.fragment,e),g(H.$$.fragment,e),g(W.$$.fragment,e),g(X.$$.fragment,e),g(S.$$.fragment,e),g(A.$$.fragment,e),g(Q.$$.fragment,e),g(Y.$$.fragment,e),g(O.$$.fragment,e),g(K.$$.fragment,e),g(ee.$$.fragment,e),g(te.$$.fragment,e),g(D.$$.fragment,e),g(oe.$$.fragment,e),g(se.$$.fragment,e),g(P.$$.fragment,e),g(ae.$$.fragment,e),He=!1},d(e){e&&(o(J),o($),o(_),o(l),o(w),o(ke),o(xe),o(j),o(Me),o(Ie),o(U),o(Je),o(Ce),o(Z),o(je),o(Ue),o(z),o(Ze),o(Ne),o(k),o(Ve),o(Le),o(N),o(De),o(Pe),o(V),o(Be),o(Ee),o(x),o(qe),o(Fe),o(y),o(Ge),o(Re),o(Te)),o(p),h(b,e),h(E,e),h(q),h(F,e),h(G),h(R,e),h(H),h(W,e),h(X),h(S,e),h(A),h(Q,e),h(Y),h(O,e),h(K),h(ee,e),h(te),h(D),h(oe,e),h(se),h(P),h(ae,e)}}}const Bt='{"title":"Utilities","local":"utilities","sections":[{"title":"numpy_to_pil","local":"diffusers.utils.numpy_to_pil","sections":[],"depth":2},{"title":"pt_to_pil","local":"diffusers.utils.pt_to_pil","sections":[],"depth":2},{"title":"load_image","local":"diffusers.utils.load_image","sections":[],"depth":2},{"title":"export_to_gif","local":"diffusers.utils.export_to_gif","sections":[],"depth":2},{"title":"export_to_video","local":"diffusers.utils.export_to_video","sections":[],"depth":2},{"title":"make_image_grid","local":"diffusers.utils.make_image_grid","sections":[],"depth":2},{"title":"randn_tensor","local":"diffusers.utils.torch_utils.randn_tensor","sections":[],"depth":2},{"title":"apply_layerwise_casting","local":"diffusers.hooks.apply_layerwise_casting","sections":[],"depth":2},{"title":"apply_group_offloading","local":"diffusers.hooks.apply_group_offloading","sections":[],"depth":2}],"depth":1}';function Et(re){return jt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zt extends Ut{constructor(p){super(),Zt(this,p,Et,Pt,Ct,{})}}export{zt as component};
