| Crates.io | numina |
| lib.rs | numina |
| version | 0.0.1 |
| created_at | 2025-11-04 11:13:30.039007+00 |
| updated_at | 2025-11-04 11:13:30.039007+00 |
| description | Backend-agnostic array library for high-performance computing in Rust |
| homepage | https://github.com/SkuldNorniern/numina |
| repository | https://github.com/SkuldNorniern/numina |
| max_upload_size | |
| id | 1916133 |
| size | 147,425 |
A safe, efficient array library with ndarray-compatible operations, designed as the foundation for high-performance computing backends in Rust.
NdArray trait enables multiple backends (CPU, GPU, remote)use numina::{Array, Shape, add, matmul, sum, F32};
// Create arrays
let a = Array::from_slice(&[1.0f32, 2.0, 3.0, 4.0], Shape::from([2, 2]))?;
let b = Array::from_slice(&[5.0f32, 6.0, 7.0, 8.0], Shape::from([2, 2]))?;
// Operations work on any NdArray backend
let c = add(&a, &b)?; // Element-wise addition
let d = matmul(&a, &b)?; // Matrix multiplication
let total = sum(&a, None)?; // Sum all elements
let row_sums = sum(&a, Some(1))?; // Sum along axis
Array<T>: Typed N-dimensional arrays for CPU operationsCpuBytesArray: Byte-based N-dimensional arrays for CPU operationsNdArray: Backend-agnostic trait for all array operationsShape: Multi-dimensional array dimensionsDType: Data types (f32, f64, i8-i64, u8-u64, bool, custom types)Design Philosophy: Numina provides the low-level backend infrastructure. High-level tensor APIs (like Tensor types) are provided by dependent crates like laminax-types which build upon Numina's NdArray trait.
use numina::{BFloat16, QuantizedU8, QuantizedI4};
// Brain Float 16
let bf16 = BFloat16::from_f32(3.14159);
assert_eq!(bf16.size_bytes(), 2);
// 8-bit quantized
let q8 = QuantizedU8::quantize(2.5, 0.01);
assert!((q8.dequantize() - 2.5).abs() < 0.1);
// 4-bit quantized (2 values per byte)
let q4 = QuantizedI4::pack(3, -2, 1.0);
assert_eq!(q4.size_bytes(), 1); // 87.5% memory savings!
use numina::{Array, CpuBytesArray, Shape, add, F32};
// Different backend implementations
let typed_array = Array::from_slice(&[1.0f32, 2.0], Shape::from([2]))?;
let bytes = [1.0f32, 2.0].iter().flat_map(|&x| x.to_le_bytes()).collect();
let byte_array = CpuBytesArray::new(bytes, Shape::from([2]), F32);
// Same operations work on all backends
let sum1 = add(&typed_array, &byte_array)?;
let sum2 = add(&byte_array, &typed_array)?;
// Cross-backend operations are fully supported
assert_eq!(sum1.shape(), sum2.shape());
src/
├── array/ # NdArray trait and CPU implementations
├── dtype/ # Data type system and custom types
├── ops.rs # Mathematical operations
├── reductions.rs # Reduction operations
├── sorting.rs # Sorting and searching
└── lib.rs # Library interface
Implemented:
Planned:
Numina serves as one of the core libraries for Laminax, enabling high-performance GPU/CPU computing.