ViT模型片外访存分析对于ViT-tiny模型,其embedding大小为192。输入的patch_size为16,对于一张(256, 256)的图片而言,其总共包含1025个token(算上CLS token之后)。
考虑一个边缘端芯片,其总共的memory size一般<1Mb。若input_activation的memory与weight memory都为512Kb,且IA量化为8bit,weight量化为4bit的情况下。统计两个memory各自的访存。
ViT-tiny backbone layer计算$Q,K,V$将input feature map以170个token为1组放到片上,此时weight memory可以存下所有的QKV矩阵。生成的Q, K, V立即发出片外。总共的offchip access为 $ 170 \times 192 \times 8 \times 4 \times 6 = 11.95 Mb $,其中8为input activation (IA)的quantization bits, 4为load input feature map, off ...