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.30-1908061459
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.30-1908061459.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thop-0.0.30.post1908061459-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / thop-0.0.30-1908061459.tar.gz
| Download URL | thop-0.0.30-1908061459.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f36fa90623368e54ee76350708d12159a317411bf839e43acd2ef8242040999
|
|
BLAKE2b-256 checksum How to use checksums |
1dc04c4ecf671552e9f816795cdfd7d5c7931ec64fd5a409194b561e7a664eea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / thop-0.0.30.post1908061459-py3-none-any.whl
| Download URL | thop-0.0.30.post1908061459-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5f39f17cf5ce25a865d527144a4cfb8e1314411667e44859285569d52845286
|
|
BLAKE2b-256 checksum How to use checksums |
a3a69f4a0443350aed1a4243cb169eb4fd9ae494008124e5e52a5bc829b06d2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|