Skip to main content

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

Metadata

Release files for thop 0.0.23-1907011323

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thop 0.0.23-1907011323
File Size Uploaded Provenance Actions
thop-0.0.23-1907011323.tar.gz 3.9 kB Without provenance Details for thop-0.0.23-1907011323.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thop 0.0.23-1907011323
File Interpreter ABI Platform Actions
thop-0.0.23.post1907011323-py3-none-any.whl Python 3 none any Details for thop-0.0.23.post1907011323-py3-none-any.whl

Total release size: 8.4 kB

Release files / thop-0.0.23-1907011323.tar.gz

Download URL thop-0.0.23-1907011323.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e5ed9030383abc2d4ade997a00095ee73f330254569bd35caf5935df3c768de0
BLAKE2b-256 checksum
How to use checksums
1d3e116687fcab006dd8d2e7591a89529bfa3ad84c34fd9bfe5e2eaa5b1a9500
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.post1907011323-py3-none-any.whl

Download URL thop-0.0.23.post1907011323-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b825fd3c023508e32e3de3c0dfab8477ec39ec9a90b2c07bfab9f0774599611
BLAKE2b-256 checksum
How to use checksums
cbe6ea1fa92b2d8114d2a62e5cbf8cd9e344063b46a8f46c91853cdd5734ad2d
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

Security for thop 0.0.23-1907011323

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page