Files
avtc 01a324bb11 feature: Add DiT model support with toroidal attention, latent wrapping, and Raylight integration
Extends tiling beyond UNet (Conv2d) models to support DiT architectures
using toroidal attention patches and latent content wrapping for seamless
infinite tiling. Adds rectangular tiling mode, WanVAE 5D tensor handling,
and an AdvancedTilingRay node for distributed Raylight workers.
2026-04-23 17:03:45 +03:00

40 lines
1.1 KiB
Python

"""
Rectangular (toroidal) tiling implementation
Wraps coordinates modularly: right edge wraps to left, bottom wraps to top.
"""
from . import Settings
def rect_tiling(
x: int,
y: int,
original_size: tuple[int, int],
padded_size: tuple[int, int],
_settings: Settings,
) -> tuple[int, int]:
"""
Rectangular tiling: wraps coordinates modularly around the original area.
Positions inside original_size are identity. Positions in the padding area
wrap to the opposite side of the original content.
:param x: X coordinate in padded space
:param y: Y coordinate in padded space
:param original_size: (width, height) of original content
:param padded_size: (width, height) of padded tensor
:param _settings: Tiling settings (unused for rectangular)
:return: (new_x, new_y) source coordinates in padded space
"""
ow, oh = original_size
pw, ph = padded_size
pad_x = (pw - ow) // 2
pad_y = (ph - oh) // 2
rel_x = (x - pad_x) % ow
rel_y = (y - pad_y) % oh
return (rel_x + pad_x, rel_y + pad_y)