Tiling¶
tiling
¶
tiled_process
¶
tiled_process(x: array, fn: Callable[[array], array], tile_size: int = 512, overlap: int = 64, spatial_dims: tuple = (1, 2)) -> array
Process a tensor in overlapping spatial tiles with linear blending.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Input tensor. Spatial dimensions specified by spatial_dims. |
required |
fn
|
Callable[[array], array]
|
Processing function applied to each tile. |
required |
tile_size
|
int
|
Size of each tile along spatial dimensions. |
512
|
overlap
|
int
|
Overlap between adjacent tiles for blending. |
64
|
spatial_dims
|
tuple
|
Which dimensions are spatial (default: H, W for BHWC). |
(1, 2)
|
Returns:
| Type | Description |
|---|---|
array
|
Processed tensor, same shape as fn(x) would produce if memory |
array
|
were unlimited. |
temporal_slice_process
¶
temporal_slice_process(x: array, fn: Callable[[array], array], window_size: int = 16, overlap: int = 4, temporal_dim: int = 1) -> array
Process a video tensor in overlapping temporal windows with linear blending.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Input tensor with a temporal dimension (e.g., (B, T, H, W, C)). |
required |
fn
|
Callable[[array], array]
|
Processing function applied to each temporal window. |
required |
window_size
|
int
|
Number of frames per window. |
16
|
overlap
|
int
|
Number of overlapping frames between windows. |
4
|
temporal_dim
|
int
|
Which dimension is temporal. |
1
|
Returns:
| Type | Description |
|---|---|
array
|
Processed tensor with the same temporal length as fn(x) would produce. |
spatial
¶
Tiled processing for large spatial tensors.
Splits tensors into overlapping tiles, processes each tile independently, and blends them back together. Useful for VAE encoding/decoding of high-resolution images/video that exceed memory limits.
tiled_process
¶
tiled_process(x: array, fn: Callable[[array], array], tile_size: int = 512, overlap: int = 64, spatial_dims: tuple = (1, 2)) -> array
Process a tensor in overlapping spatial tiles with linear blending.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Input tensor. Spatial dimensions specified by spatial_dims. |
required |
fn
|
Callable[[array], array]
|
Processing function applied to each tile. |
required |
tile_size
|
int
|
Size of each tile along spatial dimensions. |
512
|
overlap
|
int
|
Overlap between adjacent tiles for blending. |
64
|
spatial_dims
|
tuple
|
Which dimensions are spatial (default: H, W for BHWC). |
(1, 2)
|
Returns:
| Type | Description |
|---|---|
array
|
Processed tensor, same shape as fn(x) would produce if memory |
array
|
were unlimited. |
temporal
¶
Temporal slicing for processing long video sequences.
Processes video tensors in overlapping temporal windows, useful for VAE encoding/decoding of long videos that don't fit in memory at once.
temporal_slice_process
¶
temporal_slice_process(x: array, fn: Callable[[array], array], window_size: int = 16, overlap: int = 4, temporal_dim: int = 1) -> array
Process a video tensor in overlapping temporal windows with linear blending.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Input tensor with a temporal dimension (e.g., (B, T, H, W, C)). |
required |
fn
|
Callable[[array], array]
|
Processing function applied to each temporal window. |
required |
window_size
|
int
|
Number of frames per window. |
16
|
overlap
|
int
|
Number of overlapping frames between windows. |
4
|
temporal_dim
|
int
|
Which dimension is temporal. |
1
|
Returns:
| Type | Description |
|---|---|
array
|
Processed tensor with the same temporal length as fn(x) would produce. |