10 releases (4 breaking)

0.6.3 Feb 11, 2023
0.6.2 Feb 10, 2023
0.5.0 Sep 10, 2022
0.4.6 Aug 16, 2022
0.1.4 Jul 26, 2022

#630 in Machine learning


Used in gradients

MIT license

145KB
3.5K SLoC

custos-math

Crates.io version Docs

This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using custos.

Installation

Add "custos-math" as a dependency: You will also need custos, if you want to run an example.

[dependencies]
custos-math = "0.6.3"

# to disable the default features (cuda, opencl) and use an own set of features:
#custos-math = { version="0.6.3", default-features = false, features=["opencl"]}

custos-math supports no-std via the no-std feature. This activates the "stack" feature, providing a Stack device.

custos is accessible via custos_math::custos::{..}

Example

use custos_math::{Matrix, custos::CPU};

fn main() {
    let device = CPU::new();

    let a = Matrix::from((&device, (2, 3), [1., 2., 3., 4., 5., 6.,]));
    let b = Matrix::from((&device, (3, 2), [6., 5., 4., 3., 2., 1.,]));

    let c = a.gemm(&b);

    assert_eq!(c.read(), vec![20., 14., 56., 41.,]);
}

Many more examples can be found in the tests and examples folder.

Dependencies

~0.6–1.1MB
~26K SLoC