edgefirst-tensor
Zero-copy tensor memory management for edge AI applications.
This crate provides a unified interface for managing multi-dimensional arrays (tensors) with support for different memory backends optimized for ML inference pipelines.
Memory Types
| Type | Description | Use Case |
|---|---|---|
| DMA | Linux DMA-BUF allocation | Hardware accelerators (GPU, NPU, video codecs) |
| SHM | POSIX shared memory | Inter-process communication, zero-copy IPC |
| Mem | Standard heap allocation | General purpose, maximum compatibility |
Features
- Automatic memory selection - Tries DMA → SHM → Mem based on availability
- Zero-copy sharing - Share tensors between processes via file descriptors
- Memory mapping - Efficient CPU access to tensor data
- ndarray integration - Optional conversion to/from
ndarray::Array(feature:ndarray)
Quick Start
use ;
// Create a tensor with automatic memory selection
let tensor = new?;
println!;
// Create with explicit memory type
let dma_tensor = new?;
// Map tensor for CPU access
let mut map = tensor.map?;
map.as_mut_slice.fill;
// Share via file descriptor (Unix only)
let fd = tensor.clone_fd?;
Platform Support
| Platform | DMA | SHM | Mem |
|---|---|---|---|
| Linux | Yes | Yes | Yes |
| macOS | No | Yes | Yes |
| Other Unix | No | Yes | Yes |
| Windows | No | No | Yes |
Feature Flags
ndarray(default) - Enablendarrayintegration for array conversions
Environment Variables
EDGEFIRST_TENSOR_FORCE_MEM- Set to1ortrueto force heap allocation
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.