Crates.io | briny_ai |
lib.rs | briny_ai |
version | 0.3.0 |
created_at | 2025-07-08 16:46:21.903206+00 |
updated_at | 2025-08-23 00:57:20.348215+00 |
description | A tiny & efficient AI inference engine |
homepage | |
repository | https://github.com/bobbothe2nd/briny_ai |
max_upload_size | |
id | 1743180 |
size | 271,142 |
A minimal deep learning core for scalar and tensor autograd, written in Rust.
This library provides low-level primitives for defining and training differentiable models on top of multi-dimensional arrays (Tensor<T>
,Tensor<T, N, D>
, VecTensor<T>
), supporting:
briny_ai
may not be a popular crate, but it is a growing one.
v0.1.0 |
v0.2.0 |
v0.2.1 |
v0.2.2 |
|
---|---|---|---|---|
Size | 9.92 KiB | 40.4 KiB | 42.3 KiB | 42.1 KiB |
Downloads | ~200 | ~130 | ~180 | ~150 |
[*] The downloads section is just throughout the first few days
.bpat
binary model format with safe, explicit parsingTo use briny_ai
, add it to your Cargo.toml
or run the command cargo add briny_ai
in your terminal.
To enable SIMD, pass the feature flag simd
. Similarly, to enable GPU acceleration, pass the feature flag wgpu
to the compiler. In order to make use of such features, you should set the backend like:
set_backend(Backend::Wgpu);
set_backend(Backend::Cpu); //default
set_backend(Backend::Cuda) // same as Wgpu
As of v0.3.0
, all std
-dependent features like saving and loading files are gated behind the std
feature flag. Similarly, all dynamic allocations are gated behind an alloc
feature, enabled whenever std
is enabled automatically.
NOTE: SIMD only works on AVX2 compatible x86_64 devices.
use briny_ai::tensors::{Tensor, WithGrad};
use briny_ai::backprop::{relu, matmul, mse_loss, sgd};
fn main() {
let x = WithGrad::from(Tensor::new(vec![1, 2], vec![1.0, 2.0]));
let w = WithGrad::from(Tensor::new(vec![2, 1], vec![0.5, -1.0]));
let (y, back1) = matmul(&x, &w);
let (a, back2) = relu(&WithGrad::from(y));
let target = Tensor::new(vec![1, 1], vec![0.0]);
let (loss, back3) = mse_loss(&WithGrad::from(a.clone()), &target);
let grad_a = back3(1.0);
let grad_y = back2(&grad_a);
let (grad_x, grad_w) = back1(&grad_y);
println!("Loss: {:.4}", loss);
println!("Gradients: {:?}", grad_w);
}
use briny_ai::modelio::{save_model, load_model};
let tensor = Tensor::new(vec![2, 2], vec![1.0, 2.0, 3.0, 4.0]);
save_model("model.bpat", &[tensor.clone()]).unwrap();
let tensors = load_model("model.bpat").unwrap();
assert_eq!(tensors[0], tensor);
briny_ai
tch-rs
or burn
, briny_ai
stays small and straightforward. It’s perfect if you want just the core building blocks without bloat or magic.briny_ai
relies on your own control flow and simple GPU acceleration via wgpu, avoiding large, complex dependencies or runtime surprises.briny_ai
is tailored for that.If you want a no-nonsense, Rust-native AI core that’s lean, secure, and explicit — briny_ai
is the right tool for you.
PRs welcome. This project is early-stage but cleanly structured and easy to extend. Open issues or ideas any time!
Got an Nvidia GPU or know CUDA? Your help is golden!
Under the MIT License.