· via dev.to (home feed)
Incin makes tensor shape, dtype and device mismatches compile-time errors in Rust
Incin, a new Rust deep learning framework, encodes each tensor's shape, data type, device and gradient state in its type, turning mismatches that usually fail at runtime into compile-time errors.

A framework that moves tensor contracts into the compiler
A developer publishing as xupremix on dev.to has introduced Incin, a deep learning framework written in Rust with an unusual guarantee: a tensor's shape, data type, device and gradient state are all expressed as part of the tensor's type. The consequence, according to the post, is that shape, dtype and device mismatches become compiler errors rather than runtime failures. The post's title, "Incin, a rust machine learning framework for setting fire to dimensionality bugs," makes the motivating annoyance explicit.
A matmul that fails before the program runs
The post demonstrates the idea with matrix multiplication. A tensor created via Cpu.randn(shape![4, 8]) can be multiplied with one of shape [8, 2], and the result of x.matmul(&w) carries the shape [4, 2] — the operation's output type reflects the computed dimensions. When a second tensor of shape [3, 8] is passed instead, the inner dimensions 8 and 3 disagree, and the call does not compile. Nothing has to be executed: the type checker already has enough information to reject the operation.
Stated goals and available material
The author frames the project as an exploration rather than a finished product pitch. The main goal, per the post, is to find out how much of the tensor contract a type system can genuinely carry, how flexible that encoding can be made, and how pleasant the resulting API is to use day to day. Readers who want to go deeper are pointed to the published crate, the API documentation and a book that accompanies the project.
Why it matters
Dimension errors are among the most common failures in deep learning code, and in dynamically typed stacks they typically surface only when the offending line actually executes — sometimes hours into a training run. Moving that check to compilation shifts the feedback loop from runtime to the editor, catching mistakes before any code runs at all. Encoding the device and gradient state in the type extends the same early detection to a second class of bugs, such as mixing tensors that live on different hardware or forgetting which values participate in gradient computation.
Rust's type system has long been capable of this kind of static reasoning, and Incin joins a broader conversation about how much of a numerical library's correctness rules can live in types rather than assertions and tests. The open question the project sets out to answer is where the ceiling sits: real models often have data-dependent shapes that are known only at runtime, and any type-level scheme must either fix dimensions statically or offer a graceful path for dynamic ones. How that balance works in practice is precisely what the author says the experiment is designed to probe.
For now, the project stands as both a usable library and a test of an idea — that the tensor contract, one of the most bug-prone interfaces in machine learning code, can be enforced by the compiler.
- #rust
- #deep-learning
- #type-safety
- #machine-learning
- #tensors