This is a profiler to count the number of MACs / FLOPs of PyTorch models based on
pip install torchprofile
You should first define your PyTorch model and its (dummy) input:
import torch from torchvision.models import resnet18 model = resnet18() inputs = torch.randn(1, 3, 224, 224)
You can then measure the number of MACs using
from torchprofile import profile_macs macs = profile_macs(model, inputs)
This repository is released under the MIT license. See LICENSE for additional details.