Lightweight PyTorch/TensorFlow model profiler
Project description
Tiny Model Profiler
A lightweight tool to quickly profile PyTorch models.
Shows parameter count, estimated memory usage, and FLOPs in one command.
Author: Mahika Shah
Features
- Parameter Count – Total trainable parameters in your model
- Memory Usage – Estimated size (in MB) of model parameters (float32)
- FLOPs – Estimated multiply–add operations (requires torchinfo)
- Lightweight – No heavy dependencies
Installation
Run: pip install tiny-model-profiler
Requirements: torch >= 1.7.0 torchinfo (installed automatically for FLOPs estimation)
Usage Example
Example 1: Using a torchvision model
from tiny_model_profiler import profile import torchvision.models as models
Load a pretrained ResNet-18
model = models.resnet18()
Profile the model
profile(model, input_size=(1, 3, 224, 224))
Expected Output:
Parameters: 11,689,512 Estimated Memory: 44.63 MB FLOPs: 3.64 GFLOPs
Example 2: Using a custom model
import torch.nn as nn from tiny_model_profiler import profile
class DummyModel(nn.Module): def init(self): super().init() self.fc = nn.Linear(10, 5)
def forward(self, x):
return self.fc(x)
model = DummyModel() profile(model, input_size=(1, 10))
Expected Output:
Parameters: 55 Estimated Memory: 0.00 MB FLOPs: 50.00 FLOPs
Function Details
profile(model, input_size=(1, 3, 224, 224))
Arguments: model (torch.nn.Module) – The model to profile input_size (tuple) – Input tensor size for FLOPs estimation Format: (batch_size, channels, height, width) For MLPs: (batch_size, input_features)
Output: Prints: - Total Parameters - Estimated Memory Usage in MB - Estimated FLOPs
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiny-model-profiler-0.3.1.tar.gz.
File metadata
- Download URL: tiny-model-profiler-0.3.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22eae3a9fe5bf205b19e584cf535549b301be30b6664119063306e43c0938509
|
|
| MD5 |
cec90b134174db146be0edd54010b872
|
|
| BLAKE2b-256 |
05ab1a6458792b0d9d8238ea1949f0827abfe95c0aad25df85083a5b99efce06
|
File details
Details for the file tiny_model_profiler-0.3.1-py3-none-any.whl.
File metadata
- Download URL: tiny_model_profiler-0.3.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9c153432bebefffd9e47058da636827e57041e679eb74bdad97647ca4680a97
|
|
| MD5 |
f9adb75b0e731904df4d4b2d5b5667fe
|
|
| BLAKE2b-256 |
c5f8d3e4c1e9e3c2d3d43a0f5f103ab16fcc515508446b6143bc31131961695c
|