MACs 和 FLOPs 有什么区别?如何计算?

MACs 和 FLOPs 有什么区别?如何计算?,第1张

MACs 和 FLOPs 有什么区别?如何计算? 一、MACs 和 FLOPs 有什么区别?

FLOPs is abbreviation of floating operations which includes mul / add / div … etc.

MACs stands for multiply–accumulate operation that performs a <- a + (b x c).12

二、如何计算?

安装thop

pip install thop

pytorch使用thop:3

from torchvision.models import resnet50
from thop import profile
model = resnet50()
input = torch.randn(1, 3, 224, 224)
macs, params = profile(model, inputs=(input, ))
三、MACs 和 FLOPs的关系

粗略的:4,1,5

MACs = 2 * FLOPs

  1. https://github.com/Lyken17/pytorch-OpCounter/tree/master/benchmark#macs-flops-what-is-the-difference ↩︎ ↩︎

  2. https://github.com/Lyken17/pytorch-OpCounter/issues/46 ↩︎

  3. https://github.com/Lyken17/pytorch-OpCounter ↩︎

  4. https://zhuanlan.zhihu.com/p/364543528 ↩︎

  5. https://github.com/sovrasov/flops-counter.pytorch/issues/16 ↩︎

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/3971936.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-10-21
下一篇2022-10-21

发表评论

登录后才能评论

评论列表(0条)

    保存