shifted window
**Shifted Window** is the **core mechanism of the Swin Transformer that enables cross-window communication** — by shifting the window partition by half the window size between consecutive layers, tokens in one window can interact with tokens from adjacent windows through the shifted configuration.
**How Does Shifted Window Work?**
- **Layer $l$**: Partition image into non-overlapping $M imes M$ windows. Self-attention within each window.
- **Layer $l+1$**: Shift the partition by $(M/2, M/2)$ pixels. Now windows straddle the old boundaries.
- **Effect**: Tokens that were in separate windows at layer $l$ share a window at layer $l+1$.
- **Efficient Masking**: Cyclic shift + masked attention avoids padding overhead.
- **Paper**: Liu et al. (2021, Swin Transformer).
**Why It Matters**
- **Cross-Window**: Solves the communication problem of window-based attention without global tokens.
- **Efficiency**: $O(M^2 cdot N)$ vs. $O(N^2)$ for global attention. Linear in image size.
- **SOTA**: Swin Transformer became the dominant vision backbone (2021-2023) for classification, detection, segmentation.
**Shifted Window** is **the sliding connection for windowed attention** — a simple shift that enables information flow across window boundaries.