pub struct MemoryPool { /* private fields */ }Expand description
NPU device memory pool for optimal allocation patterns.
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub fn allocate_buffer(&self, size: usize) -> Result<Vec<f32>>
pub fn allocate_buffer(&self, size: usize) -> Result<Vec<f32>>
Allocate a buffer from the pool.
Sourcepub fn get_manager(&self) -> MemoryManager
pub fn get_manager(&self) -> MemoryManager
Get memory manager.
Examples found in repository?
examples/full_inference_pipeline.rs (line 46)
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}Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryPool
impl !RefUnwindSafe for MemoryPool
impl Send for MemoryPool
impl Sync for MemoryPool
impl Unpin for MemoryPool
impl !UnwindSafe for MemoryPool
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