7 releases

Uses new Rust 2021

new 0.4.4 Aug 7, 2022
0.4.3 Aug 5, 2022
0.2.1 Aug 1, 2022
0.2.0 Jul 31, 2022
0.1.4 Jul 26, 2022

#111 in Machine learning

Download history 46/week @ 2022-07-14 87/week @ 2022-07-21 79/week @ 2022-07-28 72/week @ 2022-08-04

284 downloads per month
Used in gradients

MIT license

100KB
2.5K SLoC

custos-math

Crates.io version Docs

This crate provides CUDA, OpenCL and CPU 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.4.4"
custos = "0.4.4"

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

Example

use custos::CPU;
use custos_math::Matrix;

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

~170KB