cpptensor/Overview
cpptensor
A CPU-first C++ tensor library with runtime AVX2/AVX-512 dispatch, optional OpenBLAS acceleration, and early CUDA support.
cpptensor is a C++ tensor library focused on CPU performance. It pairs a
generic implementation with build-time AVX2/AVX-512 specializations, dispatches
between them at runtime based on the host CPU, and can offload linear algebra to
OpenBLAS. Early CUDA support is available behind a build flag.
What you get
- N-dimensional
Tensorwith views and contiguous materialization. - A broad op set — arithmetic, unary math, reductions, comparisons, plus reshape / transpose / concat / stack.
- Linear algebra —
matmul,dot,tensordot,svd, andeig. - Runtime ISA dispatch — generic, AVX2, and AVX-512 kernels selected after validating CPU feature bits and OS state.
- Lazy kernel registry — ops initialize the kernel registry on first use, so
a fresh process can call
A + Bwithout manual setup. - Numerically careful reductions —
sum,mean, anddotuse widened, compensated accumulation. - Checkpoints —
Tensor::save/Tensor::loadwith a versioned binary format. - Tests & benchmarks — a Catch2 suite and Google Benchmark targets.
Platform support
| Platform | Status |
|---|---|
| Linux x86_64 | Supported / primary path. |
| Linux aarch64 | Generic CPU path; AVX2/AVX-512 auto-disabled. |
| macOS | CPU builds expected; CUDA forced OFF. |
| Windows | Experimental (outside the documented conda workflow). |
At a glance
#include "cpptensor/tensor/tensor.hpp"
#include "cpptensor/ops/arithmetic/add.hpp"
int main() {
using namespace cpptensor;
Tensor a = Tensor::full({2, 2}, 1.0f);
Tensor b = Tensor::full({2, 2}, 2.0f);
Tensor c = a + b;
c.print();
}Status
cpptensor is beta — the CPU path (generic + AVX2/AVX-512), OpenBLAS-backed
linear algebra, reductions, and checkpoint I/O are validated, while CUDA support
is early and off by default. See the roadmap.
Where to next
- New here? Start with Installation and the Quickstart.
- Learn the data model in Tensors & views and the Operations catalog.
- Tuning performance? See Backends & ISA and the Build options.