sovrasov / flops-counter.pytorch

Flops counter for convolutional networks in pytorch framework
MIT License
2.82k stars 307 forks source link

about MACS and FLOPS #98

Closed leeqiaogithub closed 1 year ago

leeqiaogithub commented 1 year ago

I suspect ptflops confused MACS with FLOPS.

for example: I got one conv = nn.Conv2d(3, 32, kernel_size=7, stride=2, padding=3) ptflops output is : 4.91 GMac (conv): Conv2d(0.005 M, 0.158% Params, 4.91 GMac, 1.879% MACs, 3, 32, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3)) We know by hand that conv operetor has a force of 4.877GFLPS.【2kkCinCoutHoutWout】

So I want to know if the library has the wrong units

sovrasov commented 1 year ago

See https://github.com/sovrasov/flops-counter.pytorch/issues/16 and https://github.com/sovrasov/flops-counter.pytorch/blob/master/ptflops/pytorch_ops.py#L53 for the reference. I don't know the input / output resolution in your example, so I can't say if it is correct or not.

leeqiaogithub commented 1 year ago

@sovrasov I think I made a mistake. My network was called twice, so the difference was exactly two times. But thank you for your reply!