Open
Description
I'm having a problem with ptflops 0.7.1 and higher.
I managed to isolate the problem to this sample code:
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv1d(1, 20, 5)
self.conv2 = nn.Conv1d(20, 20, 5)
def forward(self, x):
y = nn.functional.relu(self.conv1(x))
y = nn.functional.relu(self.conv2(y))
return y
from ptflops import get_model_complexity_info
model = Model()
input_shape = (48000,)
get_model_complexity_info(model, input_shape, as_strings=True, print_per_layer_stat=True)
In ptflops 0.7.0
I get 40.52 KMac
:
Model(
2.14 k, 100.000% Params, 40.52 KMac, 100.000% MACs,
(conv1): Conv1d(120, 5.607% Params, 120.0 Mac, 0.296% MACs, 1, 20, kernel_size=(5,), stride=(1,))
(conv2): Conv1d(2.02 k, 94.393% Params, 40.4 KMac, 99.704% MACs, 20, 20, kernel_size=(5,), stride=(1,))
)
Out: ('40.52 KMac', '2.14 k')
In version 7.0.1
and higher I get a value of 1.96 MMac
:
Model(
2.14 k, 100.000% Params, 40.52 KMac, 2.067% MACs,
(conv1): Conv1d(120, 5.607% Params, 120.0 Mac, 0.006% MACs, 1, 20, kernel_size=(5,), stride=(1,))
(conv2): Conv1d(2.02 k, 94.393% Params, 40.4 KMac, 2.061% MACs, 20, 20, kernel_size=(5,), stride=(1,))
)
Out[2]: ('1.96 MMac', '2.14 k')
Where does the large discepancy come from and which value is more reliable?