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.2.tar.gz (22.1 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.2-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torchopviz-0.1.2.tar.gz
  • Upload date:
  • Size: 22.1 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.2.tar.gz
Algorithm Hash digest
SHA256 e59f019fee4ef59597c96e7db0b65114c3ac589011b8ef976aacc784359b19b4
MD5 83ee867d6c2957df07ceadbf9c969386
BLAKE2b-256 39ba3a59f977cf1f2581f4f629b079110fca22754117f90d17e6617d0a91de47

See more details on using hashes here.

File details

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

File metadata

  • Download URL: torchopviz-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3106ad80ecfe7fa45884e7e7aeceac8ae651dbd7a79021fff4a057025e9b3b9d
MD5 ec036af860e629d39e17faf3ce2cbaab
BLAKE2b-256 84687a44f001e3ec08cb7cd08c181f6bbb1613dbf4b1f0ff8fe80bfedf422776

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