ZZZHANG-jx / DocRes

[CVPR 2024] DocRes: A Generalist Model Toward Unifying Document Image Restoration Tasks
MIT License
252 stars 24 forks source link

multiply by 2 when calculating floating-point operations? #10

Closed lxy5513 closed 4 weeks ago

lxy5513 commented 1 month ago
from thop import profile 
input = torch.rand((1, 6, 256, 256))
gflops,params = profile(model,inputs=(input,))
**gflops = gflops*2 / 10**9**
params = params / 10**6
print(gflops,'==============')
print(params,'==============')

 Hello, why do we need to multiply by 2 when calculating floating-point operations? @ZZZHANG-jx 
ZZZHANG-jx commented 1 month ago

The profile function in the thop library only considers the number of multiplications. If you also account for addition operations, the final FLOPs are approximately twice the result. For more details, you can refer to this link.

lxy5513 commented 4 weeks ago

@ZZZHANG-jx I get it, thanks for u kind replay