Lyken17/pytorch-OpCounter
Lyken17/pytorch-OpCounter has 5,085 GitHub stars and 537 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-06 16:23 UTC. Last push 2024-07-08.
Count the MACs / FLOPs of your PyTorch model.
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalTHOP: PyTorch-OpCounter
How to install
pip install thop (now continously intergrated on Github actions)
OR
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) macs, 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) macs, params = profile(model, inputs=(input, ), custom_ops={YourModule: count_your_model})Improve the output readability
Call
thop.clever_formatto give a better format of the output.from thop import clever_format macs, params = clever_format([macs, params], "%.3f")
Results of Recent Models
The implementation are adapted from torchvision. Following results can be obtained using benchmark/evaluate_famous_models.py.
|
|
Explore related projects
tensorflow/tensorflow
An Open Source Machine Learning Framework for Everyone
201,311 starshuggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
168,576 starsAUTOMATIC1111/stable-diffusion-webui
Stable Diffusion web UI
165,264 starsComfy-Org/ComfyUI
The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
145,310 stars