A tool to count the FLOPs of PyTorch model.
Project description
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() input = torch.randn(1, 3, 224, 224) flops, 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) flops, params = profile(model, inputs=(input, ), custom_ops={YourModule: count_your_model})
Results on Recent Models
|
|
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
thop-0.0.23-1908021457.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for thop-0.0.23.post1908021457-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6beeaaf69843c253c91b27e0c6affb32d7ffd28f4b2184bb191c90a1942778f2 |
|
MD5 | f1641eeab812bd869096f205f6232d2c |
|
BLAKE2b-256 | d40f7b35dc30299b89ac294159e8a8eeb9c0e3247f193cfc84cbc5f62eeafb40 |