cpptensor/Quickstart
Quickstart
Create tensors, run operations, and verify your cpptensor build with a smoke test and benchmark.
This assumes you've completed Installation and
have the cpptensor conda environment.
1. A minimal program
#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();
}No setup call is needed before the first op — the kernel registry initializes lazily. See Backends & ISA for details.
2. Build with tests and examples
conda run -n cpptensor cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCPPTENSOR_BUILD_TESTS=ON \
-DCPPTENSOR_BUILD_EXAMPLES=ON \
-DCPPTENSOR_BUILD_BENCHMARKS=ON
conda run -n cpptensor cmake --build build -j3. Run the test suite
conda run -n cpptensor ctest --test-dir build --output-on-failure4. Smoke test and benchmark
conda run -n cpptensor ./build/test/cpptensor_lazy_init_smoke
conda run -n cpptensor ./build/benchmarks/cpptensor_bench_cpu --benchmark_min_time=0.01sISA benchmarks
The AVX2/AVX-512 benchmark binaries run a CPU capability check first and exit
with code 77 (graceful skip) when the host doesn't support the target ISA.
CTest treats 77 as skipped.
Next
- Learn the data model in Tensors & views.
- Browse the Operations catalog.
- Save and reload tensors with Checkpoints.