arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.01452cs.CV
收藏

面向边缘设备的注意力图引导Transformer剪枝

Attention Map Guided Transformer Pruning for Edge Device

Nanjing University of Science and Technology(南京理工大学);Jilin University(吉林大学);University of Electronic Science and Technology of China(电子科技大学)

Junzhu Mao, Yazhou Yao, Zeren Sun, Xingguo Huang, Fumin Shen, Heng-Tao Shen

AI总结:

提出注意力图引导(AMG)的Transformer剪枝方法,通过移除冗余token和head降低计算与内存开销,在保持行人重识别精度的同时实现边缘设备友好部署。

摘要:

凭借对长距离依赖关系建模的显著能力,视觉Transformer(ViT)在整体和遮挡行人重识别(Re-ID)任务中均取得了可喜的成功。然而,Transformer的固有问题,如巨大的计算成本和内存占用,仍是两个未解决的问题,这将阻碍基于ViT的行人Re-ID模型在资源受限的边缘设备上的部署。我们的目标是在不牺牲行人Re-ID相当精度的情况下,降低推理复杂度和模型大小,特别是对于存在遮挡的任务。为此,我们提出了一种新颖的注意力图引导(AMG)Transformer剪枝方法,该方法在注意力图的引导下,以硬件友好的方式移除冗余的token和head。我们首先计算key维度的熵并对整个图进行求和,具有高熵的图对应的head参数将被移除以减小模型大小。然后,我们结合key token沿query维度的相似性和一阶梯度来估计token重要性,并移除冗余的key和value token以进一步降低推理复杂度。在Occluded DukeMTMC和Market-1501上的综合实验证明了我们提议的有效性。例如,我们在ViT-Base上提出的剪枝策略节省了29.4%的FLOPs,Rank-1下降了0.2%,mAP提升了0.4%。

英文摘要:

Due to its significant capability of modeling long-range dependencies, vision transformer (ViT) has achieved promising success in both holistic and occluded person re-identification (Re-ID) tasks. However, the inherent problems of transformers such as the huge computational cost and memory footprint are still two unsolved issues that will block the deployment of ViT based person Re-ID models on resource-limited edge devices. Our goal is to reduce both the inference complexity and model size without sacrificing the comparable accuracy on person Re-ID, especially for tasks with occlusion. To this end, we propose a novel attention map guided (AMG) transformer pruning method, which removes both redundant tokens and heads with the guidance of the attention map in a hardware-friendly way. We first calculate the entropy in the key dimension and sum it up for the whole map, and the corresponding head parameters of maps with high entropy will be removed for model size reduction. Then we combine the similarity and first-order gradients of key tokens along the query dimension for token importance estimation and remove redundant key and value tokens to further reduce the inference complexity. Comprehensive experiments on Occluded DukeMTMC and Market-1501 demonstrate the effectiveness of our proposals. For example, our proposed pruning strategy on ViT-Base enjoys \textup{\textbf{29.4\%}} \textup{\textbf{FLOPs}} savings with \textup{\textbf{0.2\%}} drop on Rank-1 and \textup{\textbf{0.4\%}} improvement on mAP, respectively.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑