Skip to main content

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()
    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

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

thop-0.0.23-1906241402.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thop-0.0.23.post1906241402-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file thop-0.0.23-1906241402.tar.gz.

File metadata

  • Download URL: thop-0.0.23-1906241402.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

Hashes for thop-0.0.23-1906241402.tar.gz
Algorithm Hash digest
SHA256 1aee0bb0f1a435cca6abf9775909304c23b6c2f2cbb0121160bc92ef50ffc1d5
MD5 6c1cf6e41b3bedfac73506c8d0238f88
BLAKE2b-256 dd9fdcbfec5ce60a9576451dedc394e9d3c2c8fa70fe15d4b9a52744e9279104

See more details on using hashes here.

File details

Details for the file thop-0.0.23.post1906241402-py3-none-any.whl.

File metadata

  • Download URL: thop-0.0.23.post1906241402-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

Hashes for thop-0.0.23.post1906241402-py3-none-any.whl
Algorithm Hash digest
SHA256 5dfa20634001d133a06b8cccf39682f7760d12957cc448062b169b746bc9028a
MD5 2d65b3f8a944762570de9733a4f83e99
BLAKE2b-256 9fdf79e3f195584d352e363862642f068194c0a0e115b0b03f0d7f989cce513f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page