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.1.tar.gz (21.4 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.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torchopviz-0.1.1.tar.gz
  • Upload date:
  • Size: 21.4 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.1.tar.gz
Algorithm Hash digest
SHA256 915ccf62de0a4c01af6b9eda3010089b19da65bd29f5fe5cb3302b92ca2da496
MD5 452e4642419042a0e09d84fbd8e01bbb
BLAKE2b-256 eb534933058c9a8d0e0299c29307e09d63715dbd436ec751d7c13f1111821e43

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torchopviz-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 229d8fb63948bc8a8ab78700d75ef113d2dea335b286048b1bc60ad21b568e58
MD5 008d2da3c1543597705a6d26c04ad015
BLAKE2b-256 9791ec4352cf706993f13c1e66500f0818d2d11390933f7eb9a190bbe8459329

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