facebookresearch / fvcore

Collection of common code that's shared among different research projects in FAIR computer vision team.
Apache License 2.0
1.93k stars 226 forks source link

DeformConv2d not supported in FLOPs counting? #121

Open kenmbkr opened 1 year ago

kenmbkr commented 1 year ago

I tested flop counting for DeformConv2d and I am getting 0 for flops. The code to reproduce is as follows. Please kindly advise how to get the correct FLOPs.

import torch
from fvcore.nn import FlopCountAnalysis, flop_count_table
from torchvision.ops import DeformConv2d

kernel_size = 3
conv = DeformConv2d(64, 64, kernel_size=kernel_size, padding=1)
x = torch.randn(1, 64, 64, 64)
offset = torch.randn(1, 2 * kernel_size * kernel_size, 64, 64)

flops = FlopCountAnalysis(conv, (x, offset))
print(flop_count_table(flops, max_depth=1))
| module   | #parameters or shape   | #flops   |
|:---------|:-----------------------|:---------|
| model    | 36.928K                | 0        |
|  weight  |  (64, 64, 3, 3)        |          |
|  bias    |  (64,)                 |          |
ppwwyyxx commented 1 year ago

print(flops.unsupported_ops()) will show that deform_conv was encountered once in the model but unsupported (because its formula was not included).

kenmbkr commented 1 year ago

print(flops.unsupported_ops()) will show that deform_conv was encountered once in the model but unsupported (because its formula was not included).

@ppwwyyxx Thank you for the confirmation. Are there any plans to support it in the future?