FLOPS & FLOPs & MACs
參考鏈接:
https://www.zhihu.com/question/65305385
https://zhuanlan.zhihu.com/p/144938518
https://zhuanlan.zhihu.com/p/137719986
https://zhuanlan.zhihu.com/p/364543528
FLOPS:
FLOPS (Floating Point Operations Per Second):每秒浮點運算次數,是一個衡量硬件速度的指標。
FLOPs:
FLOPs(Floating Point Operations):浮點運算次數,用來衡量模型計算復雜度,常用來做神經網絡模型速度的間接衡量標准。FLOPS與FLOPs常常被人們混淆使用。
MACs:
MACs (Multiply–Accumulate Operations): 乘加累積操作數,常常被人們與FLOPs概念混淆實際上1 MACs 包含一個乘法操作與一個加法操作,大約包含2 FLOPs。通常 MACs 與 FLOPs 存在一個2倍的關系。
Tools:
THOP:https://github.com/Lyken17/pytorch-OpCounter
示例如下:
import torch
import thop
import torchvision
m = torch.nn.Conv2d(128, 128, 1)
x = torch.randn(1, 128, 16, 16)
macs = thop.profile(m, inputs=(x,), verbose=True)
fprint(macs)