pub struct MemoryManager { /* private fields */ }Expand description
NPU device memory manager.
Implementations§
Source§impl MemoryManager
impl MemoryManager
Sourcepub fn deallocate(&self, bytes: usize)
pub fn deallocate(&self, bytes: usize)
Free memory on device.
Sourcepub fn get_stats(&self) -> MemoryStats
pub fn get_stats(&self) -> MemoryStats
Get current memory statistics.
Sourcepub fn get_available_bytes(&self) -> usize
pub fn get_available_bytes(&self) -> usize
Get available memory in bytes.
Examples found in repository?
examples/full_inference_pipeline.rs (line 48)
22fn setup_device() {
23 println!("1. Device Setup");
24
25 let device_info = DeviceInfo {
26 device_id: 0,
27 peak_throughput_tops: 20.0,
28 memory_mb: 512,
29 compute_units: 4,
30 frequency_mhz: 800,
31 power_tdp_watts: 5.0,
32 vendor: "Xilinx/SiFive".to_string(),
33 device_name: "XilinxAI-Engine 20-TOPS".to_string(),
34 };
35
36 let device = Arc::new(NpuDevice::with_config(device_info));
37 match device.initialize() {
38 Ok(_) => {
39 println!(" ✓ Device initialized");
40 let info = device.get_info();
41 println!(" Device: {} ({} MB memory, {} TOPS peak)",
42 info.device_name, info.memory_mb, info.peak_throughput_tops
43 );
44
45 let memory_pool = device.get_memory_pool();
46 let manager = memory_pool.get_manager();
47 println!(" Available memory: {} MB\n",
48 manager.get_available_bytes() / 1024 / 1024
49 );
50 }
51 Err(e) => println!(" ✗ Init failed: {}\n", e),
52 }
53}Sourcepub fn has_capacity(&self, bytes: usize) -> bool
pub fn has_capacity(&self, bytes: usize) -> bool
Check if enough memory is available.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryManager
impl RefUnwindSafe for MemoryManager
impl Send for MemoryManager
impl Sync for MemoryManager
impl Unpin for MemoryManager
impl UnwindSafe for MemoryManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more