GithubHelp home page GithubHelp logo

Comments (6)

AlbertiPot avatar AlbertiPot commented on August 19, 2024

code here for building network and using thop to count the flops
``
from xautodl.models import get_cell_based_tiny_net

index = 0
cifar10_config = api.get_net_config(index,'cifar10-valid')
print(cifar10_config)
cifar10_network = get_cell_based_tiny_net(cifar10_config)

from thop import profile
import torch

input = torch.randn(1,3,32,32)
flops, params = profile(cifar10_network, inputs={input,})
print(flops/1e6, params/1e6)
``

from nats-bench.

D-X-Y avatar D-X-Y commented on August 19, 2024

I use my own codes: https://github.com/D-X-Y/AutoDL-Projects/blob/main/xautodl/utils/flop_benchmark.py#L42
Basically, in my codes, I account these 6 kinds of ops.

isinstance(module, torch.nn.Conv2d)
        or isinstance(module, torch.nn.Linear)
        or isinstance(module, torch.nn.Conv1d)
        or isinstance(module, torch.nn.AvgPool2d)
        or isinstance(module, torch.nn.MaxPool2d)
        or hasattr(module, "calculate_flop_self")

from nats-bench.

D-X-Y avatar D-X-Y commented on August 19, 2024

And, personally, I do not know either thop or my codes are calculating the precise FLOPs. If you want the best FLOPs numbers, I would recommend https://github.com/facebookresearch/fvcore#features from Facebook.
Unfortunately, I did not realize this tool when I build the benchmark.

from nats-bench.

AlbertiPot avatar AlbertiPot commented on August 19, 2024

Really really thank you for your just in time reply. Currently, I am working on extracting each operation's params and flops in every cell from all stacks. Now my confusion about the mismatch between the data offered and tools is solved. I will look into your codes and facebook tools for help.
Many thanks and looking forward to your bravo works!

from nats-bench.

D-X-Y avatar D-X-Y commented on August 19, 2024

You are always welcome. If you are working on per cell's parameters and flops. fvcore is definitely what you need. Following their documentation, they have some nice APIs to show the module-level or OP-level FLOPs/#parameters. You can find more at: https://github.com/facebookresearch/fvcore/blob/main/docs/flop_count.md#our-work

from nats-bench.

AlbertiPot avatar AlbertiPot commented on August 19, 2024

YES, currently I am reading this doc, coot it is and really thank you for your help

from nats-bench.

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.