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, 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.
翻译:视觉变异器(ViT)在计算机愿景任务方面取得了快速进展,在各种基准上取得了令人乐观的成果。然而,由于参数和模型设计数量庞大,例如关注机制、基于ViT的模型通常比轻量级变速网络慢一倍。因此,实时应用的ViT尤其具有挑战性,特别是在诸如移动设备等资源受限制的硬件方面。最近的努力试图通过网络结构搜索或与移动网块混合设计来降低ViT的计算复杂性,但推力速度仍然不尽如人意。这导致一个重要问题:变频器能否在获得高性能时与移动网一样快速运行?为了回答这个问题,我们首先重新审查ViT型模型中使用的网络架构和操作员,并找出效率低下的设计。然后我们推出一个符合尺寸的纯变压器(没有移动网块)作为设计范例。最后,我们用粘力驱动的缩压精度来获得一系列的模型,调效值为美元,但是推力速度仍然不能令人满意。 大规模实验显示移动设备上高效的运行率和速度的优势。我们最快速的模型,以12-L1 运行中最精准的SyFors。