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() flops, params = profile(model, input_size=(1, 3, 224,224))
-
Define the rule for 3rd party module.
class YourModule(nn.Module): # your definition def count_your_model(model, x, y): # your rule here flops, params = profile(model, input_size=(1, 3, 224,224), 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 |
Metadata
Release files for thop 0.0.22-1906241147
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thop-0.0.22-1906241147.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thop-0.0.22.post1906241147-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / thop-0.0.22-1906241147.tar.gz
| Download URL | thop-0.0.22-1906241147.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
808b5fc3c68b20d35d1c9c6c26ce6c0b388b345dfc199bbb51de95952a5e0df5
|
|
BLAKE2b-256 checksum How to use checksums |
abc6358f828956e14e6b7994e8850eb19d6e734f9c65f9a3396b38232b5cf815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / thop-0.0.22.post1906241147-py3-none-any.whl
| Download URL | thop-0.0.22.post1906241147-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6eb2cf2d66326800670ba9f5b6752029e7420ba30b644d08ee5a91a2595ba10a
|
|
BLAKE2b-256 checksum How to use checksums |
783c15592235a0d37c492448f679f558fb3e7d6dc8b57ff47c0f9b8e95a294f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|