A tool to count the FLOPs of PyTorch model.
Project description
THOP: PyTorch-OpCounter
How to install
-
Through PyPi
pip install thop
-
Using GitHub (always latest)
pip install --upgrade git+https://github.com/Lyken17/pytorch-OpCounter.git
How to use
-
Basic usage
from torchvision.models import resnet50 from thop import profile model = resnet50() input = torch.randn(1, 3, 224, 224) flops, params = profile(model, inputs=(input, ))
-
Define the rule for 3rd party module.
class YourModule(nn.Module): # your definition def count_your_model(model, x, y): # your rule here input = torch.randn(1, 3, 224, 224) flops, params = profile(model, inputs=(input, ), custom_ops={YourModule: count_your_model})
Results on Recent Models
Model | Params(M) | FLOPs(G) |
---|---|---|
alexnet | 61.10 | 0.71 |
vgg11 | 132.86 | 7.75 |
vgg11_bn | 132.87 | 7.76 |
vgg13 | 133.05 | 11.46 |
vgg13_bn | 133.05 | 11.48 |
vgg16 | 138.36 | 15.62 |
vgg16_bn | 138.37 | 15.65 |
vgg19 | 143.67 | 19.79 |
vgg19_bn | 143.68 | 19.82 |
densenet121 | 7.98 | 2.79 |
densenet161 | 28.68 | 7.69 |
densenet169 | 14.15 | 3.33 |
densenet201 | 20.01 | 4.28 |
resnet18 | 11.69 | 1.58 |
resnet34 | 21.80 | 3.44 |
resnet50 | 25.56 | 3.53 |
resnet101 | 44.55 | 7.26 |
resnet152 | 60.19 | 10.99 |
squeezenet1_0 | 1.25 | 0.70 |
squeezenet1_1 | 1.24 | 0.34 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thop-0.0.23-1907171430.tar.gz
.
File metadata
- Download URL: thop-0.0.23-1907171430.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0148585f52b185d4bd30e427c03ecae3fd78519f393c3ff864170c3612eeaf2 |
|
MD5 | 87c44d2a16fe8444d29fb33d1cfc160f |
|
BLAKE2b-256 | ae78be411a42dd908285d7d037ac01cc76df84ea03dbe25b01d7d523fd55ddfc |
File details
Details for the file thop-0.0.23.post1907171430-py3-none-any.whl
.
File metadata
- Download URL: thop-0.0.23.post1907171430-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ca9b375729e9718fd80e7f14666e400d25177d181a2242752b1d00e1f60a045 |
|
MD5 | a87628194bc3bd1fb73e0a9da83d6f0c |
|
BLAKE2b-256 | 124556dcc90ece0a04a34b802541461e2b72bf1d33df8a4631f9cb26dcc99eec |