-
Notifications
You must be signed in to change notification settings - Fork 24.3k
[Feature Request] Calculating FLOPs for computational graph operations #5013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@soumith, this will be important, but it's low priority for now as we're still experimenting outside of pytorch. We're setting something up similar to this, but not as part of any framework for now. Maybe we can port that code to pytorch later on, but I can't promise anything. |
Would be nice to track which networks do well on which processors - and also roll up datacenter level metrics. @cpuhrsch are you building a tool outside of PyTorch that will take in a model specification and emit these numbers for every op? |
@shubho for now we're doing this one op at a time. For example, we're building it out far enough to optimize a function such as torch.sum, but within C++ only. Presumably, as we work our way through this, a tool that will create these (and many more) metrics per op for a model could emerge. For now that'd be over-engineering our tooling. |
I've come across this script to count ops and params for basic layers. It's reasonably advanced (most 2D convs and pooling). Maybe it compliments your porting efforts @cpuhrsch. |
If someone still needs this, we wrote a small script to do that: Example of usage: |
Also I've improved the above mentioned scripts to support grouped convolutions and several other layers: |
We can compute FLOPs of conv layers by hand or by existing repos easily. |
@zheng-xq - Is this something that could be of interest to you? |
Came across this library which also counts number of parameters and FLOPs used by a model given an input. |
I came across this repo: https://github.com/ceykmc/pytorch_model_summary AFAIK it's not distributed on pypi, but it gives you a pretty detailed summary. |
I just found this: Autograd profiler I wonder if this can be used for calculating the FLOPs and memory usage. I tried the chrome trace export, but I'm not yet sure how to get something useful out of it. |
Just to collect another solution https://github.com/Tramac/torchscope. But it could be better if there will be an off the shelf solution directly in pytorch. |
@pietern says, this has essentially already been implemented on the Caffe2 side; there's a lot of overlap here. |
cc @ilia-cher |
so ... any plan to provide such calculator in the next version pytorch? It would be nice to have an official tool to calculate FLOPS. 3rd party implementations might not support the extension of pytorch ops properly. |
well you know, something like tf.profiler.profile(g, run_meta=run_meta, cmd='op', options=opts) would be very helpful. |
@ruiyuanlu Is it also working with Keras? |
Are there any plans on implementing that idea? |
Bumping priority so we don't forget about this. |
cc @ngimel, who's been doing work in this area |
cc. @xuzhao9 is working on adding flops into profiler output |
#46506 is the profiler PR. |
In fvcore we created the first flop counter which has two following features together:
We gave an introduction of it at this documentation: https://github.com/facebookresearch/fvcore/blob/master/docs/flop_count.md |
a simple compare with different flops count lib, in short, I recommand fvcore https://gist.github.com/Jackiexiao/2b053cd52d977d86e07d664688c0a7ee |
i see this has been open for awhile. is there trouble getting a dev to fix this issue? what is blocking this for so long |
Can we close this @Chillee @albanD? afaict this has been implemented (https://gist.github.com/Chillee/07b36672a0ca2d1280e42b8d10f23174) |
Uh oh!
There was an error while loading. Please reload this page.
Feature Request: Please consider adding a floating point operations calculator for computational graph operations.
We'd like to use it for the deep learning models.
cc @ezyang @gchanan @zou3519 @bdhirsh @heitorschueroff @VitalyFedyunin @ngimel
The text was updated successfully, but these errors were encountered: