| Crates.io | custos-math |
| lib.rs | custos-math |
| version | 0.6.3 |
| created_at | 2022-07-17 09:47:15.610688+00 |
| updated_at | 2023-02-11 20:10:52.283519+00 |
| description | Matrix operations with custos |
| homepage | |
| repository | https://github.com/elftausend/custos-math |
| max_upload_size | |
| id | 627149 |
| size | 221,902 |
This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using custos.
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::{..}
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.