Created
July 4, 2023 22:37
-
-
Save Leumastai/4aa25b47b267175cbc32bc6d5ba02ad2 to your computer and use it in GitHub Desktop.
fvcore flops calculator fo pytorch model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ from fvcore.nn import FlopCountAnalysis | |
$ flops = FlopCountAnalysis(model, input) | |
$ flops.total() | |
-> 274656 | |
$ flops.by_operator() | |
-> Counter({'conv': 194616, 'addmm': 80040}) | |
$ flops.by_module() | |
-> Counter({'': 274656, 'conv1': 48600, | |
-> 'conv2': 146016, 'fc1': 69120, | |
-> 'fc2': 10080, 'fc3': 840}) | |
$ flops.by_module_and_operator() | |
-> {'': Counter({'conv': 194616, 'addmm': 80040}), | |
-> 'conv1': Counter({'conv': 48600}), | |
-> 'conv2': Counter({'conv': 146016}), | |
-> 'fc1': Counter({'addmm': 69120}), | |
-> 'fc2': Counter({'addmm': 10080}), | |
-> 'fc3': Counter({'addmm': 840})} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment