Skip to main content

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

  1. Parameter Count – Total trainable parameters in your model
  2. Memory Usage – Estimated size (in MB) of model parameters (float32)
  3. FLOPs – Estimated multiply–add operations (requires torchinfo)
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiny-model-profiler-0.3.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiny_model_profiler-0.3.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

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

Hashes for tiny-model-profiler-0.3.1.tar.gz
Algorithm Hash digest
SHA256 22eae3a9fe5bf205b19e584cf535549b301be30b6664119063306e43c0938509
MD5 cec90b134174db146be0edd54010b872
BLAKE2b-256 05ab1a6458792b0d9d8238ea1949f0827abfe95c0aad25df85083a5b99efce06

See more details on using hashes here.

File details

Details for the file tiny_model_profiler-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tiny_model_profiler-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9c153432bebefffd9e47058da636827e57041e679eb74bdad97647ca4680a97
MD5 f9adb75b0e731904df4d4b2d5b5667fe
BLAKE2b-256 c5f8d3e4c1e9e3c2d3d43a0f5f103ab16fcc515508446b6143bc31131961695c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page