Expand description
Tensor Memory Pool
This module provides two complementary memory pool implementations:
-
TensorMemoryPool— Slab-based pool with size-class bucketing for efficient allocation of variable-sized tensor buffers. -
TensorBlockPool— Pre-allocated fixed-size block pool that reduces allocation overhead by maintaining a reservoir of identically-sized memory blocks with owner tracking, reservation support, and defragmentation.
§Slab Pool (TensorMemoryPool)
Uses four size classes (Small/Medium/Large/Huge) with power-of-two bucket sizes. Best suited when tensor sizes vary widely.
use ipfrs_tensorlogic::memory_pool::{TensorMemoryPool, SizeClass};
let mut pool = TensorMemoryPool::new(64);
let slot_id = pool.allocate(2048, 1).expect("example: should succeed in docs");
assert!(pool.deallocate(slot_id, 2));
let slot_id2 = pool.allocate(1024, 3).expect("example: should succeed in docs");
assert_eq!(slot_id, slot_id2);§Block Pool (TensorBlockPool)
All blocks share a single configured size. Supports reservation, owner tracking, generation counting, defragmentation, and shrink-to-fit.
use ipfrs_tensorlogic::memory_pool::{TensorBlockPool, PoolConfig};
let config = PoolConfig::default();
let mut pool = TensorBlockPool::new(config);
let id = pool.allocate("matmul").expect("example: should succeed in docs");
assert!(pool.deallocate(id).is_ok());Structs§
- Block
Pool Stats - Aggregate statistics for a
TensorBlockPool. - Memory
Block - A single block managed by the
TensorBlockPool. - Memory
Pool Stats - Aggregate statistics for a
TensorMemoryPool. - Pool
Config - Configuration for a
TensorBlockPool. - Pool
Slot - A single slot managed by the
TensorMemoryPool. - Tensor
Block Pool - Pre-allocated memory pool for tensor operations to reduce allocation overhead.
- Tensor
Memory Pool - A slab-based memory pool that pre-allocates tensor buffers organised into size-class buckets to minimise allocation overhead on hot inference paths.
Enums§
- Block
Status - Status of a single block within a
TensorBlockPool. - Size
Class - Categorises a byte count into one of four allocation buckets.