Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large discrepancy between ptflops 0.7.0 and 0.7.1 #143

Open
postrational opened this issue Sep 3, 2024 · 0 comments
Open

Large discrepancy between ptflops 0.7.0 and 0.7.1 #143

postrational opened this issue Sep 3, 2024 · 0 comments

Comments

@postrational
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant