S2AFormer: Strip Self-Attention for Efficient Vision Transformer

Guoan Xu, Wenfeng Huang, Wenjing Jia, Jiamao Li, Guangwei Gao, Guo-Jun Qi · DOI

Introduction

Vision Transformers (ViTs) have revolutionized computer vision by enabling models to capture long-range dependencies through global self-attention. However, the standard self-attention mechanism suffers from quadratic computational complexity relative to the number of input tokens. This scaling issue presents a significant barrier for high-resolution tasks like autonomous driving perception or deployment on resource-constrained edge devices. While previous research has explored local window attention or token pruning to mitigate these costs, these methods often sacrifice global context or remain optimized primarily for high-end GPUs.

S2AFormer introduces a novel architecture designed to bridge this gap. By implementing Strip Self-Attention (SSA), the model achieves a superior balance of accuracy and inference speed, outperforming established efficient models such as MobileViT and SwiftFormer across a variety of vision benchmarks.

Methodology

The core innovation of S2AFormer lies in its approach to reducing the redundancy inherent in standard attention mechanisms. The architecture is built around two primary components: the Strip Self-Attention (SSA) mechanism and the Hybrid Perception Block (HPB).

Strip Self-Attention (SSA)

Standard attention is computationally expensive because it compares every token to every other token across all feature channels. SSA reduces this overhead through two concurrent compression strategies:

  1. Spatial Compression: The model utilizes depth-wise convolutions to downsample the "Key" and "Value" tensors. This reduces the total number of tokens the attention mechanism must process while preserving essential spatial information.
  2. Channel Squeeze: Unlike many efficient ViTs that focus solely on spatial dimensions, SSA identifies and exploits redundancy in the channel dimension. By squeezing the "Query" and "Key" tensors into a narrow "strip" (often a single channel), the model can compute a global attention map with significantly fewer operations.

Hybrid Perception Block (HPB)

Transformers typically lack the "inductive bias" found in Convolutional Neural Networks (CNNs), which naturally understand that neighboring pixels are related. To address this, S2AFormer employs the HPB, which combines SSA with a Local Interaction Module (LIM). The LIM uses lightweight depth-wise convolutions to capture fine-grained local details, while the SSA handles broad, global relationships. This dual-path approach ensures the model maintains a comprehensive understanding of the scene.

Hierarchical Architecture

S2AFormer follows a hierarchical four-stage design, similar to classic architectures like ResNet. This structure allows the model to generate multi-scale feature maps, which are critical for downstream tasks such as object detection and semantic segmentation.

Experimental Results

The model was evaluated on ImageNet-1K for classification, ADE20K for semantic segmentation, and COCO for object detection.

Image Classification Performance

On the ImageNet-1K benchmark, S2AFormer-mini achieved a 75.1% Top-1 accuracy with only 5 million parameters. In terms of raw throughput, it demonstrated exceptional efficiency; on an NVIDIA H100 GPU, S2AFormer-mini processed 6,330 images per second, nearly doubling the speed of EMO-2M (3,359 images/s). Furthermore, S2AFormer-T outperformed SHViT-S3 while utilizing less than half the parameters (5.8M vs 14.2M).

Downstream Tasks

S2AFormer's efficiency extends to complex spatial tasks:

  • Semantic Segmentation: On ADE20K, S2AFormer-mini reached 36.7% mIoU, surpassing ResNet-18 by 3.8% while maintaining a lower computational footprint.
  • Object Detection: In COCO benchmarks, the model exceeded the performance of established efficient models like EfficientViT-M4 in both accuracy and inference speed.

Discussion and Key Insights

Analysis of the S2AFormer architecture reveals several critical insights into efficient model design:

  • Channel Redundancy: The success of the "Channel Squeeze" in SSA suggests that the channel dimension in attention heads is highly redundant. Compressing this dimension allows for massive speedups without a proportional loss in representational power.
  • Effective Receptive Field: Visualizations show that S2AFormer’s attention expands in a strip-like pattern from a central point. This allows the model to cover the entire image more efficiently than purely local CNNs.
  • Hardware Versatility: S2AFormer is designed for broad compatibility, maintaining high performance across GPUs, CPUs, and specialized deployment formats like ONNX, making it a viable candidate for diverse real-world applications.

Conclusion and Future Work

S2AFormer demonstrates that efficient Vision Transformers can maintain global context without the prohibitive costs of standard self-attention. While the current model uses static spatial and channel reduction ratios, future iterations may incorporate dynamic compression, allowing the model to adaptively allocate computational resources based on image content. Additionally, the authors plan to explore the integration of S2AFormer with self-supervised learning frameworks like Masked Autoencoders (MAE) to further enhance its feature representation capabilities.

Summary updated

BibTeX
@article{xu2025s,
  author = {Guoan Xu and Wenfeng Huang and Wenjing Jia and Jiamao Li and Guangwei Gao and Guo-Jun Qi},
  title = {{S2AFormer: Strip Self-Attention for Efficient Vision Transformer}},
  journal = {IEEE Trans. Image Process.},
  year = {2025},
  doi = {10.1109/tip.2025.3639919},
}
Figure