EfficientFormer: Vision Transformers at MobileNet Speed

Yanyu Li, Geng Yuan, Yang Wen, Ju Hu, Georgios Evangelidis +3 more
6/2/2022
cs.CV

Official code: huggingface/pytorch-image-models (36,940 stars, Apache-2.0, PyTorch, last commit 2026-04-29). 1 more implementation below.

Abstract

Vision Transformers (ViT) have shown rapid progress in computer vision tasks, achieving promising results on various benchmarks. However, due to the massive number of parameters and model design, \textit{e.g.}, attention mechanism, ViT-based models are generally times slower than lightweight convolutional networks. Therefore, the deployment of ViT for real-time applications is particularly challenging, especially on resource-constrained hardware such as mobile devices. Recent efforts try to reduce the computation complexity of ViT through network architecture search or hybrid design with MobileNet block, yet the inference speed is still unsatisfactory. This leads to an important question: can transformers run as fast as MobileNet while obtaining high performance? To answer this, we first revisit the network architecture and operators used in ViT-based models and identify inefficient designs. Then we introduce a dimension-consistent pure transformer (without MobileNet blocks) as a design paradigm. Finally, we perform latency-driven slimming to get a series of final models dubbed EfficientFormer. Extensive experiments show the superiority of EfficientFormer in performance and speed on mobile devices. Our fastest model, EfficientFormer-L1, achieves $79.2\%$ top-1 accuracy on ImageNet-1K with only $1.6$ ms inference latency on iPhone 12 (compiled with CoreML), which runs as fast as MobileNetV2$\times 1.4$ ($1.6$ ms, $74.7\%$ top-1), and our largest model, EfficientFormer-L7, obtains $83.3\%$ accuracy with only $7.0$ ms latency. Our work proves that properly designed transformers can reach extremely low latency on mobile devices while maintaining high performance.

View on arXivView PDF

Code Implementations(2)

PyTorchApache-2.0

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

36,9405,171MDX, ShellFeb 2, 20195 months agoApache-2.0
augmixconvnextdistributed-trainingefficientnetimage-classification+15 more
PyTorch

EfficientFormerV2 [ICCV 2023] & EfficientFormer [NeurIPs 2022]

1,11695Shell, PythonJun 2, 20223 years agoNOASSERTION
deep-learningdetectionefficient-inferenceefficient-neural-networksimagenet+5 more

Similar Papers

Cite this paper

@article{li2022efficientformer,
  title  = {EfficientFormer: Vision Transformers at MobileNet Speed},
  author = {Yanyu Li and Geng Yuan and Yang Wen and Ju Hu and Georgios Evangelidis and Sergey Tulyakov and Yanzhi Wang and Jian Ren},
  year   = {2022},
  eprint = {2206.01191},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2206.01191}
}

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/2206.01191.svg)](https://codeofpaper.com/paper/2206.01191)

Discussion