Skip to content

thop undercounts FLOPs - missing bias operations #231

@RafsanjaniHub

Description

@RafsanjaniHub

The expected FLOPs count is 2,240, while thop shows 2160, which apparently overlooks biases term.

`import thop

x = torch.randn(size=(1, 3, 6, 6))

class Model(nn.Module):
def init(self):
super().init()
self.conv = nn.Sequential(
nn.Conv2d(in_channels=3, out_channels=5, kernel_size=(3, 3), groups=1, bias=True),
)

def forward(self, x):
    x = self.conv(x)
    return x

model = Model()

output = model(x)

print(f'output shape: {output.size()}')

FLOPs, params = thop.profile(model=model, inputs=(x,), verbose=False)
print(f'FLOPs: {FLOPs}')
print(f'Parameters: {params}')`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions