Sparsifiner: Learning Sparse Instance-Dependent Attention for Efficient Vision Transformers

Cong Wei, Brendan Duke, Ruowei Jiang, Parham Aarabi, Graham W. Taylor +1 more
3/24/2023
cs.CVcs.AIcs.LG

No official code found. Best implementation: lim142857/Sparsifiner (15 stars, MIT, last commit 2023-07-04).

Abstract

Vision Transformers (ViT) have shown their competitive advantages performance-wise compared to convolutional neural networks (CNNs) though they often come with high computational costs. To this end, previous methods explore different attention patterns by limiting a fixed number of spatially nearby tokens to accelerate the ViT's multi-head self-attention (MHSA) operations. However, such structured attention patterns limit the token-to-token connections to their spatial relevance, which disregards learned semantic connections from a full attention mask. In this work, we propose a novel approach to learn instance-dependent attention patterns, by devising a lightweight connectivity predictor module to estimate the connectivity score of each pair of tokens. Intuitively, two tokens have high connectivity scores if the features are considered relevant either spatially or semantically. As each token only attends to a small number of other tokens, the binarized connectivity masks are often very sparse by nature and therefore provide the opportunity to accelerate the network via sparse computations. Equipped with the learned unstructured attention pattern, sparse attention ViT (Sparsifiner) produces a superior Pareto-optimal trade-off between FLOPs and top-1 accuracy on ImageNet compared to token sparsity. Our method reduces 48% to 69% FLOPs of MHSA while the accuracy drop is within 0.4%. We also show that combining attention and token sparsity reduces ViT FLOPs by over 60%.

View on arXivView PDF

Code Implementations(1)

MIT

Demo code for CVPR2023 paper "Sparsifiner: Learning Sparse Instance-Dependent Attention for Efficient Vision Transformers"

153Shell, PythonJul 4, 20233 years agoMIT
attention-mechanismefficient-transformersefficient-vision-transformersfast-inferencelow-rank+3 more

Similar Papers

Cite this paper

@article{wei2023sparsifiner,
  title  = {Sparsifiner: Learning Sparse Instance-Dependent Attention for Efficient Vision Transformers},
  author = {Cong Wei and Brendan Duke and Ruowei Jiang and Parham Aarabi and Graham W. Taylor and Florian Shkurti},
  year   = {2023},
  eprint = {2303.13755},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2303.13755v1},
  journal = {CVPR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2303.13755.svg)](https://codeofpaper.com/paper/2303.13755)

Discussion