/Lyken17/pytorch-OpCounter
The installation method is simple:
pip install thop
Basic Usage:
from import resnet50from thop import profile model = resnet50() flops, params = profile(model, input_size=(1, 3, 224,224))
Perform special calculations on your own mods:
class YourModule(): # your definition def count_your_model(model, x, y): # your rule hereflops, params = profile(model, input_size=(1, 3, 224,224), custom_ops={YourModule: count_your_model})
This above way of calculating the FLOPs of your own model in Pytorch is all that I have shared with you.