MemoryPool

Struct MemoryPool 

Source
pub struct MemoryPool { /* private fields */ }
Expand description

NPU device memory pool for optimal allocation patterns.

Implementations§

Source§

impl MemoryPool

Source

pub fn new(device_memory_mb: usize) -> Self

Create a new memory pool.

Source

pub fn allocate_buffer(&self, size: usize) -> Result<Vec<f32>>

Allocate a buffer from the pool.

Source

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§

Source§

impl Clone for MemoryPool

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V