amx-rs
High-level ergonomic API for AMX (Apple Matrix eXtensions)
This crate provides type-safe, ergonomic abstractions over the low-level amx-sys instruction set. It includes:
- [
Matrix<T>] - Generic matrix type with operations - [
Vector<T>] - Generic vector type with iterators - [
MatMulBuilder] - Fluent API for matrix multiplication - [
ConvBuilder] - Fluent API for convolution operations
Features
- ✅ Generic over data types
- ✅ Type-safe bounds checking
- ✅ Iterator support
- ✅ Fluent builder API
- ✅ Zero-copy operations where possible
- ✅
no_stdcompatible (withalloc)
Quick Start
use Matrix;
// Create matrices
let a = zeros?;
let b = zeros?;
// Matrix operations
let c = a.transpose?;
println!;
Vectors
use Vector;
let mut v = zeros?;
v.set?;
v.set?;
// Iterate
for val in v.iter
Algorithms
Matrix Multiplication
use MatMulBuilder;
let builder = new
.transpose_a
.transpose_b
.alpha
.beta;
let c = builder.execute?;
Convolution
use ConvBuilder;
let conv = new // 3x3 kernel
.stride
.padding;
let = conv.output_dims;
Examples
Run examples:
Architecture
- amx-sys - Low-level instruction emulation (23 instructions)
- amx-rs - High-level API (this crate)
The split enables:
- Low-level research and education (amx-sys)
- Production usage with ergonomic API (amx-rs)
- Independent versioning and updates
Testing
All algorithms include unit tests:
Performance
- Dimension checking at construction time (when possible)
- Runtime bounds checking for safety
- Zero-copy operations via references
- Minimal memory overhead
License
MIT OR Apache-2.0