amx-rs 0.0.1

High-level ergonomic API for AMX (Apple Matrix eXtensions) - matrix and vector operations
Documentation
  • Coverage
  • 92.86%
    65 out of 70 items documented0 out of 36 items with examples
  • Size
  • Source code size: 21.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.64 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 54s Average build duration of successful builds.
  • all releases: 54s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • eugenehp/amx-rs
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eugenehp

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_std compatible (with alloc)

Quick Start

use amx::Matrix;

// Create matrices
let a = Matrix::<f32>::zeros(8, 8)?;
let b = Matrix::<f32>::zeros(8, 8)?;

// Matrix operations
let c = a.transpose()?;
println!("{}", c);

Vectors

use amx::Vector;

let mut v = Vector::<f32>::zeros(10)?;
v.set(0, 3.14)?;
v.set(1, 2.71)?;

// Iterate
for val in v.iter() {
    println!("{}", val);
}

Algorithms

Matrix Multiplication

use amx::algorithms::MatMulBuilder;

let builder = MatMulBuilder::new()
    .transpose_a(false)
    .transpose_b(false)
    .alpha(1.0)
    .beta(0.0);

let c = builder.execute(&a, &b)?;

Convolution

use amx::algorithms::ConvBuilder;

let conv = ConvBuilder::new(3, 3)  // 3x3 kernel
    .stride(1, 1)
    .padding(1, 1);

let (out_h, out_w) = conv.output_dims(224, 224);

Examples

Run examples:

cargo run --example matrix_ops
cargo run --example vector_ops

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:

cargo test

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