Skip to main content

One post tagged with "pytorch"

View All Tags

Talk: Tensor Shapes in the Type System

· 14 min read

Why aren't tensor shapes part of the type system?

When you write a PyTorch model, the hardest part of composing tensor ops is keeping track of their shapes. The standard practice today is to write shapes down as comments as you go. This talk introduces an experimental Pyrefly feature that brings tensor shapes into Python's type system, so those shape annotations can become inferred type hints instead of comments.

The talk was originally presented at the PyCon US 2026 Typing Summit. The slides and edited transcript are provided below for your convenience.

📎 Slides (PDF)

Want to give it a spin? This feature is available in Pyrefly today, and we'd love to hear your feedback and suggestions.