Skip to main content

svod_device/
lib.rs

1//! Device abstraction layer for tensor operations.
2//!
3//! This module provides a clean abstraction over different compute devices (CPU, CUDA, etc.)
4//! with support for:
5//! - Lazy buffer allocation
6//! - Buffer views with zero-copy slicing
7//! - LRU caching of allocations for performance
8//! - Device-agnostic copy operations
9//!
10//! # Examples
11//!
12//! ```no_run
13//! use svod_device::allocator::BufferOptions;
14//! use svod_device::{Buffer, registry};
15//! use svod_dtype::DType;
16//!
17//! // Get a CPU device
18//! let cpu = registry::cpu().unwrap();
19//!
20//! // Create a buffer with lazy allocation
21//! let buffer = Buffer::new(cpu, DType::Float32, vec![10, 10], BufferOptions::default());
22//!
23//! // Allocation happens on first use
24//! buffer.ensure_allocated().unwrap();
25//! ```
26
27pub mod allocator;
28pub mod buffer;
29pub mod device;
30pub mod error;
31pub mod queue;
32pub mod registry;
33pub mod sync;
34
35pub use buffer::{Buffer, BufferId};
36pub use device::Program;
37pub use error::{Error, Result};
38pub use queue::{DynQueue, ExecParams, HardwareQueue, QueueFactory};
39pub use sync::{CpuTimelineSignal, TimelineSignal};
40
41#[cfg(test)]
42mod test;
43
44// Re-export commonly used types
45#[cfg(feature = "cuda")]
46pub use allocator::CudaAllocator;
47pub use allocator::{Allocator, BufferOptions, CpuAllocator};
48#[cfg(feature = "cuda")]
49pub use registry::cuda;
50pub use registry::{DeviceSpec, cpu, get_device};