项目
在 GitHub 查看
Lyken17/pytorch-OpCounter
Lyken17/pytorch-OpCounter has 5,084 GitHub stars and 538 forks. GitHot measured 0 stars in 24 hours, +1 in 7 days, and -1 in 15 days. Last checked 2026-11-23 03:12 UTC. Last push 2024-07-08.
实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
关于
统计 PyTorch 模型的 MAC 数和 FLOP 数。
机器学习README.md
原文THOP: 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.
|
|
探索相关项目
加载中…