Code Monkey home page Code Monkey logo

pytorch-opcounter's Introduction

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

pytorch-opcounter's People

Contributors

bearpaw avatar exeex avatar lyken17 avatar ttumiel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.