Skip to main content

A small package to create visualizations of PyTorch operation execution

Project description

TorchOpViz

A small package to create visualizations of PyTorch operation execution.

Install

Install PyTorch with CUDA support like:

pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126

Required torch>=2.1.0.

Install torchopviz:

pip3 install torchopviz

Usage

Offline mode:

"""
complex_graph.json is a list of tensors, torch operations and modules. Each element consist of: 
    id                  identity number for tensors and torch operations
    start_time          start timestamp(us)
    end_time            end timestamp(us)
    is_tensor           True for tensor
    is_leaf             True for tensor and torch operation
    label               module name/torch operation name/tensor shape
    parent              parent of torch op
    children            a children list of module, used to build trees of modules and torch ops
    next_nodes          a list of next nodes id, used to build graphs of tensors and torch ops
    info                lifetime, and metadata for tensors
You can generate your json file which can be displayed by "torchopviz".
"""
from torchopviz import offline_viz
offline_viz(file="./complex_graph.json")

Online mode:

import torch
from torch import nn
from torchopviz import online_viz
model = nn.Sequential()
model.add_module('W0', nn.Linear(8, 16))
model.add_module('tanh', nn.Tanh())
model.add_module('W1', nn.Linear(16, 1))
data = torch.randn(1,8)
online_viz(model, data, save_dir="./sample_data")

example

TODO

1.Display distributed computation

2.Combine memory usage info

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

torchopviz-0.1.3.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

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

torchopviz-0.1.3-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file torchopviz-0.1.3.tar.gz.

File metadata

  • Download URL: torchopviz-0.1.3.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for torchopviz-0.1.3.tar.gz
Algorithm Hash digest
SHA256 540b4d8a4fc874ef64f7fecca3183364484324eed9067b4b6fffdf7caf7eb6e6
MD5 7e5676442712a54e02d04af9dc9f6b3c
BLAKE2b-256 e552ed082c2349db0a2f826652d9e7c55dcaaa7b1f7525e749e380d196151aa5

See more details on using hashes here.

File details

Details for the file torchopviz-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: torchopviz-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for torchopviz-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6722e325448f313ad80827335b4529c4090e2d4df3e9e088596df78b911d00
MD5 7cfad1c1f998d7c05416a65d9b6c7f47
BLAKE2b-256 68e37dc45cd67cbcf835f7d8a9cd70409497cc55c27c7e05082a93788210dab1

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