PyTorch model autopsy: count flops without the guesswork
A lightweight analyzer that prints layer-by-layer FLOPs, memory, and parameter counts for PyTorch models.

What it does
torchstat hooks into a PyTorch nn.Module and prints a per-layer table of theoretical compute costs: FLOPs, multiply-adds, parameter counts, and memory read/write estimates. You can call it from the CLI against a Python file or import it as a module and pass your model directly.
The interesting bit
The tool tries to estimate memory traffic (MemRead/MemWrite) alongside arithmetic, which most model summaries skip. That makes it slightly more useful for reasoning about bandwidth-bound vs. compute-bound layers, though the README warns that some layers like Dropout2d simply aren’t supported yet.
Key highlights
- CLI and Python API both available;
stat(model, (3, 224, 224))is the one-liner - Reports per-layer and total: params, FLOPs, MAdd, memory in MB, and byte-level memory traffic
- Layer support is limited to
nn.Modulesubclasses;torch.nn.functionalops are explicitly not supported - Built on prior work from
flops-counter.pytorchandpytorch_model_summary - Requires PyTorch 0.4.0+ and Python 3.6+ (versions that feel increasingly historical)
Caveats
- README marks the repo as “currently under development” with API changes possible
- Several TODOs remain un-checked: detailed layer-wise summary, export to table, and arbitrary input shapes
- Some layers emit blunt “not supported” warnings and report zero cost rather than failing gracefully
Verdict
Worth a look if you need quick, static estimates of model complexity on older PyTorch codebases. Skip it if you need production-grade profiling, dynamic shapes, or functional API support; PyTorch’s built-in profiler and tools like deepspeed.profiling have largely superseded this niche.