Metadata-Version: 2.4
Name: tensi-shapes
Version: 0.3.6
Summary: Named tensor shapes for unannotated PyTorch: hovers, shape errors and a CLI, built on Pyrefly.
Author: Tristan Farran
License-Expression: MIT
Project-URL: Homepage, https://github.com/tristan-farran/tensi
Project-URL: Issues, https://github.com/tristan-farran/tensi/issues
Project-URL: Changelog, https://github.com/tristan-farran/tensi/blob/main/CHANGELOG.md
Keywords: pytorch,tensor,shapes,type-checking,pyrefly,jaxtyping,einops,lsp
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyrefly==1.5.0
Requires-Dist: pyrefly-torch-stubs==1.5.0
Requires-Dist: pyrefly-shape-extensions==1.5.0
Requires-Dist: parso>=0.8.4
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: jaxtyping; extra == "test"
Requires-Dist: einops; extra == "test"
Dynamic: license-file

<p align="center">
  <img src="https://raw.githubusercontent.com/tristan-farran/tensi/main/brand/tensi-logo.svg" alt="tensi" width="440">
</p>

<p align="center">
  <b>tensi sees your tensors, and now you do too!</b><br>
  Hover any PyTorch tensor and see its shape, with <i>named dimensions</i>.
</p>

<p align="center">
  <img src="https://raw.githubusercontent.com/tristan-farran/tensi/main/docs/demo.gif" alt="tensi showing named tensor shapes in nanoGPT">
</p>

## Install


<p align="center">
  <a href="https://marketplace.visualstudio.com/items?itemName=TristanFarran.tensi">VS Code</a> ·
  <a href="https://pypi.org/project/tensi-shapes/">PyPI</a>
</p>

**Command line and CI:** `uv add --dev tensi-shapes` (or `pip install tensi-shapes`).

```bash
tensi peek model.py   # every tensor's shape
tensi check src/      # shape errors; exits 1 if any
```

## What you annotate

tensi works most shapes out on its own: from `b, t = idx.size()`, from callers in the same file,
from einops patterns and layer sizes. What it can't see is the shape of data arriving from outside
the file, so it tells you exactly which inputs need one annotation, and what to write:

```python
from jaxtyping import Shaped

def forward(self, idx: Shaped[torch.Tensor, "batch seq"]):
```

* One name per dimension, in order. A size name from `__init__` (like `n_embd`) links that axis to
  the layer sizes, a number fixes a size, any other name is a new size.
* In VS Code each such input has a blue hint with the line to write and a quick fix (Ctrl+. /
  Cmd+.) that writes it, or annotates every input in the file at once; the status bar counts them,
  and hovering a tensor with no shape says which input it depends on. `tensi peek` lists the same.
* No jaxtyping in your project? The quick fix imports it under `if TYPE_CHECKING:`, so your code
  runs without it. `Float`, `Int` and `Bool` work as well as `Shaped`.

tensi says when a newer release is out and how to install it (checked at most once a day, never in CI; `TENSI_NO_UPDATE_CHECK=1` turns it off).

<sub>Built on Pyrefly :)</sub>
