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})
-
Improve the output readability
Call
thop.clever_formatto give a better format of the output.from thop import clever_format flops, params = clever_format([flops, params], "%.3f")
Results on Recent Models
|
|
Metadata
Release files for thop 0.0.23-1908021522
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.23-1908021522.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thop-0.0.23.post1908021522-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / thop-0.0.23-1908021522.tar.gz
| Download URL | thop-0.0.23-1908021522.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d56ca7aa9493be06e7140708dba93f4501a01db6713fccf0088cd449a1d0882
|
|
BLAKE2b-256 checksum How to use checksums |
3896623285be3be6743dd41be3a9ddaecf3bf2c6cc4d1542f5795243136e5de0
|
| 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.23.post1908021522-py3-none-any.whl
| Download URL | thop-0.0.23.post1908021522-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93f124e2e97aa1866857593369c0d3fdf2ca0bbbb99249b756d847b42000498a
|
|
BLAKE2b-256 checksum How to use checksums |
ccbe23c479c33d4e850e421eb4a5951ac0644dc8c55f6820b3a1b50bff4c90a8
|
| 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
|