Interlaced Sparse Self-Attention for Semantic Segmentation

Lang Huang, Yuhui Yuan, Jianyuan Guo, Chao Zhang, Xilin Chen, Jingdong WangarXiv 2019

Abstract

Semantic segmentation requires capturing long-range dependencies across an image, a task traditionally handled by stacking convolutional layers or employing self-attention mechanisms. However, standard self-attention suffers from quadratic computational complexity $O(N^2)$, making it prohibitive for high-resolution data. This paper introduces Interlaced Sparse Self-Attention (ISSA), which factorizes the dense affinity matrix into two successive sparse matrices. This approach captures both long-range and short-range dependencies with significantly reduced memory and compute requirements, achieving state-of-the-art results on benchmarks like LIP and Cityscapes.

Introduction

The core challenge in semantic segmentation is the effective modeling of global context. While the self-attention (or non-local) mechanism provides a robust solution by allowing every pixel to attend to every other pixel, its $O(N^2)$ scaling with respect to the number of pixels $N$ limits its practical application. For high-resolution images common in datasets like Cityscapes, the memory footprint and FLOPs required for a single self-attention layer can exceed the capacity of modern GPUs.

Interlaced Sparse Self-Attention (ISSA)

To address these efficiency bottlenecks, the authors propose factorizing the dense self-attention operation. ISSA decomposes the global attention into two distinct, sparse stages:

  1. Long-range Attention: The input feature map is partitioned into subsets containing pixels that are spatially distant. Self-attention is performed within these subsets to capture global, coarse-grained context.
  2. Short-range Attention: The feature map is re-partitioned into subsets of neighboring pixels. Self-attention here captures local, fine-grained details.
Conceptual comparison between standard Self-Attention and the proposed Interlaced Sparse Self-Attention.

By "interlacing" these two steps through permutation and reshaping, the model ensures that information can propagate between any two pixels in the image. Mathematically, this approximates the full $N \times N$ affinity matrix as the product of two sparse matrices, reducing complexity to approximately $O(N\sqrt{N})$. This implementation relies on simple permute and reshape operations, making it highly portable across deep learning frameworks without requiring custom CUDA kernels.

Experimental Results

The effectiveness of ISSA was validated across several major semantic segmentation benchmarks, including Cityscapes, ADE20K, and LIP.

Performance and Efficiency

ISSA demonstrates a remarkable balance between accuracy and efficiency. On the LIP dataset, it achieved a state-of-the-art mIoU of 55.07%. Crucially, these gains come at a fraction of the cost of standard self-attention.

As shown in the comparison, ISSA reduces GPU memory consumption by nearly 90% (from 2122 MB to 217 MB for a $128 \times 128$ map) and cuts FLOPs by approximately 75%. Furthermore, the inference time is nearly halved, dropping from 53ms to 29ms.

Generalization

Beyond segmentation, ISSA was integrated into the Mask R-CNN framework for object detection and instance segmentation on the COCO dataset. It consistently improved Box and Mask AP by approximately 1% across different training schedules, suggesting that the interlaced sparse attention mechanism is a versatile component for various vision tasks.

Conclusion

Interlaced Sparse Self-Attention provides a scalable and efficient alternative to dense self-attention. By factorizing global dependencies into interlaced sparse operations, ISSA enables the use of powerful attention mechanisms on high-resolution images without the prohibitive computational costs. Future research may explore adaptive partitioning strategies or the application of this technique to 3D video data, where the $O(N^2)$ bottleneck is even more severe.

Summary updated

BibTeX
@misc{huang2019interlaced,
  author = {Lang Huang and Yuhui Yuan and Jianyuan Guo and Chao Zhang and Xilin Chen and Jingdong Wang},
  title = {{Interlaced Sparse Self-Attention for Semantic Segmentation}},
  year = {2019},
  eprint = {1907.12273},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1907.12273},
}
Figure