facebookresearch / fvcore

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

Feed two batches and then dividing the ended FLOPs by 2 to avoid the batch_norm error? #132

Open cloude-z opened 1 year ago

cloude-z commented 1 year ago

Hi dear fvcore team,

in my model there is a very special case, where the input tensor only have the shape of [3, 1, 1] and [9, 1, 1], thus while estimating the FLOPs by feeding only one batch, the BatchNorm2d layer can't handle this sinlge input tensor and also it seems that fvcore lib doesn't consider this case too, so an error will just be threw out.

So I'm just wondering is it possible to feed two batches and get the FLOPs computed over them, then dividing the FLOPs by 2 to have the equivalent FLOPs as feeding one batch? Just as a beginner in computing FLOPs so really have no too much idea if this works in theory.... so I would appreciate if I can have some answers on this question. Big thanks in advance!