Metadata-Version: 2.4
Name: t1c-viz
Version: 0.0.2
Summary: Interactive Visualizer for T1C-IR Graphs
Author-email: Murat Isik <murat@type1compute.com>, Anurag Daram <anurag@type1compute.com>, Subham Kumar Das <subham@type1compute.com>
Maintainer-email: Type 1 Compute <dev@type1compute.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/type1compute/t1cviz
Project-URL: Documentation, https://type1compute.github.io/docs/intro
Project-URL: Repository, https://github.com/type1compute/t1cviz.git
Project-URL: Issues, https://github.com/type1compute/t1cviz/-/issues
Project-URL: Changelog, https://github.com/type1compute/t1cviz/-/releases
Keywords: neuromorphic,spiking-neural-networks,snn,pytorch,deep-learning,machine-learning,visualizer,intermediate-representation,graph-visualization,visualizer
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: t1c-ir
Requires-Dist: rustworkx>=0.14.0
Requires-Dist: pillow>=9.0
Provides-Extra: tonic
Requires-Dist: tonic>=1.6.0; extra == "tonic"
Provides-Extra: all
Requires-Dist: tonic>=1.6.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
Requires-Dist: Cython>=3.0; extra == "dev"
Provides-Extra: jupyter
Requires-Dist: ipython>=8.38.0; extra == "jupyter"
Dynamic: license-file

<div align="center" style="background-color: #08081e; width: 100%; padding: 0;">
  <img alt="T1C-IR Logo" src="https://www.type1compute.com/images/t1c-logo-light.png" style="max-width: 200px; height: auto; display: block;">
</div>

<br>

# T1C-Viz - Interactive Visualization for T1C-IR Graphs


T1C-Viz generates beautiful, interactive HTML visualizations of T1C-IR computation graphs using D3.js and ELK for automatic layout. View your neural network architectures in Jupyter notebooks or export standalone HTML files.

T1C-Viz provides an intuitive way to explore and understand T1C-IR computation graphs, making it easier to debug, analyze, and document neuromorphic neural network architectures.

> Read more about T1C-IR in our [documentation](https://type1compute.github.io/docs/intro)

## Installation

```bash
uv add t1c-viz@git+ssh://git@github.com:type1compute/t1cir.git
```

Or with Jupyter support:

```bash
uv add "t1c-viz[jupyter]@git+ssh://git@github.com:type1compute/t1cir.git"
```

## Quick Start

```python
from t1c import ir, viz

# Load a graph
graph = ir.read('model.t1c')

# Display interactively (opens browser or shows in Jupyter)
viz.visualize(graph, title="My SNN Model")
```

## Display Methods

### Browser Display

Outside Jupyter, opens in default browser:

```python
viz.visualize(graph, title="My SNN Model")
# Output: Visualization written to: /tmp/t1c-viz/My_SNN_Model_xxx.html
```

### Jupyter Display

In Jupyter notebooks, displays as embedded iframe:

```python
viz.visualize(graph, title="My SNN", width=960, height=640)
```

### Export to File

Save as standalone HTML:

```python
path = viz.export_html(graph, "model.html", title="Production Model")
print(f"Saved to: {path}")
```

The HTML is self-contained - no server needed.

## Features

### Graph Visualization (Left Panel)

- **Dagre layout**: Automatic hierarchical graph layout
- **SNN-specific styling**: LIF neurons shown with distinctive spiking icon
- **Interactive**: Pan, zoom, click nodes to inspect
- **Parameter display**: Shows tau/theta on neuron nodes, kernel sizes on convolutions

### Data Explorer (Right Panel)

- **HDF5 tree**: Navigate graph structure
- **Array visualization**: Heatmaps for weights, line plots for biases
- **Statistics**: Min, max, mean, std for all arrays
- **Bidirectional sync**: Click in tree to highlight node in graph

## Node Colors

| Primitive | Color | Description |
|-----------|-------|-------------|
| Input | Green | Graph entry points |
| Output | Red | Graph exit points |
| Affine | Blue | Linear layers |
| SpikingAffine | Purple | Quantized affine with spike hints |
| LIF | Cyan | Leaky integrate-and-fire neurons |
| Conv2d | Orange | 2D convolution |
| SepConv2d | Deep Orange | Depthwise separable convolution |
| MaxPool2d | Brown | Max pooling |
| AvgPool2d | Blue Grey | Average pooling |
| Flatten | Grey | Reshape operations |
| Skip | Yellow | Residual/skip connections |

## Development

From the repo root (requires [t1c-ir](https://github.com/type1compute/t1cir.git) installed first):

```bash
uv pip install -e .
pytest tests/ -v
```
