axonml-core
Overview
axonml-core is the foundational layer of the AxonML machine learning framework. It provides core abstractions for device management, memory storage, data types, and pluggable backend implementations that underpin all tensor operations across CPU and GPU devices.
Features
-
Device Abstraction - Unified interface for managing compute devices including CPU, CUDA, Vulkan, Metal, and WebGPU backends with seamless tensor transfer between devices.
-
Type-Safe Data Types - Comprehensive type system supporting f16, f32, f64, i8, i16, i32, i64, u8, u32, u64, and bool with automatic type promotion rules.
-
Efficient Memory Storage - Reference-counted storage with zero-copy slicing, automatic memory cleanup, and device-agnostic operations.
-
Pluggable Backend Architecture - Extensible backend system with a common
Backendtrait enabling device-agnostic tensor operations. -
Memory Allocator - Flexible allocator trait with default CPU implementation and support for custom memory pools.
-
Device Capabilities - Query device capabilities including memory, f16/f64 support, and compute capability for optimal resource utilization.
Modules
| Module | Description |
|---|---|
device |
Device abstraction (CPU, CUDA, Vulkan, Metal, WebGPU) with availability checking and capability queries |
dtype |
Data type definitions with Scalar, Numeric, and Float traits for type-safe operations |
storage |
Reference-counted memory storage with views, slicing, and device transfer |
allocator |
Memory allocation traits and default CPU allocator implementation |
backends |
Device-specific backend implementations for compute operations |
error |
Comprehensive error types for shape mismatches, device errors, and memory allocation failures |
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic Example
use ;
// Check device availability
let device = Cpu;
assert!;
// Create storage on CPU
let storage = zeros;
assert_eq!;
// Create storage from data
let data = vec!;
let storage = from_vec;
// Create a view (zero-copy slice)
let view = storage.slice.unwrap;
assert_eq!;
Device Capabilities
use Device;
let device = Cpu;
let caps = device.capabilities;
println!;
println!;
println!;
println!;
Data Types
use ;
// Query dtype properties
assert!;
assert_eq!;
// Use type traits
Tests
Run the test suite:
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.