Skip to content

Repository files navigation

Tensor Engine

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.


What it does

  • 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

Structure

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

Run it

cargo test
cargo bench

What it covers

  • 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

About

Tensor engine from scratch in Rust — generic ops, AVX2 matmul, autograd with backward pass, linear regression. No PyTorch, no ndarray.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages