Table of Contents
Fetching ...

EfficientFormer: Vision Transformers at MobileNet Speed

Yanyu Li, Geng Yuan, Yang Wen, Ju Hu, Georgios Evangelidis, Sergey Tulyakov, Yanzhi Wang, Jian Ren

TL;DR

The paper investigates why Vision Transformers lag on mobile hardware and introduces EfficientFormer, a dimension-consistent pure-transformer design optimized for on-device latency. It combines 4D Conv-BN based early blocks with 3D MHSA in later stages and uses a latency-driven slimming procedure to configure architectures under target latency. Empirical results show EfficientFormer-L1 achieving 79.2% top-1 on ImageNet at 1.6 ms on iPhone 12 and EfficientFormer-L7 reaching 83.3% at 7 ms, outperforming comparable CNN and ViT baselines on mobile devices. The work demonstrates that transformers can achieve ultra-fast edge inference alongside strong accuracy, and it establishes EfficientFormer as a robust backbone for detection and segmentation tasks.

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.

EfficientFormer: Vision Transformers at MobileNet Speed

TL;DR

The paper investigates why Vision Transformers lag on mobile hardware and introduces EfficientFormer, a dimension-consistent pure-transformer design optimized for on-device latency. It combines 4D Conv-BN based early blocks with 3D MHSA in later stages and uses a latency-driven slimming procedure to configure architectures under target latency. Empirical results show EfficientFormer-L1 achieving 79.2% top-1 on ImageNet at 1.6 ms on iPhone 12 and EfficientFormer-L7 reaching 83.3% at 7 ms, outperforming comparable CNN and ViT baselines on mobile devices. The work demonstrates that transformers can achieve ultra-fast edge inference alongside strong accuracy, and it establishes EfficientFormer as a robust backbone for detection and segmentation tasks.

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 top-1 accuracy on ImageNet-1K with only ms inference latency on iPhone 12 (compiled with CoreML), which runs as fast as MobileNetV2 ( ms, top-1), and our largest model, EfficientFormer-L7, obtains accuracy with only ms latency. Our work proves that properly designed transformers can reach extremely low latency on mobile devices while maintaining high performance.
Paper Structure (15 sections, 8 equations, 4 figures, 6 tables, 1 algorithm)

This paper contains 15 sections, 8 equations, 4 figures, 6 tables, 1 algorithm.

Figures (4)

  • Figure 1: Inference Speed vs. Accuracy. All models are trained on ImageNet-1K and measured by iPhone 12 with CoreMLTools to get latency. Compared to CNNs, EfficientFormer-L1 runs $40\%$ faster than EfficientNet-B0, while achieves $2.1\%$ higher accuracy. For the latest MobileViT-XS, EfficientFormer-L7 runs $0.2$ ms faster with $8.5\%$ higher accuracy.
  • Figure 2: Latency profiling. Results are obtained on iPhone 12 with CoreML. The on-device speed for CNN (MobileNetV2$\times 1.4$, ResNet50, and EfficientNet-B0), ViT-based models (DeiT-Small, LeViT-256, PoolFormer-S24, and EfficientFormer), and various operators are reported. The latency of models and operations are denoted with different color. ($\cdot$) is the top-1 accuracy on ImageNet-1K. † LeViT uses HardSwish which is not well supported by CoreML, we replace it with GeLU for fair comparison.
  • Figure 3: Overview of EfficientFormer. The network starts with a convolution stem as patch embedding, followed by MetaBlock ($\texttt{MB}$). The $\texttt{MB}^{4D}$ and $\texttt{MB}^{3D}$ contain different token mixer configurations, i.e., local pooling or global multi-head self-attention, arranged in a dimension-consistent manner.
  • Figure 4: Analysis of hardware utilization on iPhone 12 NPU.