import{s as jt,o as Zt,n as Ct}from"../chunks/scheduler.53228c21.js";import{S as Nt,i as Lt,e as i,s,c as f,h as Vt,a as d,d as o,b as a,f as M,g as m,j as v,k as I,l as r,m as n,n as c,t as u,o as g,p as h}from"../chunks/index.100fac89.js";import{C as Dt}from"../chunks/CopyLLMTxtMenu.4f0519ef.js";import{D as V}from"../chunks/Docstring.d02a9fa5.js";import{C as Ut}from"../chunks/CodeBlock.d30a6509.js";import{E as Jt}from"../chunks/ExampleCodeBlock.38517eb4.js";import{H as C,E as Pt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.62dbb7c4.js";function Bt(ie){let p,J="Example:",$,_,b;return _=new Ut({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:Ct,i(l){b||(u(_.$$.fragment,l),b=!0)},o(l){g(_.$$.fragment,l),b=!1},d(l){l&&(o(p),o($)),h(_,l)}}}function Et(ie){let p,J="Example:",$,_,b;return _=new Ut({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:Ct,i(l){b||(u(_.$$.fragment,l),b=!0)},o(l){g(_.$$.fragment,l),b=!1},d(l){l&&(o(p),o($)),h(_,l)}}}function qt(ie){let p,J,$,_,b,l,w,xe,E,mt="Utility and helper functions for working with 🤗 Diffusers.",Me,q,Ie,U,F,Qe,de,ct="Convert a numpy image or a batch of images to a PIL image.",Je,G,Ce,j,R,Ye,pe,ut="Convert a torch image to a PIL image.",Ue,z,je,Z,H,Oe,fe,gt="Loads <code>image</code> to a PIL Image.",Ze,W,Ne,X,S,Le,A,Ve,k,Q,Ke,me,ht=`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.`,et,ce,_t=`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.`,tt,ue,yt=`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>.`,De,Y,Pe,N,O,ot,ge,bt="Prepares a single grid of images. Useful for visualization purposes.",Be,K,Ee,L,ee,st,he,vt=`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.`,qe,te,Fe,x,oe,at,_e,$t=`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.`,nt,D,Ge,se,Re,y,ae,lt,ye,wt=`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.`,rt,be,Tt="Typically, offloading is done at two levels:",it,ve,kt=`<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>`,dt,$e,xt=`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.`,pt,we,Mt=`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.`,ft,P,ze,ne,He,ke,We;return b=new Dt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new C({props:{title:"Utilities",local:"utilities",headingTag:"h1"}}),q=new C({props:{title:"numpy_to_pil",local:"diffusers.utils.numpy_to_pil",headingTag:"h2"}}),F=new V({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"}}),G=new C({props:{title:"pt_to_pil",local:"diffusers.utils.pt_to_pil",headingTag:"h2"}}),R=new V({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"}}),z=new C({props:{title:"load_image",local:"diffusers.utils.load_image",headingTag:"h2"}}),H=new V({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"}}),S=new V({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"}}),A=new C({props:{title:"export_to_video",local:"diffusers.utils.export_to_video",headingTag:"h2"}}),Q=new V({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"}}),Y=new C({props:{title:"make_image_grid",local:"diffusers.utils.make_image_grid",headingTag:"h2"}}),O=new V({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"}}),K=new C({props:{title:"randn_tensor",local:"diffusers.utils.torch_utils.randn_tensor",headingTag:"h2"}}),ee=new V({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#L146"}}),te=new C({props:{title:"apply_layerwise_casting",local:"diffusers.hooks.apply_layerwise_casting",headingTag:"h2"}}),oe=new V({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#L101"}}),D=new Jt({props:{anchor:"diffusers.hooks.apply_layerwise_casting.example",$$slots:{default:[Bt]},$$scope:{ctx:ie}}}),se=new C({props:{title:"apply_group_offloading",local:"diffusers.hooks.apply_group_offloading",headingTag:"h2"}}),ae=new V({props:{name:"diffusers.hooks.apply_group_offloading",anchor:"diffusers.hooks.apply_group_offloading",parameters:[{name:"module",val:": Module"},{name:"onload_device",val:": typing.Union[str, torch.device]"},{name:"offload_device",val:": typing.Union[str, torch.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#L445"}}),P=new Jt({props:{anchor:"diffusers.hooks.apply_group_offloading.example",$$slots:{default:[Et]},$$scope:{ctx:ie}}}),ne=new Pt({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(),f(w.$$.fragment),xe=s(),E=i("p"),E.textContent=mt,Me=s(),f(q.$$.fragment),Ie=s(),U=i("div"),f(F.$$.fragment),Qe=s(),de=i("p"),de.textContent=ct,Je=s(),f(G.$$.fragment),Ce=s(),j=i("div"),f(R.$$.fragment),Ye=s(),pe=i("p"),pe.textContent=ut,Ue=s(),f(z.$$.fragment),je=s(),Z=i("div"),f(H.$$.fragment),Oe=s(),fe=i("p"),fe.innerHTML=gt,Ze=s(),f(W.$$.fragment),Ne=s(),X=i("div"),f(S.$$.fragment),Le=s(),f(A.$$.fragment),Ve=s(),k=i("div"),f(Q.$$.fragment),Ke=s(),me=i("p"),me.innerHTML=ht,et=s(),ce=i("p"),ce.innerHTML=_t,tt=s(),ue=i("p"),ue.innerHTML=yt,De=s(),f(Y.$$.fragment),Pe=s(),N=i("div"),f(O.$$.fragment),ot=s(),ge=i("p"),ge.textContent=bt,Be=s(),f(K.$$.fragment),Ee=s(),L=i("div"),f(ee.$$.fragment),st=s(),he=i("p"),he.innerHTML=vt,qe=s(),f(te.$$.fragment),Fe=s(),x=i("div"),f(oe.$$.fragment),at=s(),_e=i("p"),_e.textContent=$t,nt=s(),f(D.$$.fragment),Ge=s(),f(se.$$.fragment),Re=s(),y=i("div"),f(ae.$$.fragment),lt=s(),ye=i("p"),ye.textContent=wt,rt=s(),be=i("p"),be.textContent=Tt,it=s(),ve=i("ul"),ve.innerHTML=kt,dt=s(),$e=i("p"),$e.innerHTML=xt,pt=s(),we=i("p"),we.textContent=Mt,ft=s(),f(P.$$.fragment),ze=s(),f(ne.$$.fragment),He=s(),ke=i("p"),this.h()},l(e){const t=Vt("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),m(w.$$.fragment,e),xe=a(e),E=d(e,"P",{"data-svelte-h":!0}),v(E)!=="svelte-sj662i"&&(E.textContent=mt),Me=a(e),m(q.$$.fragment,e),Ie=a(e),U=d(e,"DIV",{class:!0});var le=M(U);m(F.$$.fragment,le),Qe=a(le),de=d(le,"P",{"data-svelte-h":!0}),v(de)!=="svelte-49eriv"&&(de.textContent=ct),le.forEach(o),Je=a(e),m(G.$$.fragment,e),Ce=a(e),j=d(e,"DIV",{class:!0});var re=M(j);m(R.$$.fragment,re),Ye=a(re),pe=d(re,"P",{"data-svelte-h":!0}),v(pe)!=="svelte-haxfgr"&&(pe.textContent=ut),re.forEach(o),Ue=a(e),m(z.$$.fragment,e),je=a(e),Z=d(e,"DIV",{class:!0});var Xe=M(Z);m(H.$$.fragment,Xe),Oe=a(Xe),fe=d(Xe,"P",{"data-svelte-h":!0}),v(fe)!=="svelte-suegrh"&&(fe.innerHTML=gt),Xe.forEach(o),Ze=a(e),m(W.$$.fragment,e),Ne=a(e),X=d(e,"DIV",{class:!0});var It=M(X);m(S.$$.fragment,It),It.forEach(o),Le=a(e),m(A.$$.fragment,e),Ve=a(e),k=d(e,"DIV",{class:!0});var B=M(k);m(Q.$$.fragment,B),Ke=a(B),me=d(B,"P",{"data-svelte-h":!0}),v(me)!=="svelte-1gg2c2d"&&(me.innerHTML=ht),et=a(B),ce=d(B,"P",{"data-svelte-h":!0}),v(ce)!=="svelte-fx26ue"&&(ce.innerHTML=_t),tt=a(B),ue=d(B,"P",{"data-svelte-h":!0}),v(ue)!=="svelte-15zmktc"&&(ue.innerHTML=yt),B.forEach(o),De=a(e),m(Y.$$.fragment,e),Pe=a(e),N=d(e,"DIV",{class:!0});var Se=M(N);m(O.$$.fragment,Se),ot=a(Se),ge=d(Se,"P",{"data-svelte-h":!0}),v(ge)!=="svelte-rk2372"&&(ge.textContent=bt),Se.forEach(o),Be=a(e),m(K.$$.fragment,e),Ee=a(e),L=d(e,"DIV",{class:!0});var Ae=M(L);m(ee.$$.fragment,Ae),st=a(Ae),he=d(Ae,"P",{"data-svelte-h":!0}),v(he)!=="svelte-11ct46x"&&(he.innerHTML=vt),Ae.forEach(o),qe=a(e),m(te.$$.fragment,e),Fe=a(e),x=d(e,"DIV",{class:!0});var Te=M(x);m(oe.$$.fragment,Te),at=a(Te),_e=d(Te,"P",{"data-svelte-h":!0}),v(_e)!=="svelte-owzrds"&&(_e.textContent=$t),nt=a(Te),m(D.$$.fragment,Te),Te.forEach(o),Ge=a(e),m(se.$$.fragment,e),Re=a(e),y=d(e,"DIV",{class:!0});var T=M(y);m(ae.$$.fragment,T),lt=a(T),ye=d(T,"P",{"data-svelte-h":!0}),v(ye)!=="svelte-7b2e3l"&&(ye.textContent=wt),rt=a(T),be=d(T,"P",{"data-svelte-h":!0}),v(be)!=="svelte-1b92jfk"&&(be.textContent=Tt),it=a(T),ve=d(T,"UL",{"data-svelte-h":!0}),v(ve)!=="svelte-k3tp1z"&&(ve.innerHTML=kt),dt=a(T),$e=d(T,"P",{"data-svelte-h":!0}),v($e)!=="svelte-18cbdz5"&&($e.innerHTML=xt),pt=a(T),we=d(T,"P",{"data-svelte-h":!0}),v(we)!=="svelte-17duuep"&&(we.textContent=Mt),ft=a(T),m(P.$$.fragment,T),T.forEach(o),ze=a(e),m(ne.$$.fragment,e),He=a(e),ke=d(e,"P",{}),M(ke).forEach(o),this.h()},h(){I(p,"name","hf:doc:metadata"),I(p,"content",Ft),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(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(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(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(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(L,"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),c(w,e,t),n(e,xe,t),n(e,E,t),n(e,Me,t),c(q,e,t),n(e,Ie,t),n(e,U,t),c(F,U,null),r(U,Qe),r(U,de),n(e,Je,t),c(G,e,t),n(e,Ce,t),n(e,j,t),c(R,j,null),r(j,Ye),r(j,pe),n(e,Ue,t),c(z,e,t),n(e,je,t),n(e,Z,t),c(H,Z,null),r(Z,Oe),r(Z,fe),n(e,Ze,t),c(W,e,t),n(e,Ne,t),n(e,X,t),c(S,X,null),n(e,Le,t),c(A,e,t),n(e,Ve,t),n(e,k,t),c(Q,k,null),r(k,Ke),r(k,me),r(k,et),r(k,ce),r(k,tt),r(k,ue),n(e,De,t),c(Y,e,t),n(e,Pe,t),n(e,N,t),c(O,N,null),r(N,ot),r(N,ge),n(e,Be,t),c(K,e,t),n(e,Ee,t),n(e,L,t),c(ee,L,null),r(L,st),r(L,he),n(e,qe,t),c(te,e,t),n(e,Fe,t),n(e,x,t),c(oe,x,null),r(x,at),r(x,_e),r(x,nt),c(D,x,null),n(e,Ge,t),c(se,e,t),n(e,Re,t),n(e,y,t),c(ae,y,null),r(y,lt),r(y,ye),r(y,rt),r(y,be),r(y,it),r(y,ve),r(y,dt),r(y,$e),r(y,pt),r(y,we),r(y,ft),c(P,y,null),n(e,ze,t),c(ne,e,t),n(e,He,t),n(e,ke,t),We=!0},p(e,[t]){const le={};t&2&&(le.$$scope={dirty:t,ctx:e}),D.$set(le);const re={};t&2&&(re.$$scope={dirty:t,ctx:e}),P.$set(re)},i(e){We||(u(b.$$.fragment,e),u(w.$$.fragment,e),u(q.$$.fragment,e),u(F.$$.fragment,e),u(G.$$.fragment,e),u(R.$$.fragment,e),u(z.$$.fragment,e),u(H.$$.fragment,e),u(W.$$.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(oe.$$.fragment,e),u(D.$$.fragment,e),u(se.$$.fragment,e),u(ae.$$.fragment,e),u(P.$$.fragment,e),u(ne.$$.fragment,e),We=!0)},o(e){g(b.$$.fragment,e),g(w.$$.fragment,e),g(q.$$.fragment,e),g(F.$$.fragment,e),g(G.$$.fragment,e),g(R.$$.fragment,e),g(z.$$.fragment,e),g(H.$$.fragment,e),g(W.$$.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(oe.$$.fragment,e),g(D.$$.fragment,e),g(se.$$.fragment,e),g(ae.$$.fragment,e),g(P.$$.fragment,e),g(ne.$$.fragment,e),We=!1},d(e){e&&(o(J),o($),o(_),o(l),o(xe),o(E),o(Me),o(Ie),o(U),o(Je),o(Ce),o(j),o(Ue),o(je),o(Z),o(Ze),o(Ne),o(X),o(Le),o(Ve),o(k),o(De),o(Pe),o(N),o(Be),o(Ee),o(L),o(qe),o(Fe),o(x),o(Ge),o(Re),o(y),o(ze),o(He),o(ke)),o(p),h(b,e),h(w,e),h(q,e),h(F),h(G,e),h(R),h(z,e),h(H),h(W,e),h(S),h(A,e),h(Q),h(Y,e),h(O),h(K,e),h(ee),h(te,e),h(oe),h(D),h(se,e),h(ae),h(P),h(ne,e)}}}const Ft='{"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 Gt(ie){return Zt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qt extends Nt{constructor(p){super(),Lt(this,p,Gt,qt,jt,{})}}export{Qt as component};
