Metadata-Version: 2.4
Name: torchshapeflow
Version: 0.2.0
Summary: Static AST-based PyTorch tensor shape analysis.
Project-URL: Homepage, https://github.com/Davidxswang/torchshapeflow
Project-URL: Repository, https://github.com/Davidxswang/torchshapeflow
Project-URL: Issues, https://github.com/Davidxswang/torchshapeflow/issues
Project-URL: Documentation, https://davidxswang.github.io/torchshapeflow/
Author: TorchShapeFlow Contributors
License: MIT License
        
        Copyright (c) 2026 Xuesong Wang
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: typer>=0.16.0
Provides-Extra: dev
Requires-Dist: mkdocs-material>=9.5.0; extra == 'dev'
Requires-Dist: mkdocs>=1.6.0; extra == 'dev'
Requires-Dist: mypy>=1.18.0; extra == 'dev'
Requires-Dist: pytest>=8.3.0; extra == 'dev'
Requires-Dist: ruff>=0.11.0; extra == 'dev'
Requires-Dist: torch>=2.10.0; extra == 'dev'
Description-Content-Type: text/markdown

# TorchShapeFlow

[![CI](https://github.com/Davidxswang/torchshapeflow/actions/workflows/ci.yml/badge.svg)](https://github.com/Davidxswang/torchshapeflow/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/torchshapeflow)](https://pypi.org/project/torchshapeflow/)
[![Python](https://img.shields.io/pypi/pyversions/torchshapeflow)](https://pypi.org/project/torchshapeflow/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

TorchShapeFlow is a static, AST-based shape analyzer for PyTorch. It reads your Python source — no execution required — infers tensor shapes through your code, and reports mismatches as structured diagnostics.

```python
from typing import Annotated
import torch
import torch.nn as nn
from torchshapeflow import Shape

class Net(nn.Module):
    def __init__(self):
        self.conv = nn.Conv2d(3, 8, 3, padding=1)
        self.linear = nn.Linear(8 * 32 * 32, 10)

    def forward(self, x: Annotated[torch.Tensor, Shape("B", 3, 32, 32)]):
        y = self.conv(x)      # inferred: [B, 8, 32, 32]
        z = y.flatten(1)      # inferred: [B, 8192]
        return self.linear(z) # inferred: [B, 10]
```

```bash
$ tsf check mymodel.py
mymodel.py: ok
```

## Install

```bash
pip install torchshapeflow
```

## Documentation

Full docs at **[davidxswang.github.io/torchshapeflow](https://davidxswang.github.io/torchshapeflow)**

- [Quickstart](https://davidxswang.github.io/torchshapeflow/quickstart/) — install and run your first check
- [Annotation syntax](https://davidxswang.github.io/torchshapeflow/syntax/) — how to annotate your tensors
- [Supported operators](https://davidxswang.github.io/torchshapeflow/operators/) — what is analyzed and what shapes are inferred
- [Limitations](https://davidxswang.github.io/torchshapeflow/limitations/) — what the analyzer does not handle

## Contributing

```bash
git clone https://github.com/Davidxswang/torchshapeflow
cd torchshapeflow
make install   # uv sync --extra dev
make check     # format + lint + typecheck + tests
```

See [docs/development.md](docs/development.md) for the full development guide: all make targets, CI workflow descriptions, and how to add new operators.

## Release

See [RELEASING.md](RELEASING.md) for the full release procedure.

Build commands:

- `make python-dist` — wheel and sdist into `dist/`
- `make extension-package` — VS Code extension `.vsix`
- `make build` — both

Marketplace publishing in the release workflow is gated on GitHub Actions secrets:

- `VSCE_PAT` for the VS Code Marketplace
- `OVSX_PAT` for Open VSX
