cml is a C99-based machine learning library project.
It links against CBLAS for linear algebra operations.
The repository is in an early work-in-progress stage. Do not use! If you're seeing this, there's probably barely anything to use at all.
- CMake 3.21+
- A C compiler (GCC/Clang/MSVC)
- Ninja (recommended generator used in examples)
- A BLAS implementation with CBLAS support available as a static library (for example: OpenBLAS, BLIS, Intel MKL, or Apple Accelerate), or allow CMake to fetch OpenBLAS automatically
- (Optional) CUDA Toolkit with cuBLAS for GPU backend support
Configure and build:
cmake -Bbuild -GNinja .
cmake --build buildAddressSanitizer and UndefinedBehaviorSanitizer are enabled by default (non-MSVC builds).
To disable sanitizers:
cmake -Bbuild -GNinja . -DCML_ENABLE_SANITIZERS=OFFTo explicitly enable:
cmake -Bbuild -GNinja . -DCML_ENABLE_SANITIZERS=ONWhen CUDA backend support is enabled, sanitizers are skipped.
cml uses CBLAS for linear algebra operations and links it into the cml target.
The build first tries to find a system BLAS with CBLAS headers and static libraries. If none is found, it fetches and builds OpenBLAS statically by default.
To disable auto-fetching and require a system BLAS:
cmake -Bbuild -GNinja . -DCML_FETCH_OPENBLAS=OFFTo compile CUDA support:
cmake -Bbuild -GNinja . -DCML_ENABLE_CUDA=ON
cmake --build buildcml passes -allow-unsupported-compiler and -std=c++20 to nvcc by default to help with newer host compilers.
To disable that behavior, set -DCML_CUDA_ALLOW_UNSUPPORTED_COMPILER=OFF.
Use cml_init_with_backend(..., CML_BACKEND_CUDA) to request CUDA for a context.
cml_init(...) keeps the default CPU backend.
When CML_ENABLE_CUDA=ON, an additional test target (test_cuda_parity) is added.
It verifies parity between CPU and CUDA results for deterministic tensor operations.
If CUDA is compiled in but no runtime CUDA device/backend is available, parity checks are skipped.
After configuring and building, run:
ctest --test-dir build --output-on-failureTesting is wired through CTest, with a basic framework setup called Unity.
This may be swapped in the future because it doesn't have many features as its target is embedded platforms, but it provides everything currently needed.
GitHub Actions runs:
build-and-test: regular CPU build/tests on Ubuntu and Windows.build-and-test-cuda: CUDA-enabled Ubuntu build/tests with CUDA toolkit installation and-DCML_ENABLE_CUDA=ON.