Linear Complexity Self-Attention With $3{\mathrm{rd}}$3 rd Order Polynomials

Francesca Babiloni, Ioannis Marras, Jiankang Deng, Filippos Kokkinos, Matteo Maggioni, Grigorios Chrysos, Philip H. S. Torr, Stefanos Zafeiriou

Abstract

Self-attention mechanisms and non-local blocks have become crucial building blocks for state-of-the-art neural architectures thanks to their unparalleled ability in capturing long-range dependencies in the input. However their cost is quadratic with the number of spatial positions hence making their use impractical in many real case applications. In this work, we analyze these methods through a polynomial lens, and we show that self-attention can be seen as a special case of a 3 rd order polynomial. Within this polynomial framework, we are able to design polynomial operators capable of accessing the same data pattern of non-local and self-attention blocks while reducing the complexity from quadratic to linear. As a result, we propose two modules (Poly-NL and Poly-SA) that can be used as ”drop-in” replacements for more-complex non-local and self-attention layers in state-of-the-art CNNs and ViT architectures. Our modules can achieve comparable, if not better, performance across a wide range of computer vision tasks while keeping a complexity equivalent to a standard linear layer.
BibTeX
@article{babiloni2023linear,
  author = {Francesca Babiloni and Ioannis Marras and Jiankang Deng and Filippos Kokkinos and Matteo Maggioni and Grigorios Chrysos and Philip H. S. Torr and Stefanos Zafeiriou},
  title = {{Linear Complexity Self-Attention With $3\{\textbackslash\{\}mathrm\{rd\}\}$3 rd Order Polynomials}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2023},
  url = {https://openreview.net/forum?id=2k_ogJ7Y3Si},
}

Loading related content...

Figure