https://github.com/elftausend/custos-math
Matrix implementation using custos
https://github.com/elftausend/custos-math
custos math matrix neural-network rust
Last synced: 3 days ago
JSON representation
Matrix implementation using custos
- Host: GitHub
- URL: https://github.com/elftausend/custos-math
- Owner: elftausend
- License: mit
- Created: 2022-03-28T17:40:07.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-07T11:17:40.000Z (about 1 year ago)
- Last Synced: 2025-04-11T03:52:37.282Z (3 days ago)
- Topics: custos, math, matrix, neural-network, rust
- Language: Rust
- Homepage:
- Size: 491 KB
- Stars: 12
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cuda-and-hpc - custos-math - math?style=social"/> : This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using [custos](https://github.com/elftausend/custos). (Frameworks)
- awesome-rust-list - custos-math - math?style=social"/> : This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using [custos](https://github.com/elftausend/custos). (Scientific Computation)
- awesome-rust-list - custos-math - math?style=social"/> : This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using [custos](https://github.com/elftausend/custos). (Scientific Computation)
README
# custos-math
[](https://crates.io/crates/custos-math)
[](https://docs.rs/custos-math/0.6.3/custos-math/)This crate provides CUDA, OpenCL, CPU (and Stack) based matrix operations using [custos].
[custos]: https://github.com/elftausend/custos
## Installation
Add "custos-math" as a dependency:
You will also need [custos], if you want to run an example.
```toml
[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
```rust
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.