MemoryCalculator

Struct MemoryCalculator 

Source
pub struct MemoryCalculator<T: IsFloat + Debug + Copy + Clone> { /* private fields */ }
Expand description

Wrapper that manages storage of matrices and custom kernels and manages calculation operations.

Implementations§

Source§

impl<T: IsFloat + Debug + Copy + Clone> MemoryCalculator<T>

Source

pub fn store_matrix(&mut self, matrix: Matrix<T>) -> Result<usize>

Store matrix to calculator and gpu memory.

Source§

impl MemoryCalculator<f32>

Source

pub fn init() -> Result<MemoryCalculator<f32>>

Initializes Calculator struct.

Source

pub fn mat_mul( &mut self, left_idx: usize, right_idx: usize, ) -> Result<(Matrix<f32>, usize)>

Multiply Matrix and Matrix.

Source

pub unsafe fn load_custom_fn( &mut self, program_source: &str, kernel_name: &str, parameter_fn: MemoryParameterFunction<f32>, ) -> Result<usize>

Compile and store a custom kernel and build/store a closure to execute said kernel.

Source

pub unsafe fn exec_custom_fn( &mut self, custom_index: usize, input_floats: Option<Vec<f32>>, input_ints: Option<Vec<i32>>, input_mat_idcs: Vec<usize>, ) -> Result<(Matrix<f32>, usize)>

Execute custom kernel via pre-generated closure.

Source§

impl MemoryCalculator<f64>

Source

pub fn init() -> Result<MemoryCalculator<f64>>

Initializes Calculator struct.

Source

pub fn mat_mul( &mut self, left_idx: usize, right_idx: usize, ) -> Result<(Matrix<f64>, usize)>

Multiply Matrix and Matrix.

Source

pub unsafe fn load_custom_fn( &mut self, program_source: &str, kernel_name: &str, parameter_fn: MemoryParameterFunction<f64>, ) -> Result<usize>

Compile and store a custom kernel and build/store a closure to execute said kernel.

Source

pub unsafe fn exec_custom_fn( &mut self, custom_index: usize, input_floats: Option<Vec<f64>>, input_ints: Option<Vec<i32>>, input_mat_idcs: Vec<usize>, ) -> Result<(Matrix<f64>, usize)>

Execute custom kernel via pre-generated closure.

Auto Trait Implementations§

§

impl<T> Freeze for MemoryCalculator<T>

§

impl<T> !RefUnwindSafe for MemoryCalculator<T>

§

impl<T> !Send for MemoryCalculator<T>

§

impl<T> !Sync for MemoryCalculator<T>

§

impl<T> Unpin for MemoryCalculator<T>
where T: Unpin,

§

impl<T> !UnwindSafe for MemoryCalculator<T>

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> 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, 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.