A tensor engine built from scratch in Rust — no PyTorch, no ndarray, no dependencies beyond my own matmul kernel.
I built this to understand what actually sits underneath frameworks like PyTorch. Not to replace them — just to understand them. Turns out a tensor engine is a surprisingly small thing when you strip away the abstractions.
- Generic tensor operations — add, sub, mul, relu across f32/f64
- Matrix multiply backed by an AVX2 SIMD kernel with cache blocking
- Autograd — forward and backward pass with
Value::matmul - Linear regression as a working end-to-end example
- Criterion benchmarks with results committed
crates/
core/ — Tensor type, layout, slice/get API
ops/ — Element-wise ops, relu, matrix multiply
autograd/ — Forward + backward pass, sum(), matmul backward
macros/ — Derive macros
cargo test
cargo bench- Generic Rust with trait bounds —
Copy + Add<Output = T> - AVX2 intrinsics for matrix multiply performance
- Autograd from first principles — no magic, just the chain rule
- Cargo workspace with multiple crates
- CI with GitHub Actions