Giter VIP home page Giter VIP logo

Comments (6)

ZhenpengChenCode avatar ZhenpengChenCode commented on July 18, 2024 4

Resnet flops calculated by the OpCOunter is smaller than the value in paper.

from pytorch-opcounter.

Lyken17 avatar Lyken17 commented on July 18, 2024

Yes, as pytorch is a dynamic graph library, it is impossible to determine skip-connection structure at nn.Module level.

One quick fix is to write a special judge for inverted residual block. I'll try to provide a more precise one via tracing computational graph.

from pytorch-opcounter.

Kylin9511 avatar Kylin9511 commented on July 18, 2024

@Lyken17 In torch1.1, a new placeholder module is provided for this kind of awkward situation.

See torch.nn.Idnetity

As I can see, you should add this Module into count_hooks.py and profile.py, counting the extra ops for skip connection.

And update your readme for special notice is important as well that one must use the standard module provided by PyTorch for skip connection to get an accurate FLOPs.

from pytorch-opcounter.

Lyken17 avatar Lyken17 commented on July 18, 2024

not really. Most existing codebase still defines the identity connection in forward. The real problem, as I mentioned before, is pytorch's define-by-run philosophy. The only way to record all operations is to trace the DAG.

In this case, please have a look at my labmate's project zhijian-liu/onnx-profiler

from pytorch-opcounter.

Kylin9511 avatar Kylin9511 commented on July 18, 2024

What you mentioned is quite right. I didn't say it would fix this problem without changing the codes. If someone would like to call your hook based op-counter while considering skip connection, he can represent skip connection with nn.Identity. And by adding this module to your profile we can fix the problem.

It is kind of a patch, not a global solution.

By unify the model to onnx mode is a very interesting idea, I may look deeper into it some time.

from pytorch-opcounter.

Kylin9511 avatar Kylin9511 commented on July 18, 2024

It is kind of like a user-defined patch, so I don't think you should update your project.

from pytorch-opcounter.

Related Issues (20)

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.