1. Conduid
  2. Developer Tools
  3. Tensordiagram
MCP server · Developer Tools

Tensordiagram

Diagram tensors from torch, jax, tensorflow, numpy, etc., for understanding and debugging

Unclaimed MIT last commit 10 months ago devtools
61Good

Scored 3 days ago · breakdown

About Tensordiagram

Tensordiagram is an MCP server published by hardik-vala in the Developer Tools category: diagram tensors from torch, jax, tensorflow, numpy, etc., for understanding and debugging.

The repository has 59 stars and 1 forks, with the last commit 10 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/hardik-vala/tensordiagram

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Tensordiagram

Powered by Claude · Grounded in docs

I know everything about Tensordiagram. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • ✓Tests presentA test suite exists in the repository.
  • !Dependencies pinnedNo lockfile. Installs can pull different code over time.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

Releases

v0.2.1v0.2.1 · 24 Nov 2025What's Changed Add color argument to fill_values method by @hardik-vala in https://github.com/hardik-vala/tensordiagram/pull/1 Add tensor diagram Image object generation by @hardik-vala in https://github.com/hardik-vala/tensordiagram/pull/2
v0.2.0v0.2.0 · 22 Nov 2025Changelog [0.2.0] - 2025-11-22 Changed BREAKING: Dimension API Update Changed dimension annotation API from string-based to integer-based `annotate_dim_indices()` now uses integer literals (0, 1, 2) instead of strings ("row", "col",…
v0.1.2v0.1.2 · 31 Oct 2025added font size and format customization when filling values added font size customization when annotating dimension indices
v0.1.1v0.1.1 · 27 Oct 2025.

README

tensordiagram

example diagram

A python library for visualizing tensors from torch, jax, tensorflow, numpy, etc. Helps with learning and debugging in notebooks and other contexts. It's built on top of the graphics backend, chalk.

If you want to practice your tensor skills, try Tensor Puzzles 2. It's a notebook with a collection of hands-on pytorch puzzles. And yes, it uses tensordiagram 😃. If you're interested in learning modern ML engineering, check out qaggle.

why

Debugging deep learning code is hard—especially when it's foreign, because it's hard to imagine tensor manipulations, e.g. F.conv2d(x.unsqueeze(1), w.transpose(-1, -2)).squeeze().view(B, L, -1) in your head. Printing shapes and tensor values only gets you so far. tensordiagram lets me easily represent tensors visually, inside python code, notebooks, and interpreter sessions.

Other python libraries for creating tensor diagrams are either too physics and math focused, not notebook-friendly, limited to visualizing single tensors, and/or serve a wider purpose (so have a steep learning curve).

install

pip install tensordiagram

Separately, you'll need to install cairo for PNG rendering and Image objects:

# might need to install the base library first on debian
sudo apt-get install libcairo2-dev

# cairo python bindings + Pillow for Image objects
pip install ".[cairo]"

Or, for SVG rendering and Image objects:

# includes cairosvg + Pillow for Image objects
pip install ".[svg]"

intro

For an in-depth guide, refer to this notebook.

import numpy as np
import tensordiagram as td

tensor = np.arange(12).reshape(3, 4)
diagram = td.to_diagram(tensor)

plain 3x4 matrix

The diagram can be saved using render_png or render_svg:

diagram.render_png("output.png", height=300)

Alternatively, render to a PIL Image object instead of saving to disk:

# Render to a PIL Image object
img = diagram.to_image_png(height=300)  # Returns PIL.Image.Image

# Or use the generic to_image() method (uses PNG by default)
img = diagram.to_image(height=300)

# Can also render via SVG and convert to Image
img = diagram.to_image_svg(height=300)

Style and annotate diagrams:

diagram \
  .fill_values() \
  .fill_color("lightblue") \
  .annotate_dim_size(dim=0, color="lightgreen")

styled 3x4 matrix

3d tensor:

papaya = "#ff9700"

tensor = np.arange(24).reshape((2, 3, 4))
diagram = td.to_diagram(tensor).fill_color(papaya)

3d tensor

Combine tensor and chalk diagrams for intricate outputs:

import random
import torch

color_names = [ "red", "blue", "green", "purple", "orange", "pink", "cyan"]

def random_colors_tensor(shape):
  colors_array = np.empty(shape, dtype=object)
  for index, _ in np.ndenumerate(colors_array):
    colors_array[index] = random.choice(color_names)
  return colors_array

color_tensor = random_colors_tensor(shape=(2, 3, 4))

# tensors
t = torch.arange(24).reshape((2, 3, 4))
slice_1 = t[0, :, :].unsqueeze(0)
slice_2 = t[:, 1, :].unsqueeze(1)

# tensor diagrams
t_d = td.to_diagram(t).fill_color(lambda idx, v: color_tensor[idx])
slice_1_d = td.to_diagram(slice_1).fill_color(lambda idx, v: color_tensor[idx])
slice_2_d = td.to_diagram(slice_2).fill_color(lambda idx, v: color_tensor[idx[0], 1, idx[2]])

# chalk diagrams
diagrams = []
for d in [t_d, slice_1_d, slice_2_d]:
  diagrams.append(d.to_chalk_diagram().center_xy())

# composite diagram
composite = chalk.hcat(diagrams, 1.0)

# add background + display
composite = composite.pad(1.5).center_xy()
env = composite.get_envelope()
chalk.set_svg_height(300)
chalk.rectangle(env.width * 0.8, env.height).fill_color(Color("white")) + composite.translate(dx=env.width * 0.1, dy=0)

complex diagram

For more examples and documentation, refer to this guide.

dev

pip install -e ".[dev]"

test

setup

Visual regression tests compare rendered output against reference images stored in fixtures/.

To generate or update reference images:

# all reference images
python tests/generate_references.py --all

# list reference images
python tests/generate_references.py --list

# select reference images
python tests/generate_references.py 3d_tensor styled_gradient

run

All tests:

pytest

deploy

main package (tensordiagram)

  1. update version in pyproject.toml and commit
  2. git tag vX.X.X
  3. git push origin vX.X.X (auto-triggers gh action for publishing to PyPI)
  4. create a new gh release with the tag

mcp package (tensordiagram-mcp)

  1. update version in mcp/pyproject.toml and commit
  2. git tag mcp-vX.X.X
  3. git push origin mcp-vX.X.X (auto-triggers gh action for publishing to PyPI)
  4. create a new gh release with the tag

license

MIT

README fetched from the repository 5 days ago. The original is authoritative.

Questions

About Tensordiagram

How do I install Tensordiagram?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Tensordiagram safe to use with an AI agent?

Its trust score is 61 out of 100 (good). It passes 4 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Tensordiagram still maintained?

The last commit was 10 months ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.