关于GMac和FLOPs讨论

FLOPs: s小写,指浮点运算数,理解为计算量。可以用来衡量算法/模型的复杂度。(模型) 在论文中常用GFLOPs
(1 GFLOPs = 10^9 FLOPs)10亿次浮点运算数
(1 MFLOPs = 10^6 FLOPs)1百万次浮点运算数
一个MFLOPS(megaFLOPS)等于每秒一百万(=10^6)次的浮点运算,
一个GFLOPS(gigaFLOPS)等于每秒十亿(=10^9)次的浮点运算,
一个TFLOPS(teraFLOPS)等于每秒一万亿(=10^12)次的浮点运算,(1太拉)
一个PFLOPS(petaFLOPS)等于每秒一千万亿(=10^15)次的浮点运算,
一个EFLOPS(exaFLOPS)等于每秒一百京(=10^18)次的浮点运算,
一个ZFLOPS(zettaFLOPS)等于每秒十万京(=10^21)次的浮点运算。
https://github.com/sovrasov/flops-counter.pytorch

with torch.cuda.device(0):
macs, params = get_model_complexity_info(model, (3, 256, 192), as_strings=True,
                                         print_per_layer_stat=True, verbose=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', macs))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))

关于GMACs = GFLOPs讨论https://github.com/sovrasov/flops-counter.pytorch/issues/16
回答:
is there a typo here? I did a little reading and it seems that @snownus has it right. In general a multiply-accumulate is one multiplication and one addition, which can each be floating point operations. So 1 GMAC counts as 2 GFLOPs, meaning GMACs = .5 * GFLOPs (I’m not sure if this is what was already meant).

As for fused multiply-add (FMA) it seems that (if it is supported on a given chip/system) the two FLOPs are indeed computed “in a single step” (see here) or “at once” (see here). But this confuses our conversion. Perhaps in the case of FMA it is more accurate to say 1 GMACs = 1 GFLOPs? Hopefully someone with more expertise than me can clarify!
Params(M) MACs(G)

HRNet-W32 256×192实测
Computational complexity: 7.7 GMac
Number of parameters: 28.54 M
HRNet-W32256×192
论文中7.10 GFLOPs

你可能感兴趣的:(网络计算量,pytorch,tensorflow)