Skip to main content

Crate morok_device

Crate morok_device 

Source
Expand description

Device abstraction layer for tensor operations.

This module provides a clean abstraction over different compute devices (CPU, CUDA, etc.) with support for:

  • Lazy buffer allocation
  • Buffer views with zero-copy slicing
  • LRU caching of allocations for performance
  • Device-agnostic copy operations

§Examples

use morok_device::allocator::BufferOptions;
use morok_device::{Buffer, registry};
use morok_dtype::DType;

// Get a CPU device
let cpu = registry::cpu().unwrap();

// Create a buffer with lazy allocation
let buffer = Buffer::new(cpu, DType::Float32, vec![10, 10], BufferOptions::default());

// Allocation happens on first use
buffer.ensure_allocated().unwrap();

Re-exports§

pub use buffer::Buffer;
pub use buffer::BufferId;
pub use error::Error;
pub use error::Result;
pub use queue::DynQueue;
pub use queue::ExecParams;
pub use queue::HardwareQueue;
pub use queue::Program;
pub use queue::QueueFactory;
pub use sync::CpuTimelineSignal;
pub use sync::TimelineSignal;
pub use allocator::Allocator;
pub use allocator::BufferOptions;
pub use allocator::CpuAllocator;
pub use registry::cpu;
pub use registry::get_device;

Modules§

allocator
buffer
device
Device abstraction following Tinygrad’s architecture.
error
queue
Hardware command queue abstraction for parallel execution.
registry
sync
Timeline synchronization primitives for parallel execution.

Enums§

DeviceSpec
Device specification parsed from a device string.